diff mercurial/localrepo.py @ 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 e7a1814854b9
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)