Question

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?

Was it helpful?

Solution 3

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

OTHER TIPS

The other answers didn't work for me, this is what I did using perforce 2014:

  1. 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)
  2. In P4V, go to "Branch Mappings" (View menu->Branch Mappings )
  3. Ctrl+N to start a new mapping (or right click the list and choose "New Branch Mapping..." )
  4. Under "Branch Mapping" provide a name like B1_TO_B2
  5. Replace the mappings under View to be for example

    //depot/product/B1/...       //depot/product/B2/...  
    
  6. OK
  7. 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.
  8. 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
  9. 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.

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:

  1. Manually copy and overwrite the branch with the trunk
  2. 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/" .

  1. Create a branch spec in a text editor:

nano branch-spec.txt

Branch: R1_to_R2
View:
   //depot/release1/main/... //depot/release2/main/...
 
  1. Create a branch p4 branch -i < branch-spec.txt

  2. Unshelve Changes p4 unshelve -s 112233 -b R1_to_R2

  3. 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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top