質問

I periodically get a p4 sync and want to know what actually got synced. So I get the return from p4.run_sync which is a list of dicts per change (as far as I understood)

sync = p4.run_sync()

when I print the keys it looks like that:

sync dict Nr: 0 --------------
* totalFileSize
* rev
* totalFileCount
* clientFile
* fileSize
* action
* depotFile
* change
sync dict Nr: 1 --------------
* action
* clientFile
* rev
* depotFile
* fileSize
sync dict Nr: 2 --------------
* action
* clientFile
* rev
* depotFile
* fileSize

So only in the first dict there is a change number!

How do I get the others? I currently browse the depotFiles of the other dicts and get the headChange from p4.fstat.. but this seems quite hacky...

I'd actually like each change number that was synced to fetch a describe right away.

Or is there a more proper way todo this? Thanks!

役に立ちましたか?

解決

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 of p4 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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top