# HG changeset patch # User Laurent Charignon # Date 2015-03-25 21:01:14 # Node ID 06cbff4674a35d8b3a274fc6f33e2b2814627635 # Parent 61a99993f8a75be2cd8d869da72573f605b4e0b0 revert: fix --interactive on local modification (issue4576) We were moving files during the backup phase and it was incompatible with the way record/crecord is working diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2810,6 +2810,7 @@ def revert(ui, repo, ctx, parents, *pats ## filling of the `names` mapping # walk dirstate to fill `names` + interactive = opts.get('interactive', False) wctx = repo[None] m = scmutil.match(wctx, pats, opts) if not m.always(): @@ -3031,7 +3032,10 @@ def revert(ui, repo, ctx, parents, *pats ui.note(_('saving current version of %s as %s\n') % (rel, bakname)) if not opts.get('dry_run'): - util.rename(target, bakname) + if interactive: + util.copyfile(target, bakname) + else: + util.rename(target, bakname) if ui.verbose or not exact: if not isinstance(msg, basestring): msg = msg(abs) @@ -3044,7 +3048,6 @@ def revert(ui, repo, ctx, parents, *pats if not opts.get('dry_run'): needdata = ('revert', 'add', 'undelete') _revertprefetch(repo, ctx, *[actions[name][0] for name in needdata]) - interactive = opts.get('interactive', False) _performrevert(repo, parents, ctx, actions, interactive) # get the list of subrepos that must be reverted diff --git a/tests/test-revert-interactive.t b/tests/test-revert-interactive.t --- a/tests/test-revert-interactive.t +++ b/tests/test-revert-interactive.t @@ -205,3 +205,53 @@ 10 run the same test than 8 from within 4 5 f + $ hg st + M f + M folder1/g + R folder1/i + $ hg revert --interactive f << EOF + > y + > y + > n + > n + > EOF + diff -r 59dd6e4ab63a f + 2 hunks, 2 lines changed + examine changes to 'f'? [Ynesfdaq?] y + + @@ -1,5 +1,6 @@ + +a + 1 + 2 + 3 + 4 + 5 + record change 1/2 to 'f'? [Ynesfdaq?] y + + @@ -1,5 +2,6 @@ + 1 + 2 + 3 + 4 + 5 + +b + record change 2/2 to 'f'? [Ynesfdaq?] n + + $ hg st + M f + M folder1/g + R folder1/i + ? f.orig + $ cat f + a + 1 + 2 + 3 + 4 + 5 + $ cat f.orig + 1 + 2 + 3 + 4 + 5