Fastest way of submitting shelved changelist - perforce

I have shelved a changelist(say X) and I have ensured its correctness. Now i want to submit the changelist. I can
p4 unshelve -s X -c Y where Y is a new changelist i create before executing this command.
Then p4 shelve -c X -d and lastly p4 submit -c Y
Otherwise I can unshelve X, delete the shelve X and move the local copies to changelist X(p4 reopen -c X ) and submit X.
The last option is to unshelve X, delete shelve X, p4 change(and edit description) and finally p4 submit
What are your suggestions with regards to :-
Use 1/3 but copy paste the description that X already had to new changelists
Use 2 but copy each opened file manually in command p4 reopen.
The only advantage of 2 over 1 and 3 is that I don't have to delete X(because it turned out to be my submitted changelist, while in other cases it still is "pending").

The shortest method is:
$ p4 shelve -c #changelist -d
$ p4 submit -c #changelist

In the new 2013.1 release of the Perforce server, you can now do 'p4 submit -e X', which directly submits the shelf without needing to unshelve it first.
Try it, it's a great feature!

From my experience with Perforce, I would just unshelve the change-list, delete the shelved files and submit. Just make sure that the description of the change-list is accurate.

With Perforce 2013.1 or later, you can submit the shelved changelist "12345" directly:
p4 submit -e 12345
On previous versions, use this combination:
p4 unshelve -s 12345
p4 submit ...

Since it is 2018, here is an updated answer for newer perforce versions (2013.1 and newer)
p4 submit -e 123456
This command will fail if you already have that shelvelist open in some tree like so:
Change 123456 has shelved files -- cannot submit
In that case get to the root of that tree (or use -C client_name_where_shelvelist_is_open) and revert the changes before running the above command, like so:
p4 revert -c 123456 ...
p4 submit -e 123456

Related

In perforce, how can I reopen all elements of a CL into the default CL ?

Server version: P4D/LINUX26X86_64/2013.2/938876 (2014/09/23)
Hi:
Let's say I have a pending changelist 123 which has these 2 files...
... //foo/somewhere/abc.txt#100 edit
... //foo/somewherelse/def/txt#67 edit
I want to put both of these in the default CL. I know I can
"p4 reopen -c default //foo/somewhere/abc.txt"
and then
"p4" reopen -c default //foo/somewherelse/def.txt"
But is there a way to specify all the files in CL 123 regardless of the paths (do both reopens with one command)?
My actual situation involves a shelvelist. I want to put the changes in a shelvelist back in the default CL then delete the shelvelist AND the changelist that results after one deletes a shelve. Basically I want to undo the shelve operation. My method of doing this is...
1) delete the shelve
2) p4 describe the changelist
3) p4 reopen -c default each file, one at a time
4) delete the empty changelist
If there's a shortcut to do that, I'm all ears (eyes, whatever) !
But I would still like to learn how to do what I originally asked.
BTW, I do NOT have admin privs :-}
Thanks !
For the specific case of undoing a shelve operation and putting the shelf's contents back into the default changelist you could use p4 revert followed by p4 unshelve.
For the general case, if you just want to reopen everything in the default changelist you could do:
p4 reopen -c default //...
If you have a bunch of changelists and you want to just move the files from change 123 into the default changelist that'd be more like:
p4 -F %depotFile% opened -c 123 | p4 -x - reopen -c default

Get a folder's changelist

If I select from Perforce a folder from my workspace->right-click->Folder History, in the new view that appears, there is a label: Changhelist: 1234. Is there a command line that can retrieve this information(e.g. p4 changelist d:/my_path)?
Yes, it's p4 changes. See: https://www.perforce.com/perforce/r14.2/manuals/cmdref/p4_changes.html
So: p4 changes -m 1 d:/my_path/... will show you the most recent changelist that affected files in d:/my_path/.
p4 changelists is the same as p4 changes, so you were very close with your guess, but there is no p4 changelist, just p4 changelists and p4 changes.
Try p4 help to see all the available commands.

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

How to view Shelved P4 Changes?

One of our team member (located in different region) has shelved changes in P4 with changelist 1234.
Now, if I want to see what files are modified snf what are the changes, how can I do this?
What is the P4 command that I should use to see the changes made by our team member?
p4 describe -S 1234 should to the trick, see the documentation on describe.
To see the file content you would unshelve the files into your workspace (assuming you have a workspace for the same project your colleague is working on).
Create a new (empty) changelist with p4 change (results in e.g. 2345), then use p4 unshelve (docu) to get the modified files to your workspace:
p4 unshelve -s 1234 -c 2345
If you don't want the modified files in your workspace any longer, you can p4 revert -c 2345 them.
Using the GUI, go to Pending and remove all filters except by user, where you will put the other developer's ID. From there you should be able to see her Changelists, including the ones having shelved files. Right click on the Shelved Files icon and select Unshelve. You will have to have a workspace active that includes the files that you are trying to unshelve.
Using UI client, press Ctrl+G. Dialog window is appears. Select Changelist in combobox and input number of changelist.
Let's assume that changelist 123456 is the shelved changelist in question. As a previous answer mentioned, the way to list the files are associated with that changelist is via the p4 describe -s <changelist> command. Like so:
$ p4 describe -s 123456
Change 123456 by john.doe#JohnsBranch on 2013/10/24 15:38:10 *pending*
[Shelving my changes for Jane.]
Fix memory corruption caused by uninitialized pointer.
Affected files ...
... //depot/branches/JohnsBranch/kernel/vm/pageutils.c#1 edit
Once you know the file(s) in question, there are a couple of ways to diff the files without a corresponding workspace. Method #1 is to use p4 print:
$ p4 print -q //depot/branches/JohnsBranch/kernel/vm/pageutils.c#1 > /tmp/old
$ p4 print -q //depot/branches/JohnsBranch/kernel/vm/pageutils.c#=123456 > /tmp/new
$ diff /tmp/old /tmp/new # Or use kdiff3, tkdiff, etc.
...
<diff output here>
The other method is to use p4 diff2:
$ p4 diff2 //depot/branches/JohnsBranch/kernel/vm/pageutils.c#1 //depot/branches/JohnsBranch/kernel/vm/pageutils.c#=123456
...
<diff output here based on Perforce server's diff algorithm>
Both methods can be easily incorporated into the scripting language of choice.
jhwist's solution is good if you want to see the files' diffs.
If you want to see just the shelved files, use p4 describe -sS 1234.
The lower case s restricts the output from including file diffs.
If you wanted to see the actual content of the files, you could use:
p4 print <file>#=<shelved_change>
The #= means to look at the shelved change, where as # means to look at the change.
If you want to see only the list of files inside a ChangeList (whether it's a shelve, pending or submitted CL), without extra data, grep the result:
p4 describe -S 12345 | grep -oP '(?=//).*(?=#)'
In P4V UI, select
Search - > Go To
then choose type of changelist (in your case 'Pending changelist'), enter changelist number and click "OK".
You may try
p4 -ztag describe <changeno>
The description contains a string called '... shelved' if it is shelved.

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