[PATCH] record: Give user a hint about chunk selection progress

Rocco Rutte pdmef at gmx.net
Sat Mar 28 10:31:17 CDT 2009


# HG changeset patch
# User Rocco Rutte <pdmef at gmx.net>
# Date 1238253856 -3600
# Node ID c74b0d7424e645bd647d292442cc38859ac547b3
# Parent  2976b7f92ce509c0d972ab83d04b1c0947795661
record: Give user a hint about chunk selection progress

For me it greatly improves usage when I roughly know where
the chunks are in which I'm interested.

diff --git a/hgext/record.py b/hgext/record.py
--- a/hgext/record.py
+++ b/hgext/record.py
@@ -302,6 +302,7 @@ def filterpatch(ui, chunks):
             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,8 @@ def filterpatch(ui, chunks):
             # 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 = prompt(_('record change %d/%d to %r?') %
+                       (pos, total, chunk.filename()))
             if r == _('y'):
                 if fixoffset:
                     chunk = copy.copy(chunk)
@@ -336,6 +337,7 @@ def filterpatch(ui, chunks):
                 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], [])
 
diff --git a/tests/test-record.out b/tests/test-record.out
--- a/tests/test-record.out
+++ b/tests/test-record.out
@@ -187,7 +187,7 @@ examine changes to 'plain'? [Ynsfdaq?]  
  9
  10
 +11
-record this change to 'plain'? [Ynsfdaq?]  % modify end of plain file, no EOL
+record change 1/1 to 'plain'? [Ynsfdaq?]  % modify end of plain file, no EOL
 diff --git a/plain b/plain
 1 hunks, 1 lines changed
 examine changes to 'plain'? [Ynsfdaq?]  @@ -9,3 +9,4 @@
@@ -196,7 +196,7 @@ examine changes to 'plain'? [Ynsfdaq?]  
  11
 +cf81a2760718a74d44c0c2eecb72f659e63a69c5
 \ No newline at end of file
-record this change to 'plain'? [Ynsfdaq?]  % modify end of plain file, add EOL
+record change 1/1 to 'plain'? [Ynsfdaq?]  % modify end of plain file, add EOL
 diff --git a/plain b/plain
 1 hunks, 2 lines changed
 examine changes to 'plain'? [Ynsfdaq?]  @@ -9,4 +9,4 @@
@@ -206,7 +206,7 @@ examine changes to 'plain'? [Ynsfdaq?]  
 -cf81a2760718a74d44c0c2eecb72f659e63a69c5
 \ No newline at end of file
 +cf81a2760718a74d44c0c2eecb72f659e63a69c5
-record this change to 'plain'? [Ynsfdaq?]  % modify beginning, trim end, record both
+record change 1/1 to 'plain'? [Ynsfdaq?]  % modify beginning, trim end, record both
 diff --git a/plain b/plain
 2 hunks, 4 lines changed
 examine changes to 'plain'? [Ynsfdaq?]  @@ -1,4 +1,4 @@
@@ -215,13 +215,13 @@ examine changes to 'plain'? [Ynsfdaq?]  
  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 @@ examine changes to 'plain'? [Ynsfdaq?]  
  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 @@ record this change to 'plain'? [Ynsfdaq?
  9
 -10
 +10.new
-record this change to 'plain'? [Ynsfdaq?]  
+record change 2/2 to 'plain'? [Ynsfdaq?]  
 changeset:   12:44516c9708ae
 tag:         tip
 user:        test
@@ -294,7 +294,7 @@ examine changes to 'plain'? [Ynsfdaq?]  
  4
  5
  6
-record this change to 'plain'? [Ynsfdaq?]  
+record change 1/1 to 'plain'? [Ynsfdaq?]  
 changeset:   13:3ebbace64a8d
 tag:         tip
 user:        test
@@ -326,7 +326,7 @@ examine changes to 'plain'? [Ynsfdaq?]  
  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 @@ record this change to 'plain'? [Ynsfdaq?
  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 @@ examine changes to 'plain'? [Ynsfdaq?]  
 +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 @@ record this change to 'plain'? [Ynsfdaq?
  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
@@ -391,7 +391,7 @@ examine changes to 'plain'? [Ynsfdaq?]  
  9
 +10
 +11
-record this change to 'plain'? [Ynsfdaq?]  
+record change 1/1 to 'plain'? [Ynsfdaq?]  
 changeset:   16:80b74bbc7808
 tag:         tip
 user:        test
@@ -414,7 +414,7 @@ 1 hunks, 1 lines changed
 examine changes to 'subdir/a'? [Ynsfdaq?]  @@ -1,1 +1,2 @@
  a
 +a
-record this change to 'subdir/a'? [Ynsfdaq?]  
+record change 1/1 to 'subdir/a'? [Ynsfdaq?]  
 changeset:   18:33ff5c4fb017
 tag:         tip
 user:        test
@@ -503,7 +503,7 @@ examine changes to 'subdir/f1'? [Ynsfdaq
  a
  a
 +a
-record this change to 'subdir/f1'? [Ynsfdaq?]  
+record change 1/1 to 'subdir/f1'? [Ynsfdaq?]  
 changeset:   22:a891589cb933
 tag:         tip
 user:        test
@@ -528,7 +528,7 @@ examine changes to 'subdir/f1'? [Ynsfdaq
  a
  a
 +b
-record this change to 'subdir/f1'? [Ynsfdaq?]  
+record change 1/1 to 'subdir/f1'? [Ynsfdaq?]  
 changeset:   23:befa0dae6201
 tag:         tip
 user:        test
@@ -554,7 +554,7 @@ examine changes to 'subdir/f1'? [Ynsfdaq
  a
  b
 +c
-record this change to 'subdir/f1'? [Ynsfdaq?]  
+record change 1/1 to 'subdir/f1'? [Ynsfdaq?]  
 changeset:   24:8fd83ff53ce6
 tag:         tip
 user:        test


More information about the Mercurial-devel mailing list