Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

perforce: create a local backup of current pendinglist

Tags:

perforce

in perforce, i have a pending list with some changed files. now i want to revert to the base, but without loosing my changes, so i want to back them up somewhere. like saving the DIFFs of each file. at a later time, i want to restore those changes and continue my work.

is this possible? if so, how?

thanks!

like image 831
clamp Avatar asked Nov 12 '09 13:11

clamp


5 Answers

there is no need for external tools at all, assuming you are on a unix machine (or have a proper cygwin setup under Windows, haven't tested it.) The only caveat is that Perforce's p4 diff produces an output that is slightly incompatible with patch, therefore you need it to point to your unix diff-command. In your client-root you can do

P4DIFF=/usr/bin/diff p4 diff -du > pending-changes.patch

optional (if you want to revert the open files from the command-line, otherwise use p4v):

p4 revert `p4 opened|awk -F\# '{print $1}'`

Later you would open the files for edit (can be automated by extracting the affected files from the patchfile pending-changes.patch and then:

patch < pending-patches

Depending on your path-layout in your client-root, you have to use the -p#num option of patch to get the patch applied cleanly.

like image 67
jhwist Avatar answered Nov 04 '22 12:11

jhwist


You should be able to do a shelve. It's a way of saving a changelist for future editing. The link below is a Python add-in for Perforce that implements shelve. Also, I know that Practical Perforce has a couple of ways to shelve current changes without an external script. I don't have the book in front of me but I'll try to update this question tonight when I do.

http://public.perforce.com/wiki/P4_Shelve

like image 38
Brett Bim Avatar answered Nov 04 '22 11:11

Brett Bim


Linked to from P4Shelve, is P4tar which looks very useful, and does the operations on the client, rather than branching on the server.

Certainly I'll be looking into doing similar things soon.

like image 5
Douglas Leeder Avatar answered Nov 04 '22 10:11

Douglas Leeder


See also this question:

Sending my changelist to someone else without checking in.

It's basically the same thing.

like image 2
Greg Whitfield Avatar answered Nov 04 '22 11:11

Greg Whitfield


  • Create a branch of these files in some appropriate location
  • Check out the branch versions of the files you have edited
  • Copy the edited files over from the trunk and submit them
  • Revert the files on the trunk

Now you've got those "diffs" you wanted safely archived. When your ready to apply those changes later on, just integrate them back into the trunk.

This is what the Python script, that Brett mentioned, does. This is the way to do it manually without any special tools.

like image 1
raven Avatar answered Nov 04 '22 12:11

raven