Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I instruct Perforce to merge instead of overwrite or revert when unshelving a file?

How can I instruct Perforce to merge changes into an existing, open, and modified file in the workspace when unshelving a file shelved in the depot? The only options that Perforce appears to offer the user is to overwrite or revert the existing file in the workspace, but this does not allow, for example, to unshelve and integrate changes to the same file from multiple change lists. Is there a way around this limitation?

like image 270
Derek Mahar Avatar asked Oct 29 '10 18:10

Derek Mahar


People also ask

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.

What does p4 Unshelve do?

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

What does Unshelve mean in perforce?

After shelving a file, you (or another user) can unshelve it, which restores the shelved copy to your workspace and opens it in the changelist of your choice. Unshelving does not remove files from the shelf.

How do I add files to shelved changelist?

Reference: In order to add a file to a pre-existing shelve, the file must first be opened in the shelve's changelist; use p4 reopen to move an opened file from one changelist to another.


1 Answers

What I typically do is right-click on the shelved file and select "Diff Against Workspace File". When you open up the Diff tool, you can select a button in the toolbar to "Edit file in right pane". This essentially starts a two-way merge. With each difference you can select the changes you want from the shelved file (differences are selected from the workspace file by default).

However, it would be nice if Perforce added a type of merge feature to do this more automatically.

Edit to add: Perforce now has a built-in capability to merge files when unshelving. If the user unshelves a file that is also checked out, and "Revert checked out files before unshelving" is unchecked, Perforce will mark that file for resolve. I looked through the release notes and was not able to find in which version this capability was added, but based on this link (see near bottom of p4 unshelve description), it was added no later than 2012.1.

Edited again to add: That feature was added in release 2011.1 of the server. Here's the release note:

#299614 (Bug #38221, #39099) **
    Unshelving a file opened for edit over a file already opened
    for edit in the workspace is now allowed. A resolve record is
    created when unshelving, and the user must then run 'p4 resolve'
    to resolve the workspace files with the shelved files.
like image 160
Chance Avatar answered Oct 11 '22 07:10

Chance