Mercurial > hg-stable
changeset 35023:3649c3f2cd90
revert: do not reverse hunks in interactive when REV is not parent (issue5096)
And introduce a new "apply" operation verb for this case as suggested in
issue5096. This replaces the no longer used "revert" operation.
In interactive revert, when reverting to something else that the parent
revision, display an "apply this change" message with a diff that is not
reversed.
The rationale is that `hg revert -i -r REV` will show hunks of the diff from
the working directory to REV and prompt the user to select them for applying
(to working directory). This contradicts dcc56e10c23b in which it was
decided to have the "direction" of prompted hunks reversed. Later on
[1], there was a broad consensus (but no decision) towards the "as to
be applied direction". Now that --interactive is no longer experimental
(5910db5d1913), it's time to switch and thus we drop no longer used
"experimental.revertalternateinteractivemode" configuration option.
[1]: https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-November/090142.html
.. feature::
When interactive revert is run against a revision other than the working
directory parent, the diff shown is the diff to *apply* to the working directory,
rather than the diff to *discard* from the working copy. This is in line with
related user experiences with `git` and appears to be less confusing with
`ui.interface=curses`.
author | Denis Laxalde <denis.laxalde@logilab.fr> |
---|---|
date | Fri, 03 Nov 2017 14:47:37 +0100 |
parents | 19ecd39223dc |
children | d600bda4a3e1 |
files | mercurial/cmdutil.py mercurial/configitems.py mercurial/patch.py tests/test-revert-interactive.t |
diffstat | 4 files changed, 52 insertions(+), 132 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Fri Nov 03 10:32:38 2017 -0500 +++ b/mercurial/cmdutil.py Fri Nov 03 14:47:37 2017 +0100 @@ -3790,9 +3790,8 @@ operation = 'discard' reversehunks = True if node != parent: - operation = 'revert' - reversehunks = repo.ui.configbool('experimental', - 'revertalternateinteractivemode') + operation = 'apply' + reversehunks = False if reversehunks: diff = patch.diff(repo, ctx.node(), None, m, opts=diffopts) else:
--- a/mercurial/configitems.py Fri Nov 03 10:32:38 2017 -0500 +++ b/mercurial/configitems.py Fri Nov 03 14:47:37 2017 +0100 @@ -439,9 +439,6 @@ coreconfigitem('experimental', 'rebase.multidest', default=False, ) -coreconfigitem('experimental', 'revertalternateinteractivemode', - default=True, -) coreconfigitem('experimental', 'revlogv2', default=None, )
--- a/mercurial/patch.py Fri Nov 03 10:32:38 2017 -0500 +++ b/mercurial/patch.py Fri Nov 03 14:47:37 2017 +0100 @@ -997,16 +997,26 @@ def getmessages(): return { 'multiple': { + 'apply': _("apply change %d/%d to '%s'?"), 'discard': _("discard change %d/%d to '%s'?"), 'record': _("record change %d/%d to '%s'?"), - 'revert': _("revert change %d/%d to '%s'?"), }, 'single': { + 'apply': _("apply this change to '%s'?"), 'discard': _("discard this change to '%s'?"), 'record': _("record this change to '%s'?"), - 'revert': _("revert this change to '%s'?"), }, 'help': { + 'apply': _('[Ynesfdaq?]' + '$$ &Yes, apply this change' + '$$ &No, skip this change' + '$$ &Edit this change manually' + '$$ &Skip remaining changes to this file' + '$$ Apply remaining changes to this &file' + '$$ &Done, skip remaining changes and files' + '$$ Apply &all changes to all remaining files' + '$$ &Quit, applying no changes' + '$$ &? (display help)'), 'discard': _('[Ynesfdaq?]' '$$ &Yes, discard this change' '$$ &No, skip this change' @@ -1027,16 +1037,6 @@ '$$ Record &all changes to all remaining files' '$$ &Quit, recording no changes' '$$ &? (display help)'), - 'revert': _('[Ynesfdaq?]' - '$$ &Yes, revert this change' - '$$ &No, skip this change' - '$$ &Edit this change manually' - '$$ &Skip remaining changes to this file' - '$$ Revert remaining changes to this &file' - '$$ &Done, skip remaining changes and files' - '$$ Revert &all changes to all remaining files' - '$$ &Quit, reverting no changes' - '$$ &? (display help)') } }
--- a/tests/test-revert-interactive.t Fri Nov 03 10:32:38 2017 -0500 +++ b/tests/test-revert-interactive.t Fri Nov 03 14:47:37 2017 +0100 @@ -60,56 +60,56 @@ 2 hunks, 2 lines changed examine changes to 'f'? [Ynesfdaq?] y - @@ -1,5 +1,6 @@ - +a + @@ -1,6 +1,5 @@ + -a 1 2 3 4 5 - revert change 1/6 to 'f'? [Ynesfdaq?] y + apply change 1/6 to 'f'? [Ynesfdaq?] y - @@ -1,5 +2,6 @@ + @@ -2,6 +1,5 @@ 1 2 3 4 5 - +b - revert change 2/6 to 'f'? [Ynesfdaq?] y + -b + apply change 2/6 to 'f'? [Ynesfdaq?] y diff --git a/folder1/g b/folder1/g 2 hunks, 2 lines changed examine changes to 'folder1/g'? [Ynesfdaq?] y - @@ -1,5 +1,6 @@ - +c + @@ -1,6 +1,5 @@ + -c 1 2 3 4 5 - revert change 3/6 to 'folder1/g'? [Ynesfdaq?] ? + apply change 3/6 to 'folder1/g'? [Ynesfdaq?] ? - y - yes, revert this change + y - yes, apply this change n - no, skip this change e - edit this change manually s - skip remaining changes to this file - f - revert remaining changes to this file + f - apply remaining changes to this file d - done, skip remaining changes and files - a - revert all changes to all remaining files - q - quit, reverting no changes + a - apply all changes to all remaining files + q - quit, applying no changes ? - ? (display help) - revert change 3/6 to 'folder1/g'? [Ynesfdaq?] y + apply change 3/6 to 'folder1/g'? [Ynesfdaq?] y - @@ -1,5 +2,6 @@ + @@ -2,6 +1,5 @@ 1 2 3 4 5 - +d - revert change 4/6 to 'folder1/g'? [Ynesfdaq?] n + -d + apply change 4/6 to 'folder1/g'? [Ynesfdaq?] n diff --git a/folder2/h b/folder2/h 2 hunks, 2 lines changed @@ -157,12 +157,12 @@ 1 hunks, 1 lines changed examine changes to 'folder1/g'? [Ynesfdaq?] y - @@ -3,3 +3,4 @@ + @@ -3,4 +3,3 @@ 3 4 5 - +d - revert this change to 'folder1/g'? [Ynesfdaq?] n + -d + apply this change to 'folder1/g'? [Ynesfdaq?] n $ ls folder1/ g @@ -173,12 +173,12 @@ 1 hunks, 1 lines changed examine changes to 'folder1/g'? [Ynesfdaq?] y - @@ -3,3 +3,4 @@ + @@ -3,4 +3,3 @@ 3 4 5 - +d - revert this change to 'folder1/g'? [Ynesfdaq?] y + -d + apply this change to 'folder1/g'? [Ynesfdaq?] y $ ls folder1/ g @@ -206,45 +206,45 @@ 2 hunks, 2 lines changed examine changes to 'f'? [Ynesfdaq?] y - @@ -1,5 +1,6 @@ - +a + @@ -1,6 +1,5 @@ + -a 1 2 3 4 5 - revert change 1/6 to 'f'? [Ynesfdaq?] y + apply change 1/6 to 'f'? [Ynesfdaq?] y - @@ -1,5 +2,6 @@ + @@ -2,6 +1,5 @@ 1 2 3 4 5 - +b - revert change 2/6 to 'f'? [Ynesfdaq?] y + -b + apply change 2/6 to 'f'? [Ynesfdaq?] y diff --git a/folder1/g b/folder1/g 2 hunks, 2 lines changed examine changes to 'folder1/g'? [Ynesfdaq?] y - @@ -1,5 +1,6 @@ - +c + @@ -1,6 +1,5 @@ + -c 1 2 3 4 5 - revert change 3/6 to 'folder1/g'? [Ynesfdaq?] y + apply change 3/6 to 'folder1/g'? [Ynesfdaq?] y - @@ -1,5 +2,6 @@ + @@ -2,6 +1,5 @@ 1 2 3 4 5 - +d - revert change 4/6 to 'folder1/g'? [Ynesfdaq?] n + -d + apply change 4/6 to 'folder1/g'? [Ynesfdaq?] n diff --git a/folder2/h b/folder2/h 2 hunks, 2 lines changed @@ -368,77 +368,6 @@ $ cat k 42 -Check the experimental config to invert the selection: - $ cat <<EOF >> $HGRCPATH - > [experimental] - > revertalternateinteractivemode=False - > EOF - - - $ hg up -C . - 1 files updated, 0 files merged, 0 files removed, 0 files unresolved - $ printf 'firstline\nc\n1\n2\n3\n 3\n5\nd\nlastline\n' > folder1/g - $ hg diff --nodates - diff -r a3d963a027aa folder1/g - --- a/folder1/g - +++ b/folder1/g - @@ -1,7 +1,9 @@ - +firstline - c - 1 - 2 - 3 - -4 - + 3 - 5 - d - +lastline - $ hg revert -i <<EOF - > y - > y - > y - > n - > EOF - reverting folder1/g (glob) - diff --git a/folder1/g b/folder1/g - 3 hunks, 3 lines changed - examine changes to 'folder1/g'? [Ynesfdaq?] y - - @@ -1,4 +1,5 @@ - +firstline - c - 1 - 2 - 3 - discard change 1/3 to 'folder1/g'? [Ynesfdaq?] y - - @@ -1,7 +2,7 @@ - c - 1 - 2 - 3 - -4 - + 3 - 5 - d - discard change 2/3 to 'folder1/g'? [Ynesfdaq?] y - - @@ -6,2 +7,3 @@ - 5 - d - +lastline - discard change 3/3 to 'folder1/g'? [Ynesfdaq?] n - - $ hg diff --nodates - diff -r a3d963a027aa folder1/g - --- a/folder1/g - +++ b/folder1/g - @@ -5,3 +5,4 @@ - 4 - 5 - d - +lastline - $ hg update -C . 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg purge @@ -463,11 +392,6 @@ When a line without EOL is selected during "revert -i" (issue5651) - $ cat <<EOF >> $HGRCPATH - > [experimental] - > %unset revertalternateinteractivemode - > EOF - $ hg init $TESTTMP/revert-i-eol $ cd $TESTTMP/revert-i-eol $ echo 0 > a @@ -487,11 +411,11 @@ 1 hunks, 1 lines changed examine changes to 'a'? [Ynesfdaq?] y - @@ -1,1 +1,2 @@ + @@ -1,2 +1,1 @@ 0 - +1 + -1 \ No newline at end of file - revert this change to 'a'? [Ynesfdaq?] y + apply this change to 'a'? [Ynesfdaq?] y $ cat a 0