[PATCH 1 of 5] localrepo: show indeterminate progress for incoming data

Augie Fackler durin42 at gmail.com
Fri Feb 12 09:37:06 CST 2010


# HG changeset patch
# User Augie Fackler <durin42 at gmail.com>
# Date 1265565640 21600
# Node ID 50f561a2b1fecc56776bd1ed8e07dfa9c07b6528
# Parent  5a3a916aad58d63e70ef141f53ade3f7c4855407
localrepo: show indeterminate progress for incoming data

This has some quirks, like showing progress bars for importing
bundles, including during rebase.

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -24,13 +24,15 @@
                           % (len(d), l - 4))
     return d
 
-def chunkiter(source):
+def chunkiter(source, progress=None):
     """iterate through the chunks in source, yielding a sequence of chunks
     (strings)"""
     while 1:
         c = getchunk(source)
         if not c:
             break
+        elif progress is not None:
+            progress()
         yield c
 
 def chunkheader(length):
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1990,20 +1990,32 @@
             # pull off the changeset group
             self.ui.status(_("adding changesets\n"))
             clstart = len(cl)
-            chunkiter = changegroup.chunkiter(source)
+            class prog(object):
+                step = 'changesets'
+                count = 1
+                ui = self.ui
+                def __call__(self):
+                    self.ui.progress(self.step, self.count, unit='chunks')
+                    self.count += 1
+            pr = prog()
+            chunkiter = changegroup.chunkiter(source, progress=pr)
             if cl.addgroup(chunkiter, csmap, trp) is None and not emptyok:
                 raise util.Abort(_("received changelog group is empty"))
             clend = len(cl)
             changesets = clend - clstart
+            self.ui.progress('changesets', None)
 
             # pull off the manifest group
             self.ui.status(_("adding manifests\n"))
-            chunkiter = changegroup.chunkiter(source)
+            pr.step = 'manifests'
+            pr.count = 1
+            chunkiter = changegroup.chunkiter(source, progress=pr)
             # no need to check for empty manifest group here:
             # if the result of the merge of 1 and 2 is the same in 3 and 4,
             # no new manifest will be created and the manifest group will
             # be empty during the pull
             self.manifest.addgroup(chunkiter, revmap, trp)
+            self.ui.progress('manifests', None)
 
             needfiles = {}
             if self.ui.configbool('server', 'validate', default=False):
@@ -2017,6 +2029,8 @@
 
             # process the files
             self.ui.status(_("adding file changes\n"))
+            pr.step = 'files'
+            pr.count = 1
             while 1:
                 f = changegroup.getchunk(source)
                 if not f:
@@ -2024,7 +2038,7 @@
                 self.ui.debug("adding %s revisions\n" % f)
                 fl = self.file(f)
                 o = len(fl)
-                chunkiter = changegroup.chunkiter(source)
+                chunkiter = changegroup.chunkiter(source, progress=pr)
                 if fl.addgroup(chunkiter, revmap, trp) is None:
                     raise util.Abort(_("received file revlog group is empty"))
                 revisions += len(fl) - o
@@ -2037,6 +2051,7 @@
                             needs.remove(n)
                     if not needs:
                         del needfiles[f]
+            self.ui.progress('files', None)
 
             for f, needs in needfiles.iteritems():
                 fl = self.file(f)
diff --git a/tests/test-acl.out b/tests/test-acl.out
--- a/tests/test-acl.out
+++ b/tests/test-acl.out
@@ -20,14 +20,23 @@
 f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
 911600dab2ae7a9baff75958b84fe606851ce955
 adding changesets
+changesets: 1 chunks
 add changeset ef1ea85a6374
+changesets: 2 chunks
 add changeset f9cafe1212c8
+changesets: 3 chunks
 add changeset 911600dab2ae
 adding manifests
+manifests: 1 chunks
+manifests: 2 chunks
+manifests: 3 chunks
 adding file changes
 adding foo/Bar/file.txt revisions
+files: 1 chunks
 adding foo/file.txt revisions
+files: 2 chunks
 adding quux/file.py revisions
+files: 3 chunks
 added 3 changesets with 3 changes to 3 files
 updating the branch cache
 rolling back last transaction
@@ -49,14 +58,23 @@
 f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
 911600dab2ae7a9baff75958b84fe606851ce955
 adding changesets
+changesets: 1 chunks
 add changeset ef1ea85a6374
+changesets: 2 chunks
 add changeset f9cafe1212c8
+changesets: 3 chunks
 add changeset 911600dab2ae
 adding manifests
+manifests: 1 chunks
+manifests: 2 chunks
+manifests: 3 chunks
 adding file changes
 adding foo/Bar/file.txt revisions
+files: 1 chunks
 adding foo/file.txt revisions
+files: 2 chunks
 adding quux/file.py revisions
+files: 3 chunks
 added 3 changesets with 3 changes to 3 files
 calling hook pretxnchangegroup.acl: hgext.acl.hook
 acl: changes have source "push" - skipping
