Perforce:如何查找更改列表的原始编号

发布于 2024-10-08 20:45:32 字数 135 浏览 8 评论 0原文

在提交时变更列表必然会被重新编号。因此,例如,当创建变更列表时,它将编号为 777 ,但是在提交变更列表时,它将被重新编号为 790 。

我的问题是,如果我知道旧的 CL 编号 777,如何获得新的 CL 编号 (790) ,或者反之亦然?

In perforce changelists get renumbered on submission. So for e.g. when the changelist was created it would be numbered 777 , but on submission of changelist it would get renumbered to say 790.

My question is how do I get the new CL number (790) , if I know the old CL number 777 , or vice versa ?

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

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

发布评论

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

评论(6

风情万种。 2024-10-15 20:45:32

如果您确实想要原始变更列表编号,可以从 Perforce 检索该编号,而无需将原始变更列表编号嵌入到描述中。您可以使用 -ztag 命令行选项来获取它。而且您只能通过“更改”命令来获取它(据我所知):

d:\sandbox>p4 submit -c 24510
Submitting change 24510.
Locking 1 files ...
edit //depot/testfile.txt#2
Change 24510 renamed change 24512 and submitted.

d:\sandbox>p4 -ztag changes -m1 //depot/testfile.txt
... change 24512
... time 1294249178
... user test.user
... client client-test.user
... status submitted
... oldChange 24510
... desc <enter description here>
<saved

正如所指出的,它可能没有那么有用。然而,我确实想指出,这是有可能实现的。

If you really want the original changelist number, that can be retrieved from Perforce without having to embed the original changelist number in the description. You can use the -ztag command line option to get at it. And you can only get at it through the 'changes' command (as far as I know):

d:\sandbox>p4 submit -c 24510
Submitting change 24510.
Locking 1 files ...
edit //depot/testfile.txt#2
Change 24510 renamed change 24512 and submitted.

d:\sandbox>p4 -ztag changes -m1 //depot/testfile.txt
... change 24512
... time 1294249178
... user test.user
... client client-test.user
... status submitted
... oldChange 24510
... desc <enter description here>
<saved

As pointed out, it's probably not that useful. However, I did want to note that it's possible to get at it.

一绘本一梦想 2024-10-15 20:45:32

我能想到的唯一方法是将原始变更列表编号添加为变更列表描述字段的一部分。首先,您需要一个脚本来存储原始变更列表编号:

#!/bin/env perl
$id = $ARGV[0];
open (CHANGE_IN, "p4 change -o $id|");
open (CHANGE_OUT, "|p4 change -i $id");
while (<CHANGE_IN>)
{
    if (/^Description:/ and not /ORIGID/)
    {
        s/(^Description:)(.*)$/$1 ORIGID $id. $2/;
    }
    print CHANGE_OUT $_;
}
close (CHANGE_IN);
close (CHANGE_OUT);

在 Perforce 服务器上将其保存为 origid.pl,并设置可执行位。然后使用 p4 触发器 设置触发器。

Triggers:
    add_origid change-submit //depot/... /usr/bin/origid.pl %change%

The only way I can think of is adding the original changelist number as part of the changelist description field. First, you'll need a script to store the original changelist number:

#!/bin/env perl
$id = $ARGV[0];
open (CHANGE_IN, "p4 change -o $id|");
open (CHANGE_OUT, "|p4 change -i $id");
while (<CHANGE_IN>)
{
    if (/^Description:/ and not /ORIGID/)
    {
        s/(^Description:)(.*)$/$1 ORIGID $id. $2/;
    }
    print CHANGE_OUT $_;
}
close (CHANGE_IN);
close (CHANGE_OUT);

Save this as origid.pl on the Perforce server with the executable bit set. Then setup a trigger with p4 triggers.

Triggers:
    add_origid change-submit //depot/... /usr/bin/origid.pl %change%
遇到 2024-10-15 20:45:32

Perforce 2012.1 版本向 p4 describe 引入了 -O(大写 oh)参数,它允许您通过原始编号查询更改列表(在 p4 提交重新编号之前)。

我发现这非常有帮助,因为我经常发现自己在提交变更集之前记录变更集,然后忘记记下提交时它被重新编号的内容。

因此,如果我有一个关于更改 12300 的注释,我现在可以通过输入以下内容来查看它所指的内容:

p4 describe -s -O 12300

并让 Perforce 告诉我:

Change 12345 by me@myhost on 2013/10/31 00:00:00

    Fix that thing I wrote that note about

Affected files ...

    ... //Proj/MAIN/foo.c

前面提到的 ztag 方法可用于查找 更改列表编号已提交更改:

> p4 -ztag describe -s 12345 | grep oldChange
... oldChange 12300

Version 2012.1 of Perforce introduced the -O (capital oh) argument to p4 describe, which allows you to query a changelist by its original number (before being renumbered by p4 submit).

I find this very helpful, since I often find myself keeping notes about a changeset before it is submitted, then forgetting to note what it was renumbered to on submission.

So if I have a note talking about change 12300, I can now see what it refers to by typing:

p4 describe -s -O 12300

and having Perforce tell me:

Change 12345 by me@myhost on 2013/10/31 00:00:00

    Fix that thing I wrote that note about

Affected files ...

    ... //Proj/MAIN/foo.c

The ztag method mentioned earlier can be used to find the old changelist number of a submitted change:

> p4 -ztag describe -s 12345 | grep oldChange
... oldChange 12300
┈┾☆殇 2024-10-15 20:45:32

添加到 Eric Miller 的回复,因为我无法发表评论(没有足够的点):

只发出 1 个数字

p4 -ztag 描述 $ORIG | sed -e 's/^\.\.\. oldChange //;t-ok;d;:-ok'

例如

OLD=$(p4 -ztag 描述 $ORIG | sed -e 's/^\.\.\.oldChange //; t-ok;d;:-ok')

或者如果您想查找许多数字,这将在每行输出一个 new old 的地图(对于“加入”命令)。如果没有旧的提交,那么它会重新发出新的提交。

p4 -ztag 描述 782546 782547 ... | sed -e '${x;p};s/^\.\.\.更改 //;t-keep;b-next;:-keep;x;/./p;g;G;s/\n/ /;x;d;:-next;s/^\.\.\ 。 oldChange //;t-ok;d;:-ok;H;x;s/ .*\n/ / /;x;d;'

我试图避免使用 sed 的 GNU 扩展。

Adding to Eric Miller's reply, because I can't comment (not enough points):

to just emit the 1 number

p4 -ztag describe $ORIG | sed -e 's/^\.\.\. oldChange //;t-ok;d;:-ok'

e.g.

OLD=$(p4 -ztag describe $ORIG | sed -e 's/^\.\.\. oldChange //;t-ok;d;:-ok')

or if you want to look up many numbers, this will output a map of new old on each line (may be useful with the "join" command). If there is no old commit, then it re-emits the new commit.

p4 -ztag describe 782546 782547 ... | sed -e '${x;p};s/^\.\.\. change //;t-keep;b-next;:-keep;x;/./p;g;G;s/\n/ /;x;d;:-next;s/^\.\.\. oldChange //;t-ok;d;:-ok;H;x;s/ .*\n/ /;x;d;'

I tried to avoid using GNU extensions to sed.

好菇凉咱不稀罕他 2024-10-15 20:45:32

除非您按照 Tim 建议的那样执行操作,否则旧的更改列表编号将在提交时丢失。

在您实际提交之前,更改列表编号只是暂时的。因此,如果您创建一个新的更改列表(例如 777),然后决定删除它,则您创建的下一个更改列表将是 778。

Unless you do something like Tim suggests the old change list number will be lost on submission.

Change list numbers are only temporary until you actually submit. So if you create a new change list (777 say) and then decide to delete it, the next change list you create will be 778.

愁杀 2024-10-15 20:45:32

如果您使用 P4 Python 模块,它会更优雅一些。

import P4
p4 = P4.P4()
p4.connect() # having a valid p4 workspace/connection is on you :)

c = p4.run_describe('969696') # describe a Submitted, renumbered changelist, i.e. 969696

old_pending_cl_number = c['oldChange'] # print out prior/pending CL# if this exists.

干杯

It can be a bit more elegant if you use the P4 Python module.

i.e.

import P4
p4 = P4.P4()
p4.connect() # having a valid p4 workspace/connection is on you :)

c = p4.run_describe('969696') # describe a Submitted, renumbered changelist, i.e. 969696

old_pending_cl_number = c['oldChange'] # print out prior/pending CL# if this exists.

Cheers

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