changeset 14522:5ca61ef6ff00

localrepo: simplify file bundling code and fix progress bug Progress for files was off by one, and the code was rather hackish.
author Sune Foldager <cryo@cyanite.org>
date Fri, 03 Jun 2011 20:23:32 +0200
parents d27f669bad7c
children b4175b72bbd8
files mercurial/localrepo.py tests/test-acl.t tests/test-bundle.t
diffstat 3 files changed, 97 insertions(+), 104 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Fri Jun 03 20:15:06 2011 +0200
+++ b/mercurial/localrepo.py	Fri Jun 03 20:23:32 2011 +0200
@@ -1570,17 +1570,14 @@
                     raise util.Abort(_("empty or missing revlog for %s") % fname)
                 fstate[0] = fname
                 fstate[1] = fnodes.pop(fname, {})
-                first = True
 
-                for chunk in filerevlog.group(prune(filerevlog, fstate[1]),
-                                              bundler, reorder=reorder):
-                    if first:
-                        if chunk == bundler.close():
-                            break
-                        count[0] += 1
-                        yield bundler.fileheader(fname)
-                        first = False
-                    yield chunk
+                nodelist = prune(filerevlog, fstate[1])
+                if nodelist:
+                    count[0] += 1
+                    yield bundler.fileheader(fname)
+                    for chunk in filerevlog.group(nodelist, bundler, reorder):
+                        yield chunk
+
             # Signal that no more groups are left.
             yield bundler.close()
             self.ui.progress(_('bundling'), None)
@@ -1665,16 +1662,12 @@
                 if not len(filerevlog):
                     raise util.Abort(_("empty or missing revlog for %s") % fname)
                 fstate[0] = fname
-                first = True
-                for chunk in filerevlog.group(gennodelst(filerevlog), bundler,
-                                              reorder=reorder):
-                    if first:
-                        if chunk == bundler.close():
-                            break
-                        count[0] += 1
-                        yield bundler.fileheader(fname)
-                        first = False
-                    yield chunk
+                nodelist = gennodelst(filerevlog)
+                if nodelist:
+                    count[0] += 1
+                    yield bundler.fileheader(fname)
+                    for chunk in filerevlog.group(nodelist, bundler, reorder):
+                        yield chunk
             yield bundler.close()
             self.ui.progress(_('bundling'), None)
 
--- a/tests/test-acl.t	Fri Jun 03 20:15:06 2011 +0200
+++ b/tests/test-acl.t	Fri Jun 03 20:23:32 2011 +0200
@@ -97,9 +97,9 @@
   bundling: 1/3 manifests (33.33%)
   bundling: 2/3 manifests (66.67%)
   bundling: 3/3 manifests (100.00%)
-  bundling: foo/Bar/file.txt 0/3 files (0.00%)
-  bundling: foo/file.txt 1/3 files (33.33%)
-  bundling: quux/file.py 2/3 files (66.67%)
+  bundling: foo/Bar/file.txt 1/3 files (33.33%)
+  bundling: foo/file.txt 2/3 files (66.67%)
+  bundling: quux/file.py 3/3 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
@@ -153,9 +153,9 @@
   bundling: 1/3 manifests (33.33%)
   bundling: 2/3 manifests (66.67%)
   bundling: 3/3 manifests (100.00%)
-  bundling: foo/Bar/file.txt 0/3 files (0.00%)
-  bundling: foo/file.txt 1/3 files (33.33%)
-  bundling: quux/file.py 2/3 files (66.67%)
+  bundling: foo/Bar/file.txt 1/3 files (33.33%)
+  bundling: foo/file.txt 2/3 files (66.67%)
+  bundling: quux/file.py 3/3 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
@@ -212,9 +212,9 @@
   bundling: 1/3 manifests (33.33%)
   bundling: 2/3 manifests (66.67%)
   bundling: 3/3 manifests (100.00%)
-  bundling: foo/Bar/file.txt 0/3 files (0.00%)
-  bundling: foo/file.txt 1/3 files (33.33%)
-  bundling: quux/file.py 2/3 files (66.67%)
+  bundling: foo/Bar/file.txt 1/3 files (33.33%)
+  bundling: foo/file.txt 2/3 files (66.67%)
+  bundling: quux/file.py 3/3 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
@@ -280,9 +280,9 @@
   bundling: 1/3 manifests (33.33%)
   bundling: 2/3 manifests (66.67%)
   bundling: 3/3 manifests (100.00%)
