Is there a way to revert a file line by line in P4
Asked Answered
A

3

6

I want to revert part of changes in a file. I know in p4v you can easily revert files line by line. I am wondering how to do that using p4 command.

Avenge answered 26/6, 2012 at 22:29 Comment(6)
Not that I'm aware of. Your best bet is a diff program. We used replace the built-in diff program with Beyond Compare.Callean
How would I reference the previous version when using a diff program?Avenge
You can use the P4DIFF environment variable to use another diff tool.Nog
@p4-randall Do you have recommendation on any diff tool used in Linux?Avenge
Set P4DIFF to p4merge (p4's own diff tool), or use kdiff3.Hematite
This might help: kb.perforce.com/article/47/third-party-merge-tools (Even though this article talks about 3-way merges, I believe the same setup works for 2-way diffs.)Autoclave
R
13

Yes you can, assuming your using the default p4merge utility, follow this procedure:

  1. Right click on the file in your change-list.
  2. Select 'Diff against Workspace file'. (the workspace file is right panel and original is left)
  3. Select 'Edit' from the main top menu.
  4. Select 'Edit right pane'. (a 3rd pane at the bottom will appear which you can edit)
  5. Now browse your changes ...
  6. ... To remove a change, click the triangle shape on the right side. (shape icon turns blue)
  7. ... To add the change back, click the circle shape on the right side. (shape icon turns green)
  8. Quit the editor and save your changes and your done!

Does that help?

Regret answered 29/11, 2012 at 23:6 Comment(1)
YOU RULE!!!! Diff against Have revision also worked.Faris
P
1

Another option is to force a resolve and then resolve interactively. One way to do this is

  1. Shelve the files you want to partially revert with "revert after they are shelved" checked
  2. Check shelved files back out in the same changelist
  3. Unshelve files with both "Revert checked out files" and "overwrite workspace files" unchecked. Files will be unshelved in unresolved state
  4. Resolve files interactively, allowing you to choose which blocks to keep and which to revert
Peen answered 1/2, 2016 at 20:43 Comment(0)
L
0

It's not possible to revert line by line using p4. See p4 docs

Consider using any of the following ways to diff:

1) Using vim, try vi -d file1 file2 shows you a graphical difference between the two files

2) Besides Kdiff3, Meld is also popular, pretty nifty graphical interface for diff...Meld

3) Emacs has Ediff

4) If you're looking for something light weight...consider xdiff

Layer answered 10/7, 2012 at 7:46 Comment(1)
for option 1), how can I compare the current version of the file with the previous version?Avenge

© 2022 - 2024 — McMap. All rights reserved.