@@ -82,14 +100,23 @@
 f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
 911600dab2ae7a9baff75958b84fe606851ce955
 adding changesets
+changesets: 1 chunks
 add changeset ef1ea85a6374
+changesets: 2 chunks
 add changeset f9cafe1212c8
+changesets: 3 chunks
 add changeset 911600dab2ae
 adding manifests
+manifests: 1 chunks
+manifests: 2 chunks
+manifests: 3 chunks
 adding file changes
 adding foo/Bar/file.txt revisions
+files: 1 chunks
 adding foo/file.txt revisions
+files: 2 chunks
 adding quux/file.py revisions
+files: 3 chunks
 added 3 changesets with 3 changes to 3 files
 calling hook pretxnchangegroup.acl: hgext.acl.hook
 acl: acl.allow not enabled
@@ -120,14 +147,23 @@
 f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
 911600dab2ae7a9baff75958b84fe606851ce955
 adding changesets
+changesets: 1 chunks
 add changeset ef1ea85a6374
+changesets: 2 chunks
 add changeset f9cafe1212c8
+changesets: 3 chunks
 add changeset 911600dab2ae
 adding manifests
+manifests: 1 chunks
+manifests: 2 chunks
+manifests: 3 chunks
 adding file changes
 adding foo/Bar/file.txt revisions
+files: 1 chunks
 adding foo/file.txt revisions
+files: 2 chunks
 adding quux/file.py revisions
+files: 3 chunks
 added 3 changesets with 3 changes to 3 files
 calling hook pretxnchangegroup.acl: hgext.acl.hook
 acl: acl.allow enabled, 0 entries for user fred
@@ -159,14 +195,23 @@
 f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
 911600dab2ae7a9baff75958b84fe606851ce955
 adding changesets
+changesets: 1 chunks
 add changeset ef1ea85a6374
+changesets: 2 chunks
 add changeset f9cafe1212c8
+changesets: 3 chunks
 add changeset 911600dab2ae
 adding manifests
+manifests: 1 chunks
+manifests: 2 chunks
+manifests: 3 chunks
 adding file changes
 adding foo/Bar/file.txt revisions
+files: 1 chunks
 adding foo/file.txt revisions
+files: 2 chunks
 adding quux/file.py revisions
+files: 3 chunks
 added 3 changesets with 3 changes to 3 files
 calling hook pretxnchangegroup.acl: hgext.acl.hook
 acl: acl.allow enabled, 1 entries for user fred
@@ -201,14 +246,23 @@
 f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
 911600dab2ae7a9baff75958b84fe606851ce955
 adding changesets
+changesets: 1 chunks
 add changeset ef1ea85a6374
+changesets: 2 chunks
 add changeset f9cafe1212c8
+changesets: 3 chunks
 add changeset 911600dab2ae
 adding manifests
+manifests: 1 chunks
+manifests: 2 chunks
+manifests: 3 chunks
 adding file changes
 adding foo/Bar/file.txt revisions
+files: 1 chunks
 adding foo/file.txt revisions
+files: 2 chunks
 adding quux/file.py revisions
+files: 3 chunks
 added 3 changesets with 3 changes to 3 files
 calling hook pretxnchangegroup.acl: hgext.acl.hook
 acl: acl.allow enabled, 0 entries for user barney
@@ -242,14 +296,23 @@
 f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
 911600dab2ae7a9baff75958b84fe606851ce955
 adding changesets
+changesets: 1 chunks
 add changeset ef1ea85a6374
+changesets: 2 chunks
 add changeset f9cafe1212c8
+changesets: 3 chunks
 add changeset 911600dab2ae
 adding manifests
+manifests: 1 chunks
+manifests: 2 chunks
+manifests: 3 chunks
 adding file changes
 adding foo/Bar/file.txt revisions
+files: 1 chunks
 adding foo/file.txt revisions
+files: 2 chunks
 adding quux/file.py revisions
+files: 3 chunks
 added 3 changesets with 3 changes to 3 files
 calling hook pretxnchangegroup.acl: hgext.acl.hook
 acl: acl.allow enabled, 1 entries for user fred
@@ -286,14 +349,23 @@
 f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
 911600dab2ae7a9baff75958b84fe606851ce955
 adding changesets
+changesets: 1 chunks
 add changeset ef1ea85a6374
+changesets: 2 chunks
 add changeset f9cafe1212c8
+changesets: 3 chunks
 add changeset 911600dab2ae
 adding manifests
+manifests: 1 chunks
+manifests: 2 chunks
+manifests: 3 chunks
 adding file changes
 adding foo/Bar/file.txt revisions
+files: 1 chunks
 adding foo/file.txt revisions
+files: 2 chunks
 adding quux/file.py revisions
+files: 3 chunks
 added 3 changesets with 3 changes to 3 files
 calling hook pretxnchangegroup.acl: hgext.acl.hook
 acl: acl.allow enabled, 1 entries for user fred
