how to list my shelved changes in perforce? - perforce

p4 shelve saved a lot of my effort to edit the same file with different changes.
The problem is after i shelved some changes, I start to forget what I've shelved.
Is there a way to list all the changes I've shelved?
I checked p4 help unshelve/shelve but could not find the option.

This should list all the shelved changes per user.
p4 changes -u <USERNAME> -s shelved

p4 changes -s shelved
My colleague find the answer for me, and I answer my own question here.

In the latest version of p4, you don't have to type out your username:
p4 changes --me -s shelved

Related

Perforce: How to revert all those files that are opened but unedited?

Is there a way to check all the files which are opened in the p4 client and can be reverted if we know that they are not edited.
In P4V, on the pending changelist in question, right-click and choose Revert Unchanged Files.
On the command-line, you can achieve the same with p4 revert -c CHANGELIST -a (you can even add -n to preview the operation). See p4 help revert for more information.

In Perforce, how to unshelve change from one branch to another one?

I have two branches in Perforce, one is branchA another is branchB, in branchA I have a changelist contains several files, now I want to unshelve it to branchB, I use the following steps:
Change perforce config to branchA, shelve the files use "p4 shelve -c changelistA"
Change perforce config to branchB, create a new changelist "changelistB"
In Brunch B, unshelve the changes use "p4 unshelve -s changelistA -c changelistB -b branchB"
But it throws the error "No such file(s)." How to solve this issue?
You have to run the following commands:
p4 unshelve -s change_list_number -b your_destination_branch
p4 resolve ...
The first one bring the changes and the second one resolved any conflict
Yes, a couple of releases ago (2014.1?) the ability to unshelve to another branch was introduced. From the shelved changelist, select Unshelve then select the Map unshelved files option (using Branch Mapping). Of course, this assumes you have a Branch Mapping spec set up.

How to unshelve a shelved changelist to another branch prior to Perforce 2013?

Using Perforce Server 2012.2/538478, how can I unshelve files from the trunk to another branch?
When trying to do it, I get:
//filename... (not mapped to your workspace view)
In Perforce 2013, I found this unshelve command to really be helpful:
p4 unshelve -s <changlist#-with-shelved-files> -S //depot/streamname
But with the version I'm using currently, I found nothing to help me with that issue.
Any suggestions?
The other answers didn't work for me, this is what I did using perforce 2014:
Edit your current workplace so that both //depot/product/B1/... and //depot/product/B2/... are mapped in it (not to each other, to your workspace like normal mappings)
In P4V, go to "Branch Mappings" (View menu->Branch Mappings )
Ctrl+N to start a new mapping (or right click the list and choose "New Branch Mapping..." )
Under "Branch Mapping" provide a name like B1_TO_B2
Replace the mappings under View to be for example
//depot/product/B1/... //depot/product/B2/...
OK
Create an empty Changelist where your unshelved files will be placed (otherwise they will go to "default" changelist). The number of this new changelist will be < TARGET_CL > in the command below.
In the command line, run
p4 unshelve -s <SOURCE_CL> -c <TARGET_CL> -b B1_to_B2
If it doesn't work, make sure the correct workspace is set in .p4config
Now all you have to do is resolve the files in < TARGET_CL >
You're looking at the right command, but possibly not the right parameters. This is how I use it:
p4 unshelve -s 77655 -b MY_BRANCH_SPEC
which unshelves changelist 77655, using the specified branch specification to map the files to the new branch.
Critically, you need to make sure that both the specified branch mapping and your current workspace mapping contain both the source and destination files, otherwise you will get the "file not mapped" error.
Unfortunately, without upgrading to 2013.1 and getting the improved unshelve operation, you're going to need to manually copy the data by:
unshelving in trunk, noting the specific files that have changed
p4 edit the files in your other stream/branch
manually copy the unshelved files to the other stream/branch (you can't use p4 copy or p4 integrate for this because they aren't committed on the trunk
test and commit on the other branch
After spending sometime searching and reading, I have not come across a concrete example for unshelving a shelved changelist to another branch. finally I put together a concrete example.
Assuming you have a shelved changelist 324426 in Branch B1 and want to unshelve it to Branch B2.
I was able to create branch spec, then unshelve changelist to another branch.
here is exactly what I did:
1. Create a text file named branchSpec.txt, with the content below: set you own Branch name and View.
Branch: B1_to_B2
View:
//depot/dev/main/B1/... //depot/release/B2/...
2. p4 branch -i < branchSpec.txt (in target directory)
3. p4 unshelve -s 324426 -b B1_to_B2 (in target directory)
Viola, shelved files in changelist 324426 in B1 now is unshelved to B2 and ready to be submitted.
A way how to get around this is in P4 2012:
Manually copy and overwrite the branch with the trunk
Right click the branch in P4 client and click 'Reconcile Offline Work...'
This will allow you to select the new and changed files and add them to the changeset.
You can use P4 unshelve for this, but you have to create a branch mapping namely A_to_B.
1] p4 unshelve -s CL_NUM -b A_to_B
2] p4 add (files opened for add)
3] p4 resolve
Note: Please do not forget step 2. P4 do not open them by default in your destination branch. You can confirm that with "p4 opened"
This what helped me to unshelve a change list from one branch to another.
Let's say you have a shelved change list #112233 in a source branch: "//depot/release1/main/" that you want to unshelve to a destination branch: "//depot/release2/main/" .
Create a branch spec in a text editor:
nano branch-spec.txt
Branch: R1_to_R2
View:
//depot/release1/main/... //depot/release2/main/...
Create a branch
p4 branch -i < branch-spec.txt
Unshelve Changes
p4 unshelve -s 112233 -b R1_to_R2
Resolve
p4 resolve
I think what you really need is "p4 move -f". It's explained in detail here: p4 move -f: What It's For

Showing a change in a shelved perforce file

If a colleague has a file shelved in perforce, and I'd like to diff the file in the shelved changelist against the source version of that file what is the perforce command needed to do this?
For example if the file a.txt is shelved in changelist 156222 how do I view the changes to a.txt that are in the shelved changelist vs. the current review of a.txt
If you know the revision of the shelved file (e.g. #4) and the head revision (#3 in this case) you can use
p4 diff2 //path/to/depot/file#3 //path/to/depot/file#=<changenumber>
or - even easier - you can use p4 describe (see manual):
p4 describe -S <changenumber>
Find the changenumber with:
p4 changes -u <user> -s shelved
If you are using P4V, you can go to your Pending tab and select the "User" and "Workspace" of your colleague (with the help of the drop-down "Browse..." option).
Then you will see his/her Pending lists, being it composed of shelved files or not. From there, the normal "Diff Against" will work for the "a.txt" file.

How can I grab my local changelist and send it to someone else in Perforce?

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.
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.
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.
http://blog.perforce.com/blog/?p=1872
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.
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.
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

Resources