-  bundling: foo/Bar/file.txt 0/3 files (0.00%)
-  bundling: foo/file.txt 1/3 files (33.33%)
-  bundling: quux/file.py 2/3 files (66.67%)
+  bundling: foo/Bar/file.txt 1/3 files (33.33%)
+  bundling: foo/file.txt 2/3 files (66.67%)
+  bundling: quux/file.py 3/3 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
@@ -345,9 +345,9 @@
   bundling: 1/3 manifests (33.33%)
   bundling: 2/3 manifests (66.67%)
   bundling: 3/3 manifests (100.00%)
-  bundling: foo/Bar/file.txt 0/3 files (0.00%)
-  bundling: foo/file.txt 1/3 files (33.33%)
-  bundling: quux/file.py 2/3 files (66.67%)
+  bundling: foo/Bar/file.txt 1/3 files (33.33%)
+  bundling: foo/file.txt 2/3 files (66.67%)
+  bundling: quux/file.py 3/3 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
@@ -415,9 +415,9 @@
   bundling: 1/3 manifests (33.33%)
   bundling: 2/3 manifests (66.67%)
   bundling: 3/3 manifests (100.00%)
-  bundling: foo/Bar/file.txt 0/3 files (0.00%)
-  bundling: foo/file.txt 1/3 files (33.33%)
-  bundling: quux/file.py 2/3 files (66.67%)
+  bundling: foo/Bar/file.txt 1/3 files (33.33%)
+  bundling: foo/file.txt 2/3 files (66.67%)
+  bundling: quux/file.py 3/3 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
@@ -482,9 +482,9 @@
   bundling: 1/3 manifests (33.33%)
   bundling: 2/3 manifests (66.67%)
   bundling: 3/3 manifests (100.00%)
-  bundling: foo/Bar/file.txt 0/3 files (0.00%)
-  bundling: foo/file.txt 1/3 files (33.33%)
-  bundling: quux/file.py 2/3 files (66.67%)
+  bundling: foo/Bar/file.txt 1/3 files (33.33%)
+  bundling: foo/file.txt 2/3 files (66.67%)
+  bundling: quux/file.py 3/3 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
@@ -554,9 +554,9 @@
   bundling: 1/3 manifests (33.33%)
   bundling: 2/3 manifests (66.67%)
   bundling: 3/3 manifests (100.00%)
-  bundling: foo/Bar/file.txt 0/3 files (0.00%)
-  bundling: foo/file.txt 1/3 files (33.33%)
-  bundling: quux/file.py 2/3 files (66.67%)
+  bundling: foo/Bar/file.txt 1/3 files (33.33%)
+  bundling: foo/file.txt 2/3 files (66.67%)
+  bundling: quux/file.py 3/3 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
@@ -623,9 +623,9 @@
   bundling: 1/3 manifests (33.33%)
   bundling: 2/3 manifests (66.67%)
   bundling: 3/3 manifests (100.00%)
-  bundling: foo/Bar/file.txt 0/3 files (0.00%)
-  bundling: foo/file.txt 1/3 files (33.33%)
-  bundling: quux/file.py 2/3 files (66.67%)
+  bundling: foo/Bar/file.txt 1/3 files (33.33%)
+  bundling: foo/file.txt 2/3 files (66.67%)
+  bundling: quux/file.py 3/3 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
@@ -694,9 +694,9 @@
   bundling: 1/3 manifests (33.33%)
   bundling: 2/3 manifests (66.67%)
   bundling: 3/3 manifests (100.00%)
-  bundling: foo/Bar/file.txt 0/3 files (0.00%)
-  bundling: foo/file.txt 1/3 files (33.33%)
-  bundling: quux/file.py 2/3 files (66.67%)
+  bundling: foo/Bar/file.txt 1/3 files (33.33%)
+  bundling: foo/file.txt 2/3 files (66.67%)
+  bundling: quux/file.py 3/3 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
@@ -769,9 +769,9 @@
   bundling: 1/3 manifests (33.33%)
   bundling: 2/3 manifests (66.67%)
   bundling: 3/3 manifests (100.00%)
-  bundling: foo/Bar/file.txt 0/3 files (0.00%)
-  bundling: foo/file.txt 1/3 files (33.33%)
-  bundling: quux/file.py 2/3 files (66.67%)
+  bundling: foo/Bar/file.txt 1/3 files (33.33%)
+  bundling: foo/file.txt 2/3 files (66.67%)
+  bundling: quux/file.py 3/3 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
@@ -847,9 +847,9 @@
   bundling: 1/3 manifests (33.33%)
   bundling: 2/3 manifests (66.67%)
   bundling: 3/3 manifests (100.00%)
