gpt4 book ai didi

python - 如何在 python 中从 perforce check out 文件?

转载 作者:太空狗 更新时间:2023-10-29 17:00:40 25 4
gpt4 key购买 nike

我想用 python 编写一些脚本,对源代码进行一些自动更改。如果脚本确定它需要更改文件,我想首先从 perforce 中检查它。我不关心 checkin ,因为我总是想先构建和测试。

最佳答案

Perforce 在其 C/C++ 工具周围有 Python 包装器,以二进制形式提供给 Windows,并为其他平台提供源代码:

http://www.perforce.com/perforce/loadsupp.html#api

您会发现他们的脚本 API 文档很有用:

http://www.perforce.com/perforce/doc.current/manuals/p4script/p4script.pdf

Python API 的使用与命令行客户端非常相似:

PythonWin 2.5.1 (r251:54863, May  1 2007, 17:47:05) [MSC v.1310 32 bit (Intel)] on win32.
Portions Copyright 1994-2006 Mark Hammond - see 'Help/About PythonWin' for further copyright information.
>>> import P4
>>> p4 = P4.P4()
>>> p4.connect() # connect to the default server, with the default clientspec
>>> desc = {"Description": "My new changelist description",
... "Change": "new"
... }
>>> p4.input = desc
>>> p4.run("changelist", "-i")
['Change 2579505 created.']
>>>

我将从命令行验证它:

P:\>p4 changelist -o 2579505
# A Perforce Change Specification.
#
# Change: The change number. 'new' on a new changelist.
# Date: The date this specification was last modified.
# Client: The client on which the changelist was created. Read-only.
# User: The user who created the changelist.
# Status: Either 'pending' or 'submitted'. Read-only.
# Description: Comments about the changelist. Required.
# Jobs: What opened jobs are to be closed by this changelist.
# You may delete jobs from this list. (New changelists only.)
# Files: What opened files from the default changelist are to be added
# to this changelist. You may delete files from this list.
# (New changelists only.)

Change: 2579505

Date: 2008/10/08 13:57:02

Client: MYCOMPUTER-DT

User: myusername

Status: pending

Description:
My new changelist description

关于python - 如何在 python 中从 perforce check out 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/184187/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com