Karlovsky120
Karlovsky120

Reputation: 6352

Initializing a perforce stream from another stream without copying files

In git, when you run git checkout -b <name> while on branch A, assuming you had no pending changes, a new branch will be created and your workspace will switch to it. No files will be modified or copied, new branch will match branch A exactly.

I want to do the same with P4. I have a stream trunk which has about 2.5TB of data in it, currently sitting on changelist 584 as the latest changelist. I want to create a new stream called zero-four where its initial state will look exactly the same as the state of the trunk at changelist 584. Basically P4 checkout -b zero-four.

The official way to do it is to create a new empty stream, COPY all the data you want in the initial changelist and submit it. You can see how that could be a pain when the branch you're working with has 2.5TB of data.

The way I currently plan to do it is to simply MOVE trunk into zero-four, submit zero-four, and then just move it back. I don't need to switch to zero-four, in this case, I actually don't want to.

Is there a saner way to do this? A command that will initialize a stream based on a state of another stream?

Upvotes: 0

Views: 365

Answers (2)

Samwise
Samwise

Reputation: 71424

If you're using a "personal server" (a server created by p4 init) you can use a git-style workflow to create a new stream:

p4 switch -c <name>

Behind the scenes this does the equivalent of p4 stream and p4 populate before switching you to the new stream. Since the new stream is identical to the stream you started in, the p4 switch doesn't re-transfer the files in the process of "syncing" you to the new stream.

If you're on a shared server, switch -c is disabled (because stream creation has overhead that most admins prefer to put a little friction in the way of by not making it a one-click command). You can still do the equivalent commands though:

p4 stream -t development -P branchA <name>
p4 populate -r -S <name>
p4 switch <name>

See also p4 copy -v and p4 integ -v, which will open the files for branch (rather than instantly committing them like populate does) but without syncing them to your workspace.

Upvotes: 1

Jase
Jase

Reputation: 361

I think the command you are looking for is p4 populate

In this case, you would create the stream and then you would run p4 populate to replicate all the files into the new stream, without needing to sync them locally and copy. If you are doing this in P4V, you can just check the box at the bottom of the stream creation dialog that says "Branch files from parent on stream creation"

Hope that helps!

Upvotes: 0

Related Questions