remote-bzr: fix for disappeared revisions

It's possible that the previous tip goes away, we should not assume it's
always present. Fortunately we are only using it to calculate the
progress to display to the user, so only that needs to be fixed.

Also, add a test that triggers this issue.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Felipe Contreras
2013-05-07 18:39:35 -05:00
committed by Junio C Hamano
parent 3b892dc828
commit 435f39a3e8
2 changed files with 49 additions and 4 deletions

View File

@ -282,9 +282,13 @@ def export_branch(repo, name):
branch.lock_read()
revs = branch.iter_merge_sorted_revisions(None, tip, 'exclude', 'forward')
tip_revno = branch.revision_id_to_revno(tip)
last_revno, _ = branch.last_revision_info()
total = last_revno - tip_revno
try:
tip_revno = branch.revision_id_to_revno(tip)
last_revno, _ = branch.last_revision_info()
total = last_revno - tip_revno
except bzrlib.errors.NoSuchRevision:
tip_revno = 0
total = 0
for revid, _, seq, _ in revs:
@ -353,7 +357,10 @@ def export_branch(repo, name):
progress = (revno - tip_revno)
if (progress % 100 == 0):
print "progress revision %d '%s' (%d/%d)" % (revno, name, progress, total)
if total:
print "progress revision %d '%s' (%d/%d)" % (revno, name, progress, total)
else:
print "progress revision %d '%s' (%d)" % (revno, name, progress)
branch.unlock()