【问题标题】:How to get the changelist number of perforce?如何获取 perforce 的变更列表编号?
【发布时间】:2020-06-02 12:33:26
【问题描述】:

我设法按照以下步骤在我的 perforce 客户端工作区中创建了一个空的更改列表:

>>> from P4 import P4,P4Exception
>>> p4 = P4()
>>> p4.connect()
P4 [ciastro@ciastromac perforce:1666] connected
>>> change = p4.fetch_change()
>>> change
{'Status': 'new', 'Client': 'ciastromac', 'User': 'ciastro', 'Change': 'new', 'Description': '<enter description here>\n'}
>>> change[ "Description" ] = "Autosubmitted 3rd changelist"
>>> p4.input = change
>>> p4.run_submit( "-i" )

这确实添加了一个更改列表,但我没有获得更改列表编号来将文件添加到更改列表。我还需要将变更列表编号提交到仓库。

【问题讨论】:

    标签: perforce p4python


    【解决方案1】:

    您根本不需要定义新的更改列表规范来提交默认更改列表。做吧:

    p4.run_submit("-d", "Autosubmitted 3rd changelist")
    

    如果您不提供更改列表编号,p4 submit 将自动从默认更改列表中获取文件,将它们放入新编号的更改列表中,然后提交。 (如果您为 -d 标志提供描述,它将使用描述而不是提示您编辑更改列表规范。)p4 submit 的输出将告诉您更改列表的最终编号。

    【讨论】:

      【解决方案2】:

      我们可以得到零钱,但你需要使用系统命令

      change = subprocess.check_output('p4 change -o | p4 change -i', shell=True).decode('utf-8').split(' ')[1]

      打印(更改) 那么您可以使用 p4.fetch_change() 和更改编号

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-05-10
        • 1970-01-01
        • 1970-01-01
        • 2012-04-28
        • 1970-01-01
        • 1970-01-01
        • 2011-12-10
        相关资源
        最近更新 更多