relink/progress: Adding progress for collecting stage
timeless
timeless at gmail.com
Thu Jun 10 08:40:18 CDT 2010
That patch applies to a well known number, this progress is more wishywashy.
I expect mozilla will continue to grow both dead and alive files, so I
think using 3:2 is better than overflowing 7:5.
# HG changeset patch
# User timeless <timeless at gmail.com>
# Date 1276176906 -7200
# Node ID 6183853310e779afe413b11308a07b62ebd1983b
# Parent cdc2f94f0fa97e8bae74dc456cd62a4f9ef21080
relink/progress: Adding progress for collecting stage
diff --git a/hgext/relink.py b/hgext/relink.py
--- a/hgext/relink.py
+++ b/hgext/relink.py
@@ -48,7 +48,7 @@ def relink(ui, repo, origin=None, **opts
try:
remotelock = src.lock()
try:
- candidates = sorted(collect(src.store.path, ui))
+ candidates = sorted(collect(src, ui))
targets = prune(candidates, src.store.path, repo.store.path, ui)
do_relink(src.store.path, repo.store.path, targets, ui)
finally:
@@ -59,16 +59,29 @@ def relink(ui, repo, origin=None, **opts
def collect(src, ui):
seplen = len(os.path.sep)
candidates = []
+ total = len(src['tip'].manifest())
+ # Your average repository has some files which were deleted before the
+ # tip revision, we account for that by assuming that there are 3 tracked
+ # files for every 2 live files as of the tip version of the repository.
+ #
+ # mozilla-central as of 2010-06-10 had a ratio of just over 7:5.
+ total *= 3
+ total /= 2
+ src = src.store.path
+ pos = 0
for dirpath, dirnames, filenames in os.walk(src):
relpath = dirpath[len(src) + seplen:]
for filename in filenames:
+ pos += 1
if not filename[-2:] in ('.d', '.i'):
continue
st = os.stat(os.path.join(dirpath, filename))
if not stat.S_ISREG(st.st_mode):
continue
candidates.append((os.path.join(relpath, filename), st))
+ ui.progress(_('collecting'), pos, filename, _(' files'), total)
+ ui.progress(_('collecting'), None)
ui.status(_('collected %d candidate storage files\n') % len(candidates))
return candidates
More information about the Mercurial-devel
mailing list