本文介绍了如何使用 Perforce Python API 在一天内检索提交的更改列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Perforce Python API 的新手,并且仍在寻找通过它的方法.到目前为止,如果我提供文件名,我已经能够检索更改列表信息,如编号、desc 等.我正在尝试获取指定日期/时间范围内所有提交的更改列表的列表,以便我可以收集更改的文件和每个更改列表的描述等信息.有没有办法使用 API 来做到这一点?

I am new to Perforce Python API and still finding my way through it. So far I have been able to retrieve changelist information like number, desc etc, if I provide the file name. I am trying to get a list of all the submitted changelists for a specified date/time range so that I can gather information like files changed and description of each changelist etc. Is there a way to do this using the API?

谢谢

推荐答案

阅读不完整的 P4Python 文档来自 Perforce 论坛的一个问题,这段代码可能会起作用,但请记住它是完全未经测试的**所以警告空客和所有这些

From a read of the less than extensive P4Python documentation and a question from the Perforce forum, this code might do the trick but bear in mind it is completely untested** so caveat emptor and all that

在filelog命令中,...好像是请求文件夹内所有文件的方式,所以只需要替换server文件夹 具有适当的值.

In the filelog command, the ... seems to be the way of requesting all files in the folder, so you only need to replace server and folder with the appropriate values.

from P4 import P4, P4Exception
p4 = P4()
p4.port = "1"
p4.user = "User"
p4.client = "Client"

try:
    p4.connect()
    changelist = p4.run_filelog('//server/folder/...@yyyy/mm/dd,@now')
    for r in changelist:
      print r.depotFile
      print r.revisions[0].time

except P4Exception:
    for e in p4.errors:
        print e

finally:
    p4.disconnect()

** 是的,我本可以下载 Perforce,安装它,添加一些文件,然后测试代码,但这似乎有点矫枉过正.

** Yes, I could have downloaded Perforce, installed it, added some files and then tested the code, but that seemed like a mild degree of overkill.

这篇关于如何使用 Perforce Python API 在一天内检索提交的更改列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 11:14