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



Solution 1:[1]

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.

Solution 2:[2]

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.

Solution 3:[3]

If you're for some reason more comfortable using P4V than command line, the solution az2tonez gave can be done with the GUI, at least in P4V 2014.2.

  1. Shelve your changeset, and make sure you have no other files checked out in the workspace.
  2. In the 'Streams' tab, drag the workspace icon from the current stream to the stream you want to move the changes to, and get the latest changes.
  3. Unshelve the files in the 'Pending' tab. Under options select 'Map unshelved files' and select the stream you want to move the changeset from, and press 'Unshelve'.
  4. Resolve files using source.
  5. Submit your changes, and voilá! Your changes should now be in the other stream.

Solution 4:[4]

I believe the shelve/unshelve technique requires the 2013.1 server, not the 2012.2 server. You should confirm this with Perforce Technical Support.

Solution 5:[5]

I know this is an old thread, but I just recently needed to do this exact thing. While these answers were conceptually useful in understanding what needed to be done, unfortunately using only the information in this thread, I couldn't quite get it to work.

I wanted to add the perforce link I found afterwards that filled in some of the missing details that helped me understand exactly what needed to be done, in hopes it might help someone else looking to do this and landing in this thread.

https://p1community.force.com/Community2/s/article/3651

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 emackey
Solution 3 DuneCat
Solution 4 Bryan Pendleton
Solution 5 fnJeff