nothrow
nothrow

Reputation: 16168

Perforce - how to back-out changelist from master branch

I have following changelists in perforce:

1 - some work on //depot/A/file
2 - some work on //depot/A/file
3 - branching of //depot/A to //depot/B
4 .... - some work on //depot/A/file

And I want to backout changelist 2 on //depot/B.

I've tried following:

p4 sync //depot/B/file@1
p4 edit //depot/B/file
p4 sync //depot/B/file@2
....

but error occured on first line.

//depot/B/file@1 - no file(s) at that changelist number.

Is there any way how to achieve this without submitting into //depot/A branch?

Upvotes: 1

Views: 780

Answers (3)

Samwise
Samwise

Reputation: 71424

Here's what I'd do:

p4 copy //depot/A/...@1 //depot/B/...
p4 submit
p4 merge //depot/A/...@2 //depot/B/...
p4 resolve -ay
p4 submit
p4 merge //depot/A/... //depot/B/...
p4 resolve -am
p4 resolve
p4 submit

You could potentially do this all within a single changelist as well, but it gets a little trickier then -- the above keeps it simple and leaves a history that is easy to follow (i.e. each revision is clearly "copied from this change," "ignored this change", or "merged these changes" rather than a single revision that mushes those actions all together).

Upvotes: 3

tkosinski
tkosinski

Reputation: 1696

Based on your attempt to sync to //depot/B/file@1, I'm assuming the file did not previously exist on //depot/B/...?

If my assumption is correct, you'll want to delete the file:

p4 delete //depot/B/file

and submit it.

If my assumption is incorrect and your newly-branched file is @2 or higher, then:

p4 edit //depot/B/file@1
p4 resolve -ay //depot/B/file
p4 submit 

Upvotes: 0

sferencik
sferencik

Reputation: 3249

You can't simply take out 2 from B because it came together from A as one change (1 & 2).

I think the only way to achieve this is:

  1. roll back 3 on B (p4 edit //depot/B/file; p4 sync //depot/B/file#0; p4 submit //depot/B/file or p4 delete //depot/B/file; p4 submit //depot/B/file)
  2. integrate 1 from A to B
  3. integrate 4 from A to B

Having said that, this has two drawbacks:

  1. if you ever want to re-integrate 2 from A to B in the future, P4 will be confused because it knows that it already has integrated 2 from A to B
  2. if you want to integrate back from B to A, this will propagate the reversal of 2 on B back to A, which probably isn't what you want.

So, even though it's more elaborate, the only correct way to revert an integration is exactly what you don't want to do:

  1. roll back 2 on A
  2. integrate A to B
  3. re-submit 2 on A

Upvotes: 0

Related Questions