-  bundling: foo/Bar/file.txt 0/3 files (0.00%)
-  bundling: foo/file.txt 1/3 files (33.33%)
-  bundling: quux/file.py 2/3 files (66.67%)
+  bundling: foo/Bar/file.txt 1/3 files (33.33%)
+  bundling: foo/file.txt 2/3 files (66.67%)
+  bundling: quux/file.py 3/3 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
@@ -919,9 +919,9 @@
   bundling: 1/3 manifests (33.33%)
   bundling: 2/3 manifests (66.67%)
   bundling: 3/3 manifests (100.00%)
-  bundling: foo/Bar/file.txt 0/3 files (0.00%)
-  bundling: foo/file.txt 1/3 files (33.33%)
-  bundling: quux/file.py 2/3 files (66.67%)
+  bundling: foo/Bar/file.txt 1/3 files (33.33%)
+  bundling: foo/file.txt 2/3 files (66.67%)
+  bundling: quux/file.py 3/3 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
@@ -1003,9 +1003,9 @@
   bundling: 1/3 manifests (33.33%)
   bundling: 2/3 manifests (66.67%)
   bundling: 3/3 manifests (100.00%)
-  bundling: foo/Bar/file.txt 0/3 files (0.00%)
-  bundling: foo/file.txt 1/3 files (33.33%)
-  bundling: quux/file.py 2/3 files (66.67%)
+  bundling: foo/Bar/file.txt 1/3 files (33.33%)
+  bundling: foo/file.txt 2/3 files (66.67%)
+  bundling: quux/file.py 3/3 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
@@ -1079,9 +1079,9 @@
   bundling: 1/3 manifests (33.33%)
   bundling: 2/3 manifests (66.67%)
   bundling: 3/3 manifests (100.00%)
-  bundling: foo/Bar/file.txt 0/3 files (0.00%)
-  bundling: foo/file.txt 1/3 files (33.33%)
-  bundling: quux/file.py 2/3 files (66.67%)
+  bundling: foo/Bar/file.txt 1/3 files (33.33%)
+  bundling: foo/file.txt 2/3 files (66.67%)
+  bundling: quux/file.py 3/3 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
@@ -1151,9 +1151,9 @@
   bundling: 1/3 manifests (33.33%)
   bundling: 2/3 manifests (66.67%)
   bundling: 3/3 manifests (100.00%)
-  bundling: foo/Bar/file.txt 0/3 files (0.00%)
-  bundling: foo/file.txt 1/3 files (33.33%)
-  bundling: quux/file.py 2/3 files (66.67%)
+  bundling: foo/Bar/file.txt 1/3 files (33.33%)
+  bundling: foo/file.txt 2/3 files (66.67%)
+  bundling: quux/file.py 3/3 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
@@ -1225,9 +1225,9 @@
   bundling: 1/3 manifests (33.33%)
   bundling: 2/3 manifests (66.67%)
   bundling: 3/3 manifests (100.00%)
-  bundling: foo/Bar/file.txt 0/3 files (0.00%)
-  bundling: foo/file.txt 1/3 files (33.33%)
-  bundling: quux/file.py 2/3 files (66.67%)
+  bundling: foo/Bar/file.txt 1/3 files (33.33%)
+  bundling: foo/file.txt 2/3 files (66.67%)
+  bundling: quux/file.py 3/3 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
@@ -1298,9 +1298,9 @@
   bundling: 1/3 manifests (33.33%)
   bundling: 2/3 manifests (66.67%)
   bundling: 3/3 manifests (100.00%)
-  bundling: foo/Bar/file.txt 0/3 files (0.00%)
-  bundling: foo/file.txt 1/3 files (33.33%)
-  bundling: quux/file.py 2/3 files (66.67%)
+  bundling: foo/Bar/file.txt 1/3 files (33.33%)
+  bundling: foo/file.txt 2/3 files (66.67%)
+  bundling: quux/file.py 3/3 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
@@ -1413,10 +1413,10 @@
   bundling: 2/4 manifests (50.00%)
   bundling: 3/4 manifests (75.00%)
   bundling: 4/4 manifests (100.00%)
-  bundling: abc.txt 0/4 files (0.00%)
-  bundling: foo/Bar/file.txt 1/4 files (25.00%)
-  bundling: foo/file.txt 2/4 files (50.00%)
-  bundling: quux/file.py 3/4 files (75.00%)
+  bundling: abc.txt 1/4 files (25.00%)
+  bundling: foo/Bar/file.txt 2/4 files (50.00%)
+  bundling: foo/file.txt 3/4 files (75.00%)
+  bundling: quux/file.py 4/4 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
@@ -1493,10 +1493,10 @@
   bundling: 2/4 manifests (50.00%)
   bundling: 3/4 manifests (75.00%)
   bundling: 4/4 manifests (100.00%)
