Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I revert a range of lines in a file with mercurial?

Tags:

mercurial

I often notice a few unwanted changes when I review my working copy (with hg status and hg diff) right before a commit. For example, I might have temporarily added or remove some code just for the duration of a debugging session.

I know I can use hg revert to remove unwanted changes, but this removes all the changes in the entire file. Is there a way to revert just a part of a file?

like image 211
Wim Coenen Avatar asked Dec 14 '10 16:12

Wim Coenen


1 Answers

I've been doing this with the interactive ncurses style ui hg revert -i that lets you walk around and select the parts you want to destroy, either file, diff chunk or line by line, as you please, depending on how deep you unfold your changes.

I am not sure if this is a standard hg feature or not, you can verify easily enough if yours has it:

> hg revert --help --verbose | grep -- -interactive
 -i --interactive         interactively select the changes (EXPERIMENTAL)

Just remember that the changes you mark (X) will be what gets nuked, not what you retain.

like image 167
ecmanaut Avatar answered Sep 20 '22 19:09

ecmanaut