revert: make backup when unforgetting a file (
issue3423)
This skips the backup if it would be a duplicate.
--- 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