[PATCH 2 of 8] bundle progress: offer best-guess deterministic progress information

Augie Fackler durin42 at gmail.com
Thu Dec 9 17:41:02 CST 2010


# HG changeset patch
# User Augie Fackler <durin42 at gmail.com>
# Date 1291935948 21600
# Node ID 130377d187a10fdc2f55ad8957ef1b7becada7fa
# Parent  a6a1d02d1d1ad2d936a8a8324b5bb814d6bab480
bundle progress: offer best-guess deterministic progress information

This uses the same strategy as progress for pulls, estimating manifests
based on changeset count and estimating file count by files list in
each changeset.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1505,7 +1505,9 @@
             group = cl.group(msng_cl_lst, identity, collect)
             for cnt, chnk in enumerate(group):
                 yield chnk
-                self.ui.progress(_('bundling changes'), cnt, unit=_('chunks'))
+                self.ui.progress(_('bundling changes'), cnt/3,
+                                 unit=_('changesets'))
+            changecount = cnt/3
             self.ui.progress(_('bundling changes'), None)
 
             prune(mnfst, msng_mnfst_set)
@@ -1518,10 +1520,16 @@
             group = mnfst.group(msng_mnfst_lst,
                                 lambda mnode: msng_mnfst_set[mnode],
                                 filenode_collector(changedfiles))
+            efiles = {}
             for cnt, chnk in enumerate(group):
+                if cnt % 3 == 1:
+                    mnode = chnk[:20]
+                    efiles.update(self.manifest.readdelta(mnode))
                 yield chnk
-                self.ui.progress(_('bundling manifests'), cnt, unit=_('chunks'))
+                self.ui.progress(_('bundling manifests'), cnt/3,
+                                 unit=_('manifests'), total=changecount)
             self.ui.progress(_('bundling manifests'), None)
+            efiles = len(efiles)
 
             # These are no longer needed, dereference and toss the memory for
             # them.
@@ -1535,8 +1543,7 @@
                     msng_filenode_set.setdefault(fname, {})
                     changedfiles.add(fname)
             # Go through all our files in order sorted by name.
-            cnt = 0
-            for fname in sorted(changedfiles):
+            for idx, fname in enumerate(sorted(changedfiles)):
                 filerevlog = self.file(fname)
                 if not len(filerevlog):
                     raise util.Abort(_("empty or missing revlog for %s") % fname)
@@ -1559,9 +1566,12 @@
                     group = filerevlog.group(nodeiter,
                                              lambda fnode: missingfnodes[fnode])
                     for chnk in group:
+                        # even though we print the same progress on
+                        # most loop iterations, put the progress call
+                        # here so that time estimates (if any) can be updated
                         self.ui.progress(
-                            _('bundling files'), cnt, item=fname, unit=_('chunks'))
-                        cnt += 1
+                            _('bundling files'), idx, item=fname,
+                            unit=_('files'), total=efiles)
                         yield chnk
             # Signal that no more groups are left.
             yield changegroup.closechunk()


More information about the Mercurial-devel mailing list