From 1b2519db256e96c3261c318387d3c7605020eb66 Mon Sep 17 00:00:00 2001 From: Brian Harring Date: Tue, 16 Oct 2012 04:55:25 -0700 Subject: tweak the progress output a bit; specifically, percentile increments --- rewrite-commit-dump.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/rewrite-commit-dump.py b/rewrite-commit-dump.py index 1df8211..8cf1f4c 100755 --- a/rewrite-commit-dump.py +++ b/rewrite-commit-dump.py @@ -168,14 +168,16 @@ def deserialize_records(source, blob_idx): # Bleh... of course namedtuple doesn't make this easy. line = source.readline() -def serialize_records(records, handle, target='refs/heads/master', progress=5000): +def serialize_records(records, handle, target='refs/heads/master', progress=100): write = handle.write write('reset %s\n' % target) total = len(records) + total_len = len(str(total)) + progress_interval = max(1, total // progress) for idx, record in enumerate(records, 1): - if idx % progress == 0: - write('progress %02.1f%%: %i of %i commits\n' - % ((100 * float(idx))/total, idx, total)) + if idx % progress_interval == 0: + write('progress %02.0f%%: %s of %i commits\n' + % ((100 * float(idx))/total, str(idx).rjust(total_len), total)) write('commit %s\n' % target) write('mark :%i\n' % idx) # fields = ('mark', 'author', 'committer', 'msg', 'files') -- cgit v1.2.3-65-gdbad