[p4] Undoing the effects of "p4 move"

P4Sam perforce-user-forum at forums.perforce.com
Fri Aug 5 19:25:01 PDT 2016

Posted on behalf of forum user 'P4Sam'.

The idea behind "p4 move" counting as an edit (indeed, you can only
"p4 move" a file that's first been opened for edit) is that you
want to version the location of the file (within a relative namespace) as well
as its content.

So if you do:

//components/A/bar/foo.c ---branch---> //libraries/ace/A/bar/foo.c  
and then:

//libraries/ace/A/bar/foo.c ---move---> //libraries/ace/A/ola/foo.c  
and then you do:

//libraries/ace/A/... ----integrate---> //components/A/...  
then you should end up with:

//components/A/bar/foo.c ---move---> //components/A/ola/foo.c  
Because the move is getting mirrored in the target branch (as opposed to being
branched directly from the source branch, like if you'd used
"integrate"/"delete" to move the file), if changes were made
to //components/A/bar/foo.c in the meantime, those changes automatically get
included in the new //components/A/ola/foo.c, and they're merged with other
changes if necessary.

Even if you didn't make any changes to the content of foo.c itself, changing
its location counts as an edit; hence a move action is never considered a
"null change" the way that a branch action is (which is why it's
"move/add" and not "move/branch").

I'm guessing that in this case you were using "move" to change the
location of the branch (e.g. you were moving //libraries/ace/A to
//libraries/talkhouse/A, which is a change that does not have any significance
within the //components/A branch) rather than the location of the files within
the branch, and then adjusting the branch mapping to match, so that from the
perspective of the target branch nothing has moved at all.  In this
case you don't really have anything to propagate back to the parent branch,
but just as if you'd done "p4 edit" and then submitted the new
revision without any changes, it still shows up as something new to integrate.

So, for the future, the general rule is that if you're moving an entire
branch (and you don't want to integrate that change itself to other
branches), you should use "integrate" to make that change, while if
you're moving something within a branch (and you do want to integrate that
change to other branches and have everything merge nicely), you should use
"move" to make that change.

For the immediate issue, I do think your option 2 is the way to
go.  I'd do something along these lines:

First, integrate back to the home location, discarding unchanged files:  p4
integrate //libraries/talkhouse/A/... //components/A/... p4 resolve -as p4 diff
-sr | p4 -x - revert p4 submit  
Alternatively, if you don't actually want to integrate outstanding changes
and instead cancel this process, the presence of opened files after the revert
would be the clue that not everything is synced up.

Now that the home location is fully up to date, do the force integrate:  p4
integrate -f //components/A/... //libraries/talkhouse/A/... p4 resolve -at p4

Please click here to see the post in its original format:

More information about the perforce-user mailing list