Mercurial > hg
changeset 11355:9011036ba79d
relink/progress: Adding progress for collecting stage
author | timeless <timeless@gmail.com> |
---|---|
date | Thu, 10 Jun 2010 15:35:06 +0200 |
parents | 412a6e749f8d |
children | 511445840148 |
files | hgext/relink.py tests/test-relink.out |
diffstat | 2 files changed, 22 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/relink.py Thu Jun 10 13:09:50 2010 +0200 +++ b/hgext/relink.py Thu Jun 10 15:35:06 2010 +0200 @@ -48,7 +48,7 @@ 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,6 +59,18 @@ def collect(src, ui): seplen = len(os.path.sep) candidates = [] + live = 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 = live * 3 // 2 + src = src.store.path + pos = 0 + ui.status(_("tip has %d files, estimated total number of files: %s\n") + % (live, total)) for dirpath, dirnames, filenames in os.walk(src): relpath = dirpath[len(src) + seplen:] for filename in filenames: @@ -67,8 +79,11 @@ st = os.stat(os.path.join(dirpath, filename)) if not stat.S_ISREG(st.st_mode): continue + pos += 1 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
--- a/tests/test-relink.out Thu Jun 10 13:09:50 2010 +0200 +++ b/tests/test-relink.out Thu Jun 10 15:35:06 2010 +0200 @@ -12,6 +12,12 @@ created new head % relink relinking .hg/store +tip has 2 files, estimated total number of files: 3 +collecting: 00changelog.i 1/3 files (33.33%) +collecting: 00manifest.i 2/3 files (66.67%) +collecting: dummy.i 3/3 files (100.00%) +collecting: b.i 4/3 files (133.33%) +collecting: a.i 5/3 files (166.67%) collected 5 candidate storage files not linkable: 00changelog.i not linkable: 00manifest.i