Colonel Panic
Colonel Panic

Reputation: 137752

How to revert file but leave it in pending changelist?

In Perforce P4V I have a file in a pending changelist. I want to revert the contents of the file but keep the file in the changelist. How can I do that?

I tried Perforce's revert command but that removes the file from the changelist.

Upvotes: 8

Views: 4426

Answers (4)

stopBugs
stopBugs

Reputation: 351

Using the command line, it can be done in three stages. If you are using windows I highly recommend having a unix environment, e.g. cygwin (which is the one I used.)

Assume your changelist number is XYZ and you have shelved the files in their current revision (just for the sake of it!)

Step 1: get a list of files and put them in a temp file.

p4 describe XYZ | grep \/\/ | sed -e 's/\.\.\. //'| sed 's/#.*//'  > temp

Step 2: revert all the files in the changelist

p4 revert -c XYZ //...

Step 3: check out / edit the files again

cat temp | xargs p4 edit -c XYZ

I assumed all the files are in edit mode (i.e. not an already opened file or a deleted file).

PS : delete temp, if you are fussy :)

Upvotes: 3

the_cat_lady
the_cat_lady

Reputation: 951

This is not readily possible, as other respondents noted.

If you are okay with a multi-step solution, you could

  1. Right-click the file in the changelist and choose "diff against have revision".
  2. In the diff window, under "Edit" choose "Edit right/left pane" (whichever side yours is on).
  3. Copy the contents of the original and paste them over your edited workspace version
  4. Save the file.

Your file now has no changes, and it is checked out in the same changelist.

Upvotes: 4

Mark
Mark

Reputation: 3700

The only way to accomplish this (short of copy/pasting the original contents back into this file, but that seems silly) is to revert and reopen it. Shelving, by itself, does not revert the file. The concept of "shelve and revert" is still two operations.

Upvotes: 5

gaige
gaige

Reputation: 17491

I don't believe this can be done, even from the command line, since p4 sync (even with -f) explicitly excludes operations on open files.

Upvotes: 1

Related Questions