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

Rocco Rutte pdmef at gmx.net
Sat Mar 28 17:14:00 CDT 2009


Hi,

* Benoit Boissinot wrote:

>Maybe you should skip it for 1/1 ? Otherwise it's +1 from me.

Yeah, that looks better. Yet another version is attached.

Rocco
-------------- next part --------------
# HG changeset patch
# User Rocco Rutte <pdmef at gmx.net>
# Date 1238278176 -3600
# Node ID d2d6502b41a910ae7b6792b0a08ba386b1ec888a
# Parent  27f23c9da186c76a34a21d70a70d1901ee044c68
record: Give user a hint about chunk selection progress

It greatly improves usability when one roughly knows where
the chunks of interest are.

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,10 @@ 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 = 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 @@ 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-qrecord.out b/tests/test-qrecord.out
--- a/tests/test-qrecord.out
+++ b/tests/test-qrecord.out
@@ -84,12 +84,12 @@ examine changes to '1.txt'? [Ynsfdaq?]  
 -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 @@ examine changes to '2.txt'? [Ynsfdaq?]  
  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 @@ examine changes to '1.txt'? [Ynsfdaq?]  
 -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 @@ examine changes to 'dir/a.txt'? [Ynsfdaq
  
  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
diff --git a/tests/test-record.out b/tests/test-record.out
--- a/tests/test-record.out
+++ b/tests/test-record.out
@@ -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
@@ -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


More information about the Mercurial-devel mailing list