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.
Is there a way to revert a file line by line in P4
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
Yes you can, assuming your using the default p4merge utility, follow this procedure:
- Right click on the file in your change-list.
- Select 'Diff against Workspace file'. (the workspace file is right panel and original is left)
- Select 'Edit' from the main top menu.
- Select 'Edit right pane'. (a 3rd pane at the bottom will appear which you can edit)
- Now browse your changes ...
- ... To remove a change, click the triangle shape on the right side. (shape icon turns blue)
- ... To add the change back, click the circle shape on the right side. (shape icon turns green)
- Quit the editor and save your changes and your done!
Does that help?
YOU RULE!!!! Diff against Have revision also worked. –
Faris
Another option is to force a resolve and then resolve interactively. One way to do this is
- Shelve the files you want to partially revert with "revert after they are shelved" checked
- Check shelved files back out in the same changelist
- Unshelve files with both "Revert checked out files" and "overwrite workspace files" unchecked. Files will be unshelved in unresolved state
- Resolve files interactively, allowing you to choose which blocks to keep and which to revert
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
for option 1), how can I compare the current version of the file with the previous version? –
Avenge
© 2022 - 2024 — McMap. All rights reserved.