I have a workspace synced to a changelist A.
I need to test version A with a changelist D, that was committed a few commits after A to the same branch. Cherry-pick it, so to speak.
How can I do it, other than p4 diff -du and applying a patch?
I have a workspace synced to a changelist A.
I need to test version A with a changelist D, that was committed a few commits after A to the same branch. Cherry-pick it, so to speak.
How can I do it, other than p4 diff -du and applying a patch?
If you're content with just getting the files in D (at their @D revision) while leaving everything else synced to A, this is simply:
p4 sync @D,@D
But if some of the files in D were also affected by changes B and C, this might not be acceptable, since the D revisions will also contain those changes. For a true cherry-pick, you have to open the files so you can do a set of resolves that ignore B and C before cherry-picking D. My approach to this would be:
p4 -F "%depotFile%" files @D,@D | p4 -x - edit
p4 -F "%depotFile%@<D" files @D,@D | p4 -x - sync
p4 resolve -ay
p4 sync @D,@D
p4 resolve -am
If there are merge conflicts you'll need to follow this up with an interactive p4 resolve.
Note that if you actually submit these files, you'll be rolling back B and C (at least within those specific files).
If B and C didn't affect the files in D (i.e. the files returned by p4 files @D,@D), then steps 2 and 3 will be no-ops -- the sync to @<D will just leave the files at their currently synced revisions (@A), and there will be nothing to resolve/ignore. The resolve at step 5 will then do an automatic "accept theirs" (i.e. "copy from" D) since there's no "ignored" base revision in between A and D.
Another possible option would be to do this in a new branch (which you don't necessarily need to submit at any point):
p4 integ original_branch/...@A cherry_pick/...
p4 integ original_branch/...@D,@D cherry_pick/...
p4 resolve -am
The main downside of this is that it'll entail syncing new copies of all the files when you open them for branch, but if the files aren't large/numerous enough for that to be a concern, the ergonomics of p4 integ lend themselves a bit better to this sort of thing, and it can be convenient to do things like this in a separate branch within your workspace so you can mess around freely without interfering with any other work in progress, and then discard the whole thing with a revert when you're done.