Git cherry pick equivalent in Perforce?
Asked Answered
U

2

8

My team uses perforce for version control. There have been a lot of additions in the branch that I am currently working on, as compared to the Release branch.
Now, I just fixed a known bug in the released product, and checked in the code change in the branch that I was working on. Is it possible to check in/merge the same change ONLY, with the release branch?

Alternatively, I am just looking to check-in this bug fix in to the release branch, and not any other code changes. From what I searched online, I figured out that git equivalent for this is - git cherry pick. Is there a way to do this in Perforce?

Unsaid answered 7/5, 2013 at 11:18 Comment(0)
D
9

Yes, it is possible. However, for some reason the official perforce instructions have been moved or removed. Could it be that there are other better alternatives. I dont know. It was now many years since I last used P4 so this is not based on personal experience, rather the suggestion below is what the offical perforce answer forum suggested once upon a time

echo Change A > foo
p4 add foo
p4 submit -d "Add foo" foo

p4 integ foo bar
p4 submit -d "Branch foo" bar

p4 edit foo
echo Change B >> foo
p4 submit -d "Update foo" foo

p4 edit foo
echo Change C >> foo
p4 submit -d "Update foo again" foo

p4 integ foo#3,#3 bar
p4 resolve -o

The link below is kept if someone wants to try and find the original page using archive.org or similar service.

Official Perforce cherry picking instructions.

Drake answered 7/5, 2013 at 11:22 Comment(7)
JugseR is correct, but keep in mind that Perforce does cherry-picking via merges. You can end up with complicated merge history if you cherry pick often.Prothonotary
Git is way better in this sense, as randy has mentioned dealing with merging of multiple results in complicated merge history as opposed to Git where it is merged based on commits. Wish Perforce worked like this or wish my company would migrate to git!Syreetasyria
Link-only answer (no content) and now the link is broken. The answer became borderline useless...Conveyancing
Thank you, updated accordingly. Not sure of the relevance these days.Drake
Again, the link is broken.Callus
Yes, as many have noted the link is broken. The meaning of the sentence above the link tries to convey that information and also suggest a way forward if you really want to see the original page. If the information that was contained in that page is enough, the answer still stands. Also, Philips answer, while not the original page, also has a solution if I am not mistaken.Drake
Here's a new link, but the process seems pretty complicated: portal.perforce.com/s/article/3385Hapten
D
0

I also did a cherry-picking like this and re-read the mentioned knowledgebase article several times.

enter image description here

Staying at this example, I did p4 integrate of some changelists 110 and 112 containing the file changes foo#1 and foo#3. I also did a resolve -am afterwards and submitted. Later doing a p4 integrate //depot/code/cherry/foo //depot/code/cherry/bar it does not add the changes of foo#2. Curiously when doing an explicit integration of foo#2, I get the change.

It feels like the resolve -am make the new merged #2 being the most recent change and dropping any further integration of older not-yet-integrated changes. I thought integrate and resolve are working line-based. That line tat I missed from foo#2 was not touched by #1 and #3 so should still be remember as not-yet-integrated. What I'm doing wrong here?

Dodgem answered 14/3 at 12:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.