P4V:使用分支映射自动集成变​​更逐个变更列表

发布于 2024-12-06 08:11:43 字数 417 浏览 1 评论 0原文

我正在尝试使用 Perforce 自动化从我们的开发分支到主分支的集成。我设置了分支映射,并且我知道我可以自动集成整个分支的更改。我想知道是否有一种方法可以跨分支集成,但按顺序一次执行一个更改列表?

例如,今天我们有 3 名开发人员向我们的 dev 分支提交更改,更改列表编号为 1、2 和 3。有没有办法执行 p4 集成 -b 分支名称,但让它对每个更改进行单独集成,从与 1?这样,如果出现问题,我可以退出某些变更列表吗?或者,更好的是,如果我可以告诉它仅集成需要集成的最早的变更列表,那么我可以集成变更列表 1,对构建进行冒烟测试,然后集成变更列表 2 等。

我的一位同事提到使用 Jobs,但是据我了解,工作只允许我自动化有关错误等的信息,但不允许我实际自动运行集成。

抱歉,如果答案很明显,我对 Perforce 还比较陌生。我在网上查了一下,但找不到任何东西。

Using Perforce, I am trying to automate the integration from our dev branch to our main branch. I have branch mapping set up, and I know I can integrate changes automatically for the entire branch. I was wondering if there is a way to integrate accross the branch but doing it one changelist at a time, in sequential order?

For example, today we have 3 developers submit changes to our dev branch, with Changelist #'s 1, 2, and 3. Is there a way to do a p4 integrate -b branchname but have it do seperate integrates for each changelis, starting with 1? That way, if there is a problem, I can back out of just certain changelists? Or, even better, if I can tell it to integrate only the EARLIEST changelist that needs to be integrated, so I could integrate changelist 1, smoke test the build, then integrate changelist 2, etc.

One of my coworkers mentioned using Jobs, but as far as I understand jobs will only allow me to autmate information about bugs and such, but won't allow me to actually run integrations autmatically.

Sorry if the answer is obvious, I am still relatively new to Perforce. I looked around online but could not find anything.

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

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

发布评论

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

评论(3

三生殊途 2024-12-13 08:11:43

如果您想逐个集成变更列表,最好的选择是使用“p4 interchanges”命令(我认为仅在命令行上可用)。您可以使用交换命令来找出需要从源集成到目标的更改列表(请参阅命令行用法以了解如何执行此操作的各种方法)。

最好的选择是将此命令包装在某个脚本中(通过 python、perl 或其他脚本),然后调用交换命令,然后对于交换返回的每个更改列表,您可以运行集成,运行冒烟测试,然后重复。

请注意,交换命令仍然不受支持(截至版本 2010.2)。根据您的使用情况、分支的复杂性和项目的规模,您的使用情况可能会有所不同,但对于我们的(大型)项目来说,它的效果非常好。

希望这有帮助。

If you want to integrate changelist by changelist, your best bet is to use the 'p4 interchanges' command (only available on the command line I think). You can use the interchanges command to find out what changelists need to be integrates from source to target (see the command line usage for the various methods of how you could do this).

Your best bet is to wrap this command up in some script (via python, perl, or whatever), and call the interchanges command and then for every changelist that interchanges returns, you can run the integrate, run your smoke test, and then repeat.

Note that the interchanges command is still unsupported (as of version 2010.2). Depending on your usage, complexity of branches, and size of projects, your mileage on usage may vary, but for our (large) projects, it's worked very well.

Hope this helps.

绝情姑娘 2024-12-13 08:11:43

2011.1 版本将正式支持“p4 交换”。

正如第一个答案所示,您可以使用“交换”来获取更改列表的列表
需要合并的。然后您可以单独整合并解决每个问题,然后提交
最后一次全部完成。

'p4 interchanges' will be officially supported with the 2011.1 release.

As the first answer indicated, you can use 'interchanges' to get a list of changelists
that need to be merged. Then you can integrate and resolve each one individually, and submit
all at once at the end.

献世佛 2024-12-13 08:11:43

这是一个 perl 脚本,它可以帮助您将变更列表从一个分支集成到另一个分支,只需更新下面的分支规范即可。将变更列表作为参数逐一传递。这将满足您的需要。

#!/usr/local/bin/perl
my $chnum=$ARGV[0];
die("\nIntegration aborted to avoid including currently open files in the default change!\n") 
    if system ("p4 opened 2>&1 | findstr /c:\"default change\" > NUL: 2>&1") == 0 ;
print "integrating change $chnum\n";
open(FIL,"p4 change -o $chnum|");
while (<FIL>) {
$originator = $1 if /^User:\s*(\w*)/;
last if /^Description:/;
}
$originator = ' by ' . $originator if $originator;
while (<FIL>) {
$description .= $_;
}
print "Description:\n$description\n";
close(FIL);
system ("p4 integ -b <BranchSpec> \@$chnum,\@$chnum");
system ("p4 resolve -as");
system ("p4 resolve -am");
system ("p4 resolve");
open (FIL1,"p4 change -o|");
open (FIL2,"|p4 change -i");
while (<FIL1>) {
if (/<enter description here>/) {
    print FIL2 "    Integration: Change $chnum$originator <From Branch> to <To Branch>:\n";
    print FIL2 $description;
} else {
    print FIL2 $_;
}
}
close (FIL1);
close (FIL2);
print "Finished integrating change $chnum\n";

Here is a perl script, which helps you integrating the changelist from one branch to other, just update the branch spec below. Pass the changelist one after other as an argument. This would do what you need.

#!/usr/local/bin/perl
my $chnum=$ARGV[0];
die("\nIntegration aborted to avoid including currently open files in the default change!\n") 
    if system ("p4 opened 2>&1 | findstr /c:\"default change\" > NUL: 2>&1") == 0 ;
print "integrating change $chnum\n";
open(FIL,"p4 change -o $chnum|");
while (<FIL>) {
$originator = $1 if /^User:\s*(\w*)/;
last if /^Description:/;
}
$originator = ' by ' . $originator if $originator;
while (<FIL>) {
$description .= $_;
}
print "Description:\n$description\n";
close(FIL);
system ("p4 integ -b <BranchSpec> \@$chnum,\@$chnum");
system ("p4 resolve -as");
system ("p4 resolve -am");
system ("p4 resolve");
open (FIL1,"p4 change -o|");
open (FIL2,"|p4 change -i");
while (<FIL1>) {
if (/<enter description here>/) {
    print FIL2 "    Integration: Change $chnum$originator <From Branch> to <To Branch>:\n";
    print FIL2 $description;
} else {
    print FIL2 $_;
}
}
close (FIL1);
close (FIL2);
print "Finished integrating change $chnum\n";
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文