1

How can I instruct perforce command line to merge files instead of overwriting them when unshelving?

The use case is the following: I have a shelf that changes "my_file". On a "clean" (p4 revert ...) owner of the shelf I update to the latest version. I then want to unshelve but the action should merge any potential conflicts instead of overwriting them. Is this possible via command line?

This is the command line version of How can I instruct Perforce to merge instead of overwrite or revert when unshelving a file?.

Community
  • 1
  • 1
Kostas
  • 1,292
  • 1
  • 13
  • 20

1 Answers1

2

If your workspace is "clean", there will be no conflicts. The file will be unshelved at the originally shelved version; if you sync to a different version, that will automatically schedule a resolve.

If your local file is open, unshelving will schedule a resolve automatically (at least with current versions; older versions would refuse to unshelve over open changes).

If your local file is modified but not open, you might get the overwriting behavior you describe. Don't do that. :) Use "p4 reconcile" prior to unshelving to make sure that modified files are properly opened, or "p4 clean" to discard those modifications.

Samwise
  • 68,105
  • 3
  • 30
  • 44
  • The overwriting occurred because of "p4 update". I do not make changes outside of perforce. A file that was being changed in the shelf was also changed by another user's submitted change, that came in with the update. Using "p4 edit" on the file worked, because unshelving did schedule a resolve as you describe. It is sad that unshelving does not have a feature to do this automatically. You have to detect the comflicting fiels yourself... – Kostas Mar 02 '17 at 07:51
  • I'm pretty sure that what you describe is incorrect, but you don't give the exact order in which you ran the commands or what revision was involved in the shelf vs what the other user submitted vs what you synced, so I can't describe what actually happened. :) I'm pretty confident that conflicts are detected and resolves are scheduled automatically as long as you don't mess with the files when they aren't open (and even then Perforce might catch it at various points via checksum comparisons). Feel free to update your question with a description of exactly what you did or are trying to do. – Samwise Mar 02 '17 at 18:27
  • My suspicion is that you're making an incorrect assumption about how unshelve works -- if you sync version #5 and unshelve a revision that's based on #4, Perforce knows that your local file is based on #4 and automatically schedules the resolve when you re-sync #5. Nothing gets overwritten. – Samwise Mar 02 '17 at 21:05