record: Give user a hint about chunk selection progress
It greatly improves usability when one roughly knows where
the chunks of interest are.
--- a/hgext/record.py Sat Mar 28 22:22:22 2009 +0100
+++ b/hgext/record.py Sat Mar 28 23:09:36 2009 +0100
@@ -302,6 +302,7 @@
elif r == _('q'):
raise util.Abort(_('user quit'))
return r
+ pos, total = 0, len(chunks) - 1
while chunks:
chunk = chunks.pop()
if isinstance(chunk, header):
@@ -327,8 +328,10 @@
# new hunk
if resp_file[0] is None and resp_all[0] is None:
chunk.pretty(ui)
- r = prompt(_('record this change to %r?') %
- chunk.filename())
+ r = total == 1 and prompt(_('record this change to %r?') %
+ chunk.filename()) or \
+ prompt(_('record change %d/%d to %r?') %
+ (pos, total, chunk.filename()))
if r == _('y'):
if fixoffset:
chunk = copy.copy(chunk)
@@ -336,6 +339,7 @@
applied[chunk.filename()].append(chunk)
else:
fixoffset += chunk.removed - chunk.added
+ pos = pos + 1
return reduce(operator.add, [h for h in applied.itervalues()
if h[0].special() or len(h) > 1], [])
--- a/tests/test-qrecord.out Sat Mar 28 22:22:22 2009 +0100
+++ b/tests/test-qrecord.out Sat Mar 28 23:09:36 2009 +0100
@@ -84,12 +84,12 @@
-2
+2 2
3
-record this change to '1.txt'? [Ynsfdaq?] @@ -3,3 +3,3 @@
+record change 1/6 to '1.txt'? [Ynsfdaq?] @@ -3,3 +3,3 @@
3
-4
+4 4
5
-record this change to '1.txt'? [Ynsfdaq?] diff --git a/2.txt b/2.txt
+record change 2/6 to '1.txt'? [Ynsfdaq?] diff --git a/2.txt b/2.txt
1 hunks, 2 lines changed
examine changes to '2.txt'? [Ynsfdaq?] @@ -1,5 +1,5 @@
a
@@ -98,7 +98,7 @@
c
d
e
-record this change to '2.txt'? [Ynsfdaq?] diff --git a/dir/a.txt b/dir/a.txt
+record change 4/6 to '2.txt'? [Ynsfdaq?] diff --git a/dir/a.txt b/dir/a.txt
1 hunks, 2 lines changed
examine changes to 'dir/a.txt'? [Ynsfdaq?]
% after qrecord a.patch 'tip'
@@ -163,7 +163,7 @@
-4
+4 4
5
-record this change to '1.txt'? [Ynsfdaq?] diff --git a/dir/a.txt b/dir/a.txt
+record change 1/3 to '1.txt'? [Ynsfdaq?] diff --git a/dir/a.txt b/dir/a.txt
1 hunks, 2 lines changed
examine changes to 'dir/a.txt'? [Ynsfdaq?] @@ -1,4 +1,4 @@
-hello world
@@ -171,7 +171,7 @@
someone
up
-record this change to 'dir/a.txt'? [Ynsfdaq?]
+record change 3/3 to 'dir/a.txt'? [Ynsfdaq?]
% after qrecord b.patch 'tip'
changeset: 2:b056198bf878
tag: qtip
--- a/tests/test-record.out Sat Mar 28 22:22:22 2009 +0100
+++ b/tests/test-record.out Sat Mar 28 23:09:36 2009 +0100
@@ -215,13 +215,13 @@
2
3
4
-record this change to 'plain'? [Ynsfdaq?] @@ -8,5 +8,3 @@
+record change 1/2 to 'plain'? [Ynsfdaq?] @@ -8,5 +8,3 @@
8
9
10
-11
-cf81a2760718a74d44c0c2eecb72f659e63a69c5
-record this change to 'plain'? [Ynsfdaq?]
+record change 2/2 to 'plain'? [Ynsfdaq?]
changeset: 11:d09ab1967dab
tag: tip
user: test
@@ -258,7 +258,7 @@
7
8
9
-record this change to 'plain'? [Ynsfdaq?] @@ -4,7 +1,7 @@
+record change 1/2 to 'plain'? [Ynsfdaq?] @@ -4,7 +1,7 @@
4
5
6
@@ -267,7 +267,7 @@
9
-10
+10.new
-record this change to 'plain'? [Ynsfdaq?]
+record change 2/2 to 'plain'? [Ynsfdaq?]
changeset: 12:44516c9708ae
tag: tip
user: test
@@ -326,7 +326,7 @@
7
8
9
-record this change to 'plain'? [Ynsfdaq?] @@ -1,7 +4,6 @@
+record change 1/2 to 'plain'? [Ynsfdaq?] @@ -1,7 +4,6 @@
4
5
6
@@ -334,7 +334,7 @@
8
9
-10.new
-record this change to 'plain'? [Ynsfdaq?] % add to beginning, middle, end
+record change 2/2 to 'plain'? [Ynsfdaq?] % add to beginning, middle, end
% record beginning, middle
diff --git a/plain b/plain
3 hunks, 7 lines changed
@@ -344,7 +344,7 @@
+3
4
5
-record this change to 'plain'? [Ynsfdaq?] @@ -1,6 +4,8 @@
+record change 1/3 to 'plain'? [Ynsfdaq?] @@ -1,6 +4,8 @@
4
5
+5.new
@@ -353,14 +353,14 @@
7
8
9
-record this change to 'plain'? [Ynsfdaq?] @@ -3,4 +8,6 @@
+record change 2/3 to 'plain'? [Ynsfdaq?] @@ -3,4 +8,6 @@
6
7
8
9
+10
+11
-record this change to 'plain'? [Ynsfdaq?]
+record change 3/3 to 'plain'? [Ynsfdaq?]
changeset: 15:c1c639d8b268
tag: tip
user: test