Jump to content


Best way to revert an opened change without reverting changes in workspace?

revert

  • Please log in to reply
4 replies to this topic

#1 mcru

mcru

    Advanced Member

  • Members
  • PipPipPip
  • 50 posts

Posted 07 August 2017 - 10:43 PM

What is the best way to revert an opened change without reverting changes in the workspace?

Example...

I modify two files, fileA.txt and fileB.txt. I run p4 rec and both files are opened for edit. Now, I decide that I only want to commit changes to fileB.txt, but I don't want to run p4 revert on fileA.txt because I don't want to lose my changes on it. How do I revert fileA.txt to remove it from my list of open files without losing my local changes?

In this simple example I know you could just p4 submit and pass the file name, or modify the changelist specification, but imagine you had a good number of files opened. How would you do this?

Thanks!

#2 Marc Lewert

Marc Lewert

    Member

  • Members
  • PipPip
  • 14 posts

Posted 07 August 2017 - 11:05 PM

Take a look at the "-k" option in p4 revert.

That is likely to do what you need.

     marc

On 08/07/2017 03:45 PM, mcru wrote:

Quote

Posted on behalf of forum user 'mcru'.

What is the best way to revert an opened change without reverting
changes in the
workspace?

Example...

I modify two files, fileA.txt and fileB.txt. I run p4 rec and both
files are
opened for edit. Now, I decide that I only want to commit changes to
fileB.txt,
but I don't want to run p4 revert on fileA.txt because I don't want to
lose my changes on it. How do I revert fileA.txt to remove it from my
list of
open files without losing my local changes?

In this simple example I know you could just p4 submit and pass the
file name,
or modify the changelist specification, but imagine you had a good
number of
files opened. How would you do this?

Thanks!



--
Please click here to see the post in its original format:
http://forums.perfor...es-in-workspace

_______________________________________________
perforce-user mailing list  -  perforce-user@perforce.com
http://maillist.perf...o/perforce-user

--
Marc Lewert                         Going Postal: TiVo Inc.
Senior Software Production Engineer               2160 Gold St.
Email: marc.lewert at tivo.com                    San Jose, CA 95002
Phone: 408-519-9486                               Main Phone: 408-519-9100


________________________________

This email and any attachments may contain confidential and privileged material for the sole use of the intended recipient. Any review, copying, or distribution of this email (or any attachments) by others is prohibited. If you are not the intended recipient, please contact the sender immediately and permanently delete this email and any attachments. No employee or agent of TiVo Inc. is authorized to conclude any binding agreement on behalf of TiVo Inc. by email. Binding agreements with TiVo Inc. may only be made by a signed written agreement.
_______________________________________________
perforce-user mailing list  -  perforce-user@perforce.com
http://maillist.perf...o/perforce-user



#3 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 344 posts

Posted 08 August 2017 - 07:56 PM

View Postmcru, on 07 August 2017 - 10:43 PM, said:

What is the best way to revert an opened change without reverting changes in the workspace?

Example...

I modify two files, fileA.txt and fileB.txt. I run p4 rec and both files are opened for edit. Now, I decide that I only want to commit changes to fileB.txt, but I don't want to run p4 revert on fileA.txt because I don't want to lose my changes on it. How do I revert fileA.txt to remove it from my list of open files without losing my local changes?

In this simple example I know you could just p4 submit and pass the file name, or modify the changelist specification, but imagine you had a good number of files opened. How would you do this?

It doesn't sound like you want to revert the change; if you use 'revert -k' the change becomes untracked and it's at risk of being overwritten. Instead I think you want to move it to a new changelist.

p4 change
p4 reopen -c CHANGE fileB.txt

The "p4 reopen" command accepts a wildcard expression so if instead of a single file fileB.txt you have a lot of files that all match some pattern (e.g. everything in a particular directory, or with a particular extension) it's still just one command to do this.

You can do this as many times as you like with as many different changelists as you like, and you can freely move files between pending changelists.  The whole idea behind being able to create new pending changelists is that you can divide pending work into different atomic units and submit each changelist independently.

#4 mcru

mcru

    Advanced Member

  • Members
  • PipPipPip
  • 50 posts

Posted 09 August 2017 - 06:33 PM

Cool, thanks for the info. Both of these options are valid.

Adding changed files to p4 change seems like a good option, but I can't modify the files after adding them to the changelist. Do I need to revert the files or something else to get the files back to their original state? I'm thinking of something like git's 'stash' functionality here...

#5 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 344 posts

Posted 09 August 2017 - 11:47 PM

What do you mean "can't modify the files after adding them to the changelist"?  They should still be open and writable in your workspace as long as you haven't either submitted or reverted.

You can revert the files to get them back to the state they were in before you modified them, but then you lose your changes, which it sounded like you explicitly didn't want...?

"p4 shelve" is how you take a pending change and stash it on the server; once you've shelved a change you can revert your local files and the shelved revisions persist on the server (you can get them back into your workspace with "p4 unshelve").





Also tagged with one or more of these keywords: revert

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users