Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

'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.

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";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top