1

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!

4

1 回答 1

3

首先p4.run_sync()或任何p4.run_COMMAND()返回一个列表而不是一个字典。列表的每个元素都可以是字典或字符串,具体取决于 perforce 服务器支持以及您是否禁用标记。

从文档中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.
  • 当您运行 a p4.run_sync()(相当于p4 sync ...)时,您将获得该目录下所有文件的最新版本。
  • 列表中的第一个文件包含 perforce 同步到的最新更改编号,它不必是修改该文件的更改。
  • 更改编号仅对应于该目录下的最新更改。
  • 列表中的其余文件省略了这些冗余信息。这就是原因,密钥change不是文件列表中其他字典的一部分。

对于每个文件,您都会在rev密钥中获得修订号,该修订号与完整的 perforce 路径相结合,depotFile对应于存储库中文件的唯一版本(例如//depot/branch1/dir1/file1#4)。

您可以将这些信息与fstat. (不,这不是一种 hacky 方式,这是获取与特定文件和修订相对应的更改号的正确方式)。

>>> result = p4.run_fstat("//depot/branch1/dir1/file1#4")
>>> print result[0]['headChange']
12345

这表明修订版 4//depot/branch1/dir1/file1是变更的一部分12345

于 2013-03-21T22:56:41.337 回答