pull: try and produce a better progress bar for certain cases

This uses the first converted revision as an offset, and then uses
(r.revnum - offset) as the current item index and (HEAD - offset) as
the total so that we always show a "real" progress number for the case
where we're cloning only part of the svn repository.
This commit is contained in:
Augie Fackler 2010-03-19 21:24:03 -05:00
parent 8114ffd92c
commit 145188f746

View File

@ -256,7 +256,7 @@ def pull(repo, source, heads=[], force=False):
'remains unimplemented.')
oldrevisions = len(meta.revmap)
cnt = 0
progoffset = 0
if stopat_rev:
total = stopat_rev - start
else:
@ -283,9 +283,10 @@ def pull(repo, source, heads=[], force=False):
msg = [s.strip() for s in msg.splitlines() if s][0]
w = hgutil.termwidth()
bits = (r.revnum, r.author, msg)
cnt += 1
if not progoffset:
progoffset = r.revnum
ui.status(('[r%d] %s: %s\n' % bits)[:w])
util.progress(ui, 'pull', cnt, total=total)
util.progress(ui, 'pull', (r.revnum-progoffset), total=(total-progoffset))
meta.save_tbdelta(tbdelta)
close = pullfuns[have_replay](ui, meta, svn, r, tbdelta)
@ -313,7 +314,7 @@ def pull(repo, source, heads=[], force=False):
except KeyboardInterrupt:
pass
finally:
util.progress(ui, 'pull', None, total=total)
util.progress(ui, 'pull', None, total=(total-progoffset))
util.swap_out_encoding(old_encoding)
revisions = len(meta.revmap) - oldrevisions