Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perforce: moving unsubmitted changes to a different stream

Is there a good way in Perforce to move unsubmitted changes to a different stream before submitting them (equivalent of git stash, git checkout otherbranch, git stash pop)?

I currently have the files checked out locally (non-exclusively) and edited. I've tried shelving them and then trying to unshelve them into the target stream, but I get "file(s) not in client view". When I view the changelist (shelved or not), the files all have paths that include the original stream.

My target stream is one I just created, parented off the original stream. I'm using P4V. The version of Perforce Visual Components I have installed is 123.57.9578, and when I run p4 from the command line, it says "Server 2012.2/551823". I can add more info if necessary.

like image 375
entheh Avatar asked Apr 23 '13 10:04

entheh


People also ask

How do you Unshelve a shelved changelist to another branch?

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/" . Branch: R1_to_R2 View: //depot/release1/main/... //depot/release2/main/...

What does Unshelve mean in perforce?

The p4 unshelve command retrieves shelved files from the specified pending changelist, opens them in a pending changelist, and copies them to the invoking user's workspace. Unshelving files from a pending changelist is restricted by the user's permissions on the files.

How do you Unshelve a changelist?

Shelve changesIn the Commit tool window Alt+0 , right-click the files or the changelist you want to put to a shelf and select Shelve changes from the context menu. In the Shelve Changes dialog, review the list of modified files.

Can't Unshelve already opened for add p4?

If you already unshelved previously but has error for those file(s) opened for added only, then you can do just p4 unshelve -s <target-CL> <file1> <file2> to unshelve only those file(s) opened for add only.


2 Answers

You can use the p4 unshelve command to remap the shelved files in a changelist to another stream using the -S option. Ex:

p4 unshelve -s <changlist#-with-shelved-files> -S //depot/streamname

Not sure if this is only available in a certain version or above or not. However, we were unable to find a way to do it through P4V.

like image 73
az2tonez Avatar answered Sep 22 '22 21:09

az2tonez


The other answers here are correct, but they don't warn you that you can't just shelve from any stream and unshelve on any unrelated stream. In particular, the original poster asked about the error message "file(s) not in client view" which is the error message that P4V displays when you haven't selected the proper mapping.

Here's the trick to finding the proper mapping: Your unshelve stream must have a direct parent/child relationship with the shelved stream, and you must select the stream spec that describes that relationship in the "Map unshelved files using stream..." part of the dialog. This means it may take multiple hops to get from the original shelved stream to the target stream.

Here's a concrete example: Let's say you have files shelved into Dev-1 that you want to move to Dev-2. These two Dev streams are both direct children of Main. You can't unshelve Dev-1's files directly into Dev-2, first you have to unshelve and temporarily re-shelve into Main, because the Dev stream specs both describe their relationship in terms of Main and not each other.

So, you unshelve Dev-1's files into Main with "Map unshelved files using stream Dev-1" because that spec describes the relationship being traversed. Then, shelve the files into Main, and then switch your workspace to Dev-2. Now, you can unshelve the Main version of the shelved files, with "Map unshelved files using stream Dev-2", because that spec describes the direct relationship from Main to Dev-2.

With multiple hops, you can get to any other connected stream in your network. This is not as easy as git stash and git stash pop, but remember that Git is assuming the filenames don't change between git branches, whereas Perforce allows each hop to arbitrarily change the mapping of files and folders.

like image 23
emackey Avatar answered Sep 22 '22 21:09

emackey