-  bundling: abc.txt 0/4 files (0.00%)
-  bundling: foo/Bar/file.txt 1/4 files (25.00%)
-  bundling: foo/file.txt 2/4 files (50.00%)
-  bundling: quux/file.py 3/4 files (75.00%)
+  bundling: abc.txt 1/4 files (25.00%)
+  bundling: foo/Bar/file.txt 2/4 files (50.00%)
+  bundling: foo/file.txt 3/4 files (75.00%)
+  bundling: quux/file.py 4/4 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
@@ -1570,10 +1570,10 @@
   bundling: 2/4 manifests (50.00%)
   bundling: 3/4 manifests (75.00%)
   bundling: 4/4 manifests (100.00%)
-  bundling: abc.txt 0/4 files (0.00%)
-  bundling: foo/Bar/file.txt 1/4 files (25.00%)
-  bundling: foo/file.txt 2/4 files (50.00%)
-  bundling: quux/file.py 3/4 files (75.00%)
+  bundling: abc.txt 1/4 files (25.00%)
+  bundling: foo/Bar/file.txt 2/4 files (50.00%)
+  bundling: foo/file.txt 3/4 files (75.00%)
+  bundling: quux/file.py 4/4 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
@@ -1643,10 +1643,10 @@
   bundling: 2/4 manifests (50.00%)
   bundling: 3/4 manifests (75.00%)
   bundling: 4/4 manifests (100.00%)
-  bundling: abc.txt 0/4 files (0.00%)
-  bundling: foo/Bar/file.txt 1/4 files (25.00%)
-  bundling: foo/file.txt 2/4 files (50.00%)
-  bundling: quux/file.py 3/4 files (75.00%)
+  bundling: abc.txt 1/4 files (25.00%)
+  bundling: foo/Bar/file.txt 2/4 files (50.00%)
+  bundling: foo/file.txt 3/4 files (75.00%)
+  bundling: quux/file.py 4/4 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
@@ -1710,10 +1710,10 @@
   bundling: 2/4 manifests (50.00%)
   bundling: 3/4 manifests (75.00%)
   bundling: 4/4 manifests (100.00%)
-  bundling: abc.txt 0/4 files (0.00%)
-  bundling: foo/Bar/file.txt 1/4 files (25.00%)
-  bundling: foo/file.txt 2/4 files (50.00%)
-  bundling: quux/file.py 3/4 files (75.00%)
+  bundling: abc.txt 1/4 files (25.00%)
+  bundling: foo/Bar/file.txt 2/4 files (50.00%)
+  bundling: foo/file.txt 3/4 files (75.00%)
+  bundling: quux/file.py 4/4 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
@@ -1795,10 +1795,10 @@
   bundling: 2/4 manifests (50.00%)
   bundling: 3/4 manifests (75.00%)
   bundling: 4/4 manifests (100.00%)
-  bundling: abc.txt 0/4 files (0.00%)
-  bundling: foo/Bar/file.txt 1/4 files (25.00%)
-  bundling: foo/file.txt 2/4 files (50.00%)
-  bundling: quux/file.py 3/4 files (75.00%)
+  bundling: abc.txt 1/4 files (25.00%)
+  bundling: foo/Bar/file.txt 2/4 files (50.00%)
+  bundling: foo/file.txt 3/4 files (75.00%)
+  bundling: quux/file.py 4/4 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
@@ -1879,10 +1879,10 @@
   bundling: 2/4 manifests (50.00%)
   bundling: 3/4 manifests (75.00%)
   bundling: 4/4 manifests (100.00%)
-  bundling: abc.txt 0/4 files (0.00%)
-  bundling: foo/Bar/file.txt 1/4 files (25.00%)
-  bundling: foo/file.txt 2/4 files (50.00%)
-  bundling: quux/file.py 3/4 files (75.00%)
+  bundling: abc.txt 1/4 files (25.00%)
+  bundling: foo/Bar/file.txt 2/4 files (50.00%)
+  bundling: foo/file.txt 3/4 files (75.00%)
+  bundling: quux/file.py 4/4 files (100.00%)
   changesets: 1 chunks
   add changeset ef1ea85a6374
   changesets: 2 chunks
--- a/tests/test-bundle.t	Fri Jun 03 20:15:06 2011 +0200
+++ b/tests/test-bundle.t	Fri Jun 03 20:23:32 2011 +0200
@@ -572,6 +572,6 @@
   bundling: 2/2 changesets (100.00%)
   bundling: 1/2 manifests (50.00%)
   bundling: 2/2 manifests (100.00%)
-  bundling: b 0/2 files (0.00%)
-  bundling: b1 1/2 files (50.00%)
+  bundling: b 1/2 files (50.00%)
+  bundling: b1 2/2 files (100.00%)