Possible bug in revert commands -n option

Alexis S. L. Carvalho alexis at cecm.usp.br
Thu Mar 22 20:49:39 CDT 2007


Thus spake Peter Williams:
> With mercurial 0.9.3, this option only seems to work when used in 
> conjunction with the --all option:

Actually it does work:

$ hg init a
$ cd a
$ echo foo > foo
$ hg add foo
$ hg ci -m 'add foo'
$ echo bar >> foo
$ hg diff
diff -r 2f7910f0cd32 foo
--- a/foo	Thu Mar 22 22:39:58 2007 -0300
+++ b/foo	Thu Mar 22 22:40:03 2007 -0300
@@ -1,1 +1,2 @@ foo
 foo
+bar
$ hg revert -n foo  #does nothing. i.e. works fine
$ hg diff
diff -r 2f7910f0cd32 foo
--- a/foo	Thu Mar 22 22:39:58 2007 -0300
+++ b/foo	Thu Mar 22 22:40:03 2007 -0300
@@ -1,1 +1,2 @@ foo
 foo
+bar
$ hg revert foo     #reverts the change to foo
$ hg diff
$

What's probably confusing you is that "hg revert <filename>" doesn't
print anything by default.

> Personally, I would like -n to work without the --all option.  The 
> reason for my preference is that I'm writing a GUI wrapper around hg 
> (and other SCMs) specifically aimed at managing the working directory 
> rather than the repository itself (which is what existing GUI tools 
> provide).  Part of the functionality of the GUI is allowing the user to 
> select files (in a file tree) and then invoke file related hg commands 
> (add, copy, remove, rename, diff, revert) on them.  Where the command is 
> one with likely irreversible consequences I like to pop up a 
> "confirmation" dialog to give the user to change their mind.  The best 
> way for me to tell the user what's about to happen with a "revert" is to 
> get the output from a "-n" run to show them what the result will be.

Try --verbose to get the message.

Maybe we should print the messages by default with --dry-run...  But
that would be inconsistent with the behaviour without --dry-run...

Also note that revert saves the original files with a .orig suffix.

Alexis


More information about the Mercurial-devel mailing list