如何检测 Perforce 的“重新打开进行编辑”的使用 从脚本

发布于 2024-07-23 22:25:45 字数 737 浏览 3 评论 0 原文

我正在编写一个与 Perforce 交互的脚本,其中需要能够理解待处理的变更列表。 为此,我使用“p4描述”和“p4打开”,它们非常简单。 例如,打开进行编辑的文件显示如下(从打开的 p4 开始):

//source/stuff/things.h#1 add default change (text)

我似乎无法弄清楚如何检测用户已分支文件然后使用在提交该文件之前,对该文件执行“重新打开以进行编辑”命令(相当于在要分支的文件上使用“p4 edit”)。 集成文件并在提交集成之前使用“重新打开进行编辑”也是如此。 在分支情况下,文件显示为“添加”,没有任何迹象表明还有一个分支正在进行(因此上面的示例可能是真正的添加或重新打开的分支)。 在集成情况下,它显示为“编辑”。 在这两种情况下,在提交更改后,我可以看到文件已分支/集成,但我需要能够对待处理的更改执行此操作。 理论上,我希望看到这样的东西,其中 things.h 是从 tangs.h 分支和编辑的:

//source/stuff/things.h#1 add default change (text)
  branch from //source/other/thangs.h#42

有人知道实现此目的的方法吗? 我还要提到,我正在运行 Perforce 的旧版本(从 2004 年开始),所以也许它在较新的版本中是可行的,我只需要更新我的软件。

I'm working on a script to interact with Perforce, which among other things needs to be able to understand pending changelists. For this I use 'p4 describe' and 'p4 opened', which are pretty straightforward. For instance, a file opened for edit shows up like this (from p4 opened):

//source/stuff/things.h#1 add default change (text)

What I can't seem to figure out is how to detect cases where a user has branched a file and then used the 'Reopen for edit' command on that file (which amounts to using 'p4 edit' on the file to be branched) prior to submitting it. Same thing goes for integrating a file and then using 'Reopen for edit' before submitting the integration. In the branch case, the file shows up as an 'add' with no indication that there's also a branch going on (so the above example could be either a true add or a reopened branch). In the integrate case it, shows up as an 'edit'. In both cases, after I submit the change I can see that the file was branched/integrated, but I need to be able to do this for pending changes. In theory I would hope to see something like this, where things.h is being branched and edited from thangs.h:

//source/stuff/things.h#1 add default change (text)
  branch from //source/other/thangs.h#42

Does anybody know of a way to accomplish this? I'll also mention that I'm running an old-ish version of Perforce (from 2004), so perhaps it's doable in newer versions and I just need to update my software.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ζ澈沫 2024-07-30 22:25:45

p4 returned" 几乎完全符合您的要求,但不幸的是它是2007.2新增的。

[C:\dfp\Common\Code\Python]p4 opened foo.py
//buddha/Common/Code/Python/foo.py#1 - add default change (kxtext)

[C:\dfp\Common\Code\Python]p4 resolved foo.py
c:\dfp\Common\Code\Python\foo.py - branch from //buddha/Common/Code/Python/memdump.py#1,#30

在用户运行“解决”之前,您可能无法检测到问题,但他们必须在提交之前解决问题。

"p4 resolved" does almost exactly what you want, but unfortunately it is new in 2007.2.

[C:\dfp\Common\Code\Python]p4 opened foo.py
//buddha/Common/Code/Python/foo.py#1 - add default change (kxtext)

[C:\dfp\Common\Code\Python]p4 resolved foo.py
c:\dfp\Common\Code\Python\foo.py - branch from //buddha/Common/Code/Python/memdump.py#1,#30

You probably won't be able to detect problems before the user runs "resolve", but they're going to have to resolve before they submit.

青丝拂面 2024-07-30 22:25:45

我认为在发出“重新打开编辑”时这是不可能的。 正如您已经指出的,重新打开命令会将文件状态更改为不同的状态。 我运行了本地测试(我正在运行2008.2)。 自您的版本以来,强制报告文件的添加/编辑状态的方式似乎确实发生了一些变化,但您尝试做的事情似乎仍然不可能 请

d:\sandbox\ctg_test>p4 integ test.txt test_branch.txt
//ctg_test/test_branch.txt#1 - branch/sync from //ctg_test/Test.txt#1,#15

d:\sandbox\ctg_test>p4 opened
//ctg_test/test_branch.txt#1 - branch default change (text)

注意,打开的命令现在显示“分支”文件状态而不是添加,我认为它可能已随您的服务器版本一起显示。 但更关键的是:

d:\sandbox\ctg_test>p4 edit test_branch.txt
//ctg_test/test_branch.txt#1 - reopened for add

d:\sandbox\ctg_test>p4 opened
//ctg_test/test_branch.txt#1 - add default change (text)

我尝试使用 -ztag 选项查看是否提供了更多信息:

d:\sandbox\ctg_test>p4 -ztag opened
... depotFile //ctg_test/test_branch.txt
... clientFile //client-mark.allender/ctg_test/test_branch.txt
... rev 1
... action add
... change default
... type text
... user mark.allender
... client client-mark.allender

p4 fstat 也没有帮助。

I do not think that this is possible when issuing a "reopen for edit". As you have already indicated, the reopen command will change a files status to something different. I ran a local test (I'm running 2008.2). There do seem to be some changes in the way that perforce reports on the add/edit status of files since your version, but what you are trying to do still doesn't seem possible

d:\sandbox\ctg_test>p4 integ test.txt test_branch.txt
//ctg_test/test_branch.txt#1 - branch/sync from //ctg_test/Test.txt#1,#15

d:\sandbox\ctg_test>p4 opened
//ctg_test/test_branch.txt#1 - branch default change (text)

Note that the opened command now shows 'branch' for the file status instead of add which I think it might have shown with your version of the server. But the kicker:

d:\sandbox\ctg_test>p4 edit test_branch.txt
//ctg_test/test_branch.txt#1 - reopened for add

d:\sandbox\ctg_test>p4 opened
//ctg_test/test_branch.txt#1 - add default change (text)

I tried looking with the -ztag option to see if more info was given:

d:\sandbox\ctg_test>p4 -ztag opened
... depotFile //ctg_test/test_branch.txt
... clientFile //client-mark.allender/ctg_test/test_branch.txt
... rev 1
... action add
... change default
... type text
... user mark.allender
... client client-mark.allender

p4 fstat was no help either.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文