First of all p4.run_sync()
or any of the p4.run_COMMAND()
returns a list and not a dict. Each element of the list could be either a dict or a string depending on the perforce server support and whether you disabled tagged or not.
From the documentation of the p4.run
:
Whether the elements of the array are strings or dictionaries depends on
(a) server support for tagged output for the command, and
(b) whether tagged output was disabled by calling p4.tagged = False.
- When you run a
p4.run_sync()
(the equivalent ofp4 sync ...
), you're going to get the latest for all the files under that directory. - The first file in the list contains the latest change number which perforce synced to and it need not be the change at which that file was modified.
- The change number just corresponds to the latest change under that directory.
- The remaining files in the list omit this redundant information. This is the reason, the key
change
is not part of the other dicts in the list of files.
For each file you get the revision number in the rev
key which combined with the full perforce path in depotFile
corresponds to a unique version of the file in the repository (for example //depot/branch1/dir1/file1#4
).
You could just make use of this information as follows with the fstat
. (No, this is not a hacky way, this is the correct way of fetching the change number corresponding to a particular file and revision).
>>> result = p4.run_fstat("//depot/branch1/dir1/file1#4")
>>> print result[0]['headChange']
12345
This indicates that revision 4 of //depot/branch1/dir1/file1
came as part of change 12345
.