How can I grab my local changelist and send it to someone else in Perforce? More specifically, I would like to send unsubmitted changes from a local pending changelist to another user's pending changelist.
-
1You'll have to be more specific. It sounds like you're wanting to send unsubmitted changes from a local pending changelist to another user's pending changelist? Is that about right?– ninesidedCommented Dec 17, 2008 at 0:17
-
yes, @ninesided– Won Jun BaeCommented Jan 6, 2018 at 0:02
5 Answers
set P4DIFF=C:\cygwin\bin\diff.exe
p4 diff -du -c 12345 > patch-to-head.diff
# On Other machine
patch -p1 < patch-to-head.diff
I may be wrong on the env var there, and you might have to do some fixups on the diff file, but the general idea is that you generate a GNU Unified Diff, that you can send to people that can use GNU patch to apply it.
-
4At least with server 2008.2 and 2010.1, "p4 diff" doesn't have a -c flag. I still haven't found a way to run "p4 diff" on files in a particular pending changelist. Commented Nov 11, 2010 at 22:49
-
1Yeah, we have a hacked up version of p4 that we use, that's why I was so unsure with the syntax - sorry :( Commented Nov 12, 2010 at 17:27
-
1You probably want both users to sync to the same changelist, but since it only applies your changes it might work anyway.– idbriiCommented Jun 10, 2011 at 18:51
-
1The command in this line doesn't work, as it may have already been stated. Perforce doesn't have the functionality requested in the question but something "close enough" can be retrieved by
p4 diff //path/to/root/...
Unfortunately, getting the patch from a specific changelist (without shelving) isn't possible without specifying every single file in the associated changelist to the p4 diff command. Commented Jun 29, 2017 at 8:17
P4 now has native support for the shelve operation in 2009.2. Both the client and server need to be at least 2009.2 to use this.
To shelve your pending changelist YOURCHANGE:
p4 shelve [-c YOURCHANGE]
The other user then does:
p4 unshelve -s YOURCHANGE [-c THEIRCHANGE]
In either case the "-c" arg can be omitted to use the default changelist instead. In the p4 shelve
case it means a new changelist will be created and the files in your default changelist will be shelved into it; in the p4 unshelve
case it means the shelved files from your changelist will be unshelved into the other user's default changelist.
-
Note that your
shelve
command turnsYOURCHANGE
into a shelved changelist. When the other user unshelves, the-s
flag specifies the shelved change, and the optional-c
flag specifies a local pending changelist (i.e. a change that the other user owns, henceTHEIRCHANGE
) that the shelved files will be copied into.– SamwiseCommented Oct 2, 2020 at 15:11
Not sure exactly what you are trying to do, but you may also want to consider P4_Shelve. It allows you to put a load of pending changes away on a virtual shelf, and then grab them back again later. Depending on what exactly you want to achieve by sending a changelist to someone else, this could provide a part of the answer.
Linked from the P4Shelve site is P4Tar which may also be useful - this does all the packing on the client side so you just get left with a file you can send to someone else.
-
My answer superceded by Tim Danner's one, as Perforce now supports the shelve feature directly. Commented Mar 8, 2011 at 15:00
Perforce 2016, osx. Diff for pending changelist:
mac:src user$ cl=123456 && p4 diff -du $( p4 files @=$cl | sed s/#.*// ) > $cl.diff
output: 123456.diff
Applying patch:
mac:src user$ patch -p0 < 123456.diff