[PATCH 2 of 2] Use progress indicators for update and pull (and clone)
Stefano Tortarolo
stefano.tortarolo at gmail.com
Thu Dec 11 16:25:35 CST 2008
# HG changeset patch
# User Stefano Tortarolo <stefano.tortarolo at gmail.com>
# Date 1229025406 -3600
# Node ID 99faaf926b5908f971e9f4442d4cc9ef9b77bebe
# Parent 5ab5ab5dca0b666901f6c31c56005ae9cfabee89
Use progress indicators for update and pull (and clone)
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1982,6 +1982,17 @@
def revmap(x):
return cl.rev(x)
+ class chunker:
+ def __init__(self, iterator):
+ self._iterator = iterator
+
+ def __iter__(self):
+ return self
+
+ def next(self):
+ progress.update()
+ return self._iterator.next()
+
if not source:
return 0
@@ -1999,25 +2010,27 @@
try:
trp = weakref.proxy(tr)
# pull off the changeset group
- self.ui.status(_("adding changesets\n"))
+ progress = self.ui.progress(_("adding changesets"), showmsg=True)
cor = len(cl) - 1
- chunkiter = changegroup.chunkiter(source)
+ chunkiter = chunker(changegroup.chunkiter(source))
if cl.addgroup(chunkiter, csmap, trp) is None and not emptyok:
raise util.Abort(_("received changelog group is empty"))
+ progress.finish()
cnr = len(cl) - 1
changesets = cnr - cor
# pull off the manifest group
- self.ui.status(_("adding manifests\n"))
- chunkiter = changegroup.chunkiter(source)
+ progress = self.ui.progress(_("adding manifests"), showmsg=True)
+ chunkiter = chunker(changegroup.chunkiter(source))
# 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)
+ progress.finish()
# process the files
- self.ui.status(_("adding file changes\n"))
+ progress = self.ui.progress(_("adding file changes"), showmsg=True)
while 1:
f = changegroup.getchunk(source)
if not f:
@@ -2025,11 +2038,12 @@
self.ui.debug(_("adding %s revisions\n") % f)
fl = self.file(f)
o = len(fl)
- chunkiter = changegroup.chunkiter(source)
+ chunkiter = chunker(changegroup.chunkiter(source))
if fl.addgroup(chunkiter, revmap, trp) is None:
raise util.Abort(_("received file revlog group is empty"))
revisions += len(fl) - o
files += 1
+ progress.finish()
# make changelog see real files again
cl.finalize(trp)
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -300,6 +300,7 @@
audit_path = util.path_auditor(repo.root)
+ progress = repo.ui.progress(_("updating"), maxval=len(action))
for a in action:
f, m = a[:2]
if f and f[0] == "/":
@@ -354,7 +355,8 @@
elif m == "e": # exec
flags = a[2]
util.set_flags(repo.wjoin(f), 'l' in flags, 'x' in flags)
-
+ progress.update()
+ progress.finish()
return updated, merged, removed, unresolved
def recordupdates(repo, action, branchmerge):
More information about the Mercurial-devel
mailing list