11

How do you branch from a specific changelist in perforce? That is, if main is my main codeline, and I want to create a branch b off of main from a changelist n, what is the syntax to do this?

I've tried:
//depot/main/...@n //users/me/sandbox/...
in my branch spec, but get errors.

And
p4 integrate -b branch_b @n
doesn't seem to work either.

Thanks in advance.
-David

DSaracino
  • 241
  • 2
  • 6

2 Answers2

11

Based on the highly scientific method of attempting the same action in p4v and then copying and pasting out of the log, the following snippet should do what you need, provided you have your branch specification branch_b defined correctly:

p4 integrate -o -b branch_b -s //depot/main/...@n
ninesided
  • 23,085
  • 14
  • 83
  • 107
  • 5
    I realize your "highly scientific" was intended to be tongue-in-cheek, but actually I think it's a great way to learn about Perforce command line techniques for particular situations. I use that same "scientific" method myself, routinely. – Bryan Pendleton Sep 25 '10 at 20:38
  • What does the -o argument do? It doesn't appear to be documented in `p4 help integ`. – Daryl Spitzer Oct 02 '18 at 20:09
  • This command isn't limiting the files integrated to just those in the indicated changelist number. – Daryl Spitzer Oct 02 '18 at 20:11
  • `p4 integrate -b branch_b -s //depot/main/...@=n` works. (I added the `=`.) – Daryl Spitzer Oct 02 '18 at 20:22
1

The problem with the original command is that the changelist has to be specified as a range. It's an odd quirk but there it is. The correct command is:

p4 integ //depot/main/...@1,@n //users/me/sandbox/...

  • Nice, I also recommend to use a separate change list: p4 integ -c NUMBER //depot/main/...@1,@n //users/me/sandbox/... otherwise all will land in the default CL. – TomSmartBishop Jul 28 '15 at 03:12