changeset 13295:fb446228c0d4

record: do not include files into changes count This turns the prompt sequence from something like: $ examine changes to foo? $ record change 1/4 to foo? $ record change 2/4 to foo? $ examine changes to bar? $ record change 4/4 to bar? into: $ examine changes to foo? $ record change 1/3 to foo? $ record change 2/3 to foo? $ examine change to bar? $ record change 3/3 to bar?
author Patrick Mezard <pmezard@gmail.com>
date Mon, 24 Jan 2011 23:25:46 +0100
parents 98f0adfc89e3
children 5dda6c708138
files hgext/record.py tests/test-qrecord.t tests/test-record.t
diffstat 3 files changed, 12 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/record.py	Sun Jan 23 15:21:56 2011 +0100
+++ b/hgext/record.py	Mon Jan 24 23:25:46 2011 +0100
@@ -301,12 +301,9 @@
     seen = set()
     applied = {}        # 'filename' -> [] of chunks
     skipfile, skipall = None, None
-    # XXX: operation count is weird: it counts headers and hunks
-    # except for the first header. It probably comes from the previous
-    # mixed header/hunk stream representation.
-    pos, total = -1, sum((len(h.hunks) + 1) for h in headers) - 1
+    pos, total = 1, sum(len(h.hunks) for h in headers)
     for h in headers:
-        pos += len(h.hunks) + 1
+        pos += len(h.hunks)
         skipfile = None
         fixoffset = 0
         hdr = ''.join(h.header)
@@ -330,7 +327,7 @@
             msg = (total == 1
                    and (_('record this change to %r?') % chunk.filename())
                    or (_('record change %d/%d to %r?') %
-                       (pos - len(h.hunks) + i + 1, total, chunk.filename())))
+                       (pos - len(h.hunks) + i, total, chunk.filename())))
             r, skipfile, skipall = prompt(skipfile, skipall, msg)
             if r:
                 if fixoffset:
--- a/tests/test-qrecord.t	Sun Jan 23 15:21:56 2011 +0100
+++ b/tests/test-qrecord.t	Mon Jan 24 23:25:46 2011 +0100
@@ -158,13 +158,13 @@
   -2
   +2 2
    3
-  record change 1/6 to '1.txt'? [Ynsfdaq?] 
+  record change 1/4 to '1.txt'? [Ynsfdaq?] 
   @@ -3,3 +3,3 @@
    3
   -4
   +4 4
    5
-  record change 2/6 to '1.txt'? [Ynsfdaq?] 
+  record change 2/4 to '1.txt'? [Ynsfdaq?] 
   diff --git a/2.txt b/2.txt
   1 hunks, 1 lines changed
   examine changes to '2.txt'? [Ynsfdaq?] 
@@ -175,7 +175,7 @@
    c
    d
    e
-  record change 4/6 to '2.txt'? [Ynsfdaq?] 
+  record change 3/4 to '2.txt'? [Ynsfdaq?] 
   diff --git a/dir/a.txt b/dir/a.txt
   1 hunks, 1 lines changed
   examine changes to 'dir/a.txt'? [Ynsfdaq?] 
@@ -255,7 +255,7 @@
   -4
   +4 4
    5
-  record change 1/3 to '1.txt'? [Ynsfdaq?] 
+  record change 1/2 to '1.txt'? [Ynsfdaq?] 
   diff --git a/dir/a.txt b/dir/a.txt
   1 hunks, 1 lines changed
   examine changes to 'dir/a.txt'? [Ynsfdaq?] 
@@ -265,7 +265,7 @@
    
    someone
    up
-  record change 3/3 to 'dir/a.txt'? [Ynsfdaq?] 
+  record change 2/2 to 'dir/a.txt'? [Ynsfdaq?] 
 
 After qrecord b.patch 'tip'
 
--- a/tests/test-record.t	Sun Jan 23 15:21:56 2011 +0100
+++ b/tests/test-record.t	Mon Jan 24 23:25:46 2011 +0100
@@ -302,7 +302,7 @@
   -7264f99c5f5ff3261504828afa4fb4d406c3af54
   \ No newline at end of file
   +7264f99c5f5ff3261504828afa4fb4d406c3af54
-  record change 1/3 to 'plain'? [Ynsfdaq?] 
+  record change 1/2 to 'plain'? [Ynsfdaq?] 
   diff --git a/plain2 b/plain2
   new file mode 100644
   examine changes to 'plain2'? [Ynsfdaq?] 
@@ -332,21 +332,21 @@
    2
    3
    4
-  record change 1/4 to 'plain'? [Ynsfdaq?] 
+  record change 1/3 to 'plain'? [Ynsfdaq?] 
   @@ -8,5 +8,3 @@
    8
    9
    10
   -11
   -7264f99c5f5ff3261504828afa4fb4d406c3af54
-  record change 2/4 to 'plain'? [Ynsfdaq?] 
+  record change 2/3 to 'plain'? [Ynsfdaq?] 
   diff --git a/plain2 b/plain2
   1 hunks, 1 lines changed
   examine changes to 'plain2'? [Ynsfdaq?] 
   @@ -1,1 +1,2 @@
    1
   +2
-  record change 4/4 to 'plain2'? [Ynsfdaq?] 
+  record change 3/3 to 'plain2'? [Ynsfdaq?] 
 
   $ hg tip -p
   changeset:   11:21df83db12b8