@@ -329,14 +401,23 @@
 f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
 911600dab2ae7a9baff75958b84fe606851ce955
 adding changesets
+changesets: 1 chunks
 add changeset ef1ea85a6374
+changesets: 2 chunks
 add changeset f9cafe1212c8
+changesets: 3 chunks
 add changeset 911600dab2ae
 adding manifests
+manifests: 1 chunks
+manifests: 2 chunks
+manifests: 3 chunks
 adding file changes
 adding foo/Bar/file.txt revisions
+files: 1 chunks
 adding foo/file.txt revisions
+files: 2 chunks
 adding quux/file.py revisions
+files: 3 chunks
 added 3 changesets with 3 changes to 3 files
 calling hook pretxnchangegroup.acl: hgext.acl.hook
 acl: acl.allow enabled, 0 entries for user barney
@@ -373,14 +454,23 @@
 f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
 911600dab2ae7a9baff75958b84fe606851ce955
 adding changesets
+changesets: 1 chunks
 add changeset ef1ea85a6374
+changesets: 2 chunks
 add changeset f9cafe1212c8
+changesets: 3 chunks
 add changeset 911600dab2ae
 adding manifests
+manifests: 1 chunks
+manifests: 2 chunks
+manifests: 3 chunks
 adding file changes
 adding foo/Bar/file.txt revisions
+files: 1 chunks
 adding foo/file.txt revisions
+files: 2 chunks
 adding quux/file.py revisions
+files: 3 chunks
 added 3 changesets with 3 changes to 3 files
 calling hook pretxnchangegroup.acl: hgext.acl.hook
 acl: acl.allow enabled, 1 entries for user barney
@@ -418,14 +508,23 @@
 f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
 911600dab2ae7a9baff75958b84fe606851ce955
 adding changesets
+changesets: 1 chunks
 add changeset ef1ea85a6374
+changesets: 2 chunks
 add changeset f9cafe1212c8
+changesets: 3 chunks
 add changeset 911600dab2ae
 adding manifests
+manifests: 1 chunks
+manifests: 2 chunks
+manifests: 3 chunks
 adding file changes
 adding foo/Bar/file.txt revisions
+files: 1 chunks
 adding foo/file.txt revisions
+files: 2 chunks
 adding quux/file.py revisions
+files: 3 chunks
 added 3 changesets with 3 changes to 3 files
 calling hook pretxnchangegroup.acl: hgext.acl.hook
 acl: acl.allow enabled, 1 entries for user wilma
@@ -467,14 +566,23 @@
 f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
 911600dab2ae7a9baff75958b84fe606851ce955
 adding changesets
+changesets: 1 chunks
 add changeset ef1ea85a6374
+changesets: 2 chunks
 add changeset f9cafe1212c8
+changesets: 3 chunks
 add changeset 911600dab2ae
 adding manifests
+manifests: 1 chunks
+manifests: 2 chunks
+manifests: 3 chunks
 adding file changes
 adding foo/Bar/file.txt revisions
+files: 1 chunks
 adding foo/file.txt revisions
+files: 2 chunks
 adding quux/file.py revisions
+files: 3 chunks
 added 3 changesets with 3 changes to 3 files
 calling hook pretxnchangegroup.acl: hgext.acl.hook
 error: pretxnchangegroup.acl hook raised an exception: [Errno 2] No such file or directory: '../acl.config'
@@ -515,14 +623,23 @@
 f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
 911600dab2ae7a9baff75958b84fe606851ce955
 adding changesets
+changesets: 1 chunks
 add changeset ef1ea85a6374
+changesets: 2 chunks
 add changeset f9cafe1212c8
+changesets: 3 chunks
 add changeset 911600dab2ae
 adding manifests
+manifests: 1 chunks
+manifests: 2 chunks
+manifests: 3 chunks
 adding file changes
 adding foo/Bar/file.txt revisions
+files: 1 chunks
 adding foo/file.txt revisions
+files: 2 chunks
 adding quux/file.py revisions
+files: 3 chunks
 added 3 changesets with 3 changes to 3 files
 calling hook pretxnchangegroup.acl: hgext.acl.hook
 acl: acl.allow enabled, 1 entries for user betty
@@ -570,14 +687,23 @@
 f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
 911600dab2ae7a9baff75958b84fe606851ce955
 adding changesets
+changesets: 1 chunks
 add changeset ef1ea85a6374
+changesets: 2 chunks
 add changeset f9cafe1212c8
+changesets: 3 chunks
 add changeset 911600dab2ae
 adding manifests
+manifests: 1 chunks
+manifests: 2 chunks
+manifests: 3 chunks
 adding file changes
 adding foo/Bar/file.txt revisions
+files: 1 chunks
 adding foo/file.txt revisions
+files: 2 chunks
 adding quux/file.py revisions
+files: 3 chunks
 added 3 changesets with 3 changes to 3 files
 calling hook pretxnchangegroup.acl: hgext.acl.hook
 acl: acl.allow enabled, 1 entries for user barney


More information about the Mercurial-devel mailing list