revert: use "discard"/"revert" verb when reverting interactively (issue5143)
Instead of "record this change to 'FILE'?" now prompt with:
* "discard this change to 'FILE'?" when reverting to the parent of working
directory, and,
* "revert this change to 'FILE'?" otherwise.
--- a/mercurial/cmdutil.py Tue Apr 05 01:35:58 2016 +0000
+++ b/mercurial/cmdutil.py Fri Jun 03 15:55:07 2016 +0200
@@ -3301,10 +3301,12 @@
else:
diff = patch.diff(repo, None, ctx.node(), m, opts=diffopts)
originalchunks = patch.parsepatch(diff)
+ operation = _('discard') if node == parent else _('revert')
try:
- chunks, opts = recordfilter(repo.ui, originalchunks)
+ chunks, opts = recordfilter(repo.ui, originalchunks,
+ operation=operation)
if reversehunks:
chunks = patch.reversehunks(chunks)
--- a/mercurial/patch.py Tue Apr 05 01:35:58 2016 +0000
+++ b/mercurial/patch.py Fri Jun 03 15:55:07 2016 +0200
@@ -1109,11 +1109,12 @@
if skipfile is None and skipall is None:
chunk.pretty(ui)
if total == 1:
- msg = _("record this change to '%s'?") % chunk.filename()
+ msg = _("%s this change to '%s'?") % (operation,
+ chunk.filename())
else:
idx = pos - len(h.hunks) + i
- msg = _("record change %d/%d to '%s'?") % (idx, total,
- chunk.filename())
+ msg = _("%s change %d/%d to '%s'?") % (operation, idx, total,
+ chunk.filename())
r, skipfile, skipall, newpatches = prompt(skipfile,
skipall, msg, chunk)
if r:
--- a/tests/test-revert-interactive.t Tue Apr 05 01:35:58 2016 +0000
+++ b/tests/test-revert-interactive.t Fri Jun 03 15:55:07 2016 +0200
@@ -64,7 +64,7 @@
3
4
5
- record change 1/6 to 'f'? [Ynesfdaq?] y
+ revert change 1/6 to 'f'? [Ynesfdaq?] y
@@ -1,5 +2,6 @@
1
@@ -73,7 +73,7 @@
4
5
+b
- record change 2/6 to 'f'? [Ynesfdaq?] y
+ revert change 2/6 to 'f'? [Ynesfdaq?] y
diff --git a/folder1/g b/folder1/g
2 hunks, 2 lines changed
@@ -86,7 +86,7 @@
3
4
5
- record change 3/6 to 'folder1/g'? [Ynesfdaq?] y
+ revert change 3/6 to 'folder1/g'? [Ynesfdaq?] y
@@ -1,5 +2,6 @@
1
@@ -95,7 +95,7 @@
4
5
+d
- record change 4/6 to 'folder1/g'? [Ynesfdaq?] n
+ revert change 4/6 to 'folder1/g'? [Ynesfdaq?] n
diff --git a/folder2/h b/folder2/h
2 hunks, 2 lines changed
@@ -163,7 +163,7 @@
3
4
5
- record change 1/6 to 'f'? [Ynesfdaq?] y
+ revert change 1/6 to 'f'? [Ynesfdaq?] y
@@ -1,5 +2,6 @@
1
@@ -172,7 +172,7 @@
4
5
+b
- record change 2/6 to 'f'? [Ynesfdaq?] y
+ revert change 2/6 to 'f'? [Ynesfdaq?] y
diff --git a/folder1/g b/folder1/g
2 hunks, 2 lines changed
@@ -185,7 +185,7 @@
3
4
5
- record change 3/6 to 'folder1/g'? [Ynesfdaq?] y
+ revert change 3/6 to 'folder1/g'? [Ynesfdaq?] y
@@ -1,5 +2,6 @@
1
@@ -194,7 +194,7 @@
4
5
+d
- record change 4/6 to 'folder1/g'? [Ynesfdaq?] n
+ revert change 4/6 to 'folder1/g'? [Ynesfdaq?] n
diff --git a/folder2/h b/folder2/h
2 hunks, 2 lines changed
@@ -242,7 +242,7 @@
3
4
5
- record change 1/2 to 'f'? [Ynesfdaq?] y
+ discard change 1/2 to 'f'? [Ynesfdaq?] y
@@ -2,6 +1,5 @@
1
@@ -251,7 +251,7 @@
4
5
-b
- record change 2/2 to 'f'? [Ynesfdaq?] n
+ discard change 2/2 to 'f'? [Ynesfdaq?] n
$ hg st
M f
@@ -303,7 +303,7 @@
-1
+0
+2
- record this change to 'k'? [Ynesfdaq?] e
+ discard this change to 'k'? [Ynesfdaq?] e
$ cat k
42
@@ -350,7 +350,7 @@
1
2
3
- record change 1/3 to 'folder1/g'? [Ynesfdaq?] y
+ discard change 1/3 to 'folder1/g'? [Ynesfdaq?] y
@@ -2,7 +1,7 @@
c
@@ -361,13 +361,13 @@
+4
5
d
- record change 2/3 to 'folder1/g'? [Ynesfdaq?] y
+ discard change 2/3 to 'folder1/g'? [Ynesfdaq?] y
@@ -7,3 +6,2 @@
5
d
-lastline
- record change 3/3 to 'folder1/g'? [Ynesfdaq?] n
+ discard change 3/3 to 'folder1/g'? [Ynesfdaq?] n
$ hg diff --nodates
diff -r a3d963a027aa folder1/g