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.
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/...
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With