changeset 19510:8b190adb7ee3 stable

revert: make backup when unforgetting a file (issue3423) This skips the backup if it would be a duplicate.
author Matt Mackall <mpm@selenic.com>
date Fri, 26 Jul 2013 17:08:05 -0500
parents 8963a706e075
children ca2dfc2f63eb
files mercurial/cmdutil.py tests/test-issue660.t
diffstat 2 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Fri Jul 26 15:42:10 2013 -0500
+++ b/mercurial/cmdutil.py	Fri Jul 26 17:08:05 2013 -0500
@@ -1976,7 +1976,7 @@
             #   make backup if not in target manifest
             (modified, revert, remove, True, True),
             (added, revert, remove, True, False),
-            (removed, undelete, None, False, False),
+            (removed, undelete, None, True, False),
             (deleted, revert, remove, False, False),
             )
 
@@ -1986,7 +1986,8 @@
             def handle(xlist, dobackup):
                 xlist[0].append(abs)
                 if (dobackup and not opts.get('no_backup') and
-                    os.path.lexists(target)):
+                    os.path.lexists(target) and
+                    repo[None][abs].cmp(ctx[abs])):
                     bakname = "%s.orig" % rel
                     ui.note(_('saving current version of %s as %s\n') %
                             (rel, bakname))
--- a/tests/test-issue660.t	Fri Jul 26 15:42:10 2013 -0500
+++ b/tests/test-issue660.t	Fri Jul 26 17:08:05 2013 -0500
@@ -73,6 +73,15 @@
 
   $ hg st
 
+Issue3423:
+
+  $ hg forget a
+  $ echo zed > a
+  $ hg revert a
+  $ hg st
+  ? a.orig
+  $ rm a.orig
+
 addremove:
 
   $ rm -r a b