# HG changeset patch
# User Augie Fackler <durin42@gmail.com>
# Date 2010-12-16 13:45:22
# Node ID e11c14f1449185ffe00a433fa2b657abb0cd376c
# Parent  dca5488f0e4fde240feae077f195522f33049caf

progress: don't compute estimate without a total

Without this, computing an estimate crashes. Test included.

diff --git a/hgext/progress.py b/hgext/progress.py
--- a/hgext/progress.py
+++ b/hgext/progress.py
@@ -183,6 +183,8 @@ class progbar(object):
         return min(int(self.ui.config('progress', 'width', default=tw)), tw)
 
     def estimate(self, topic, pos, total, now):
+        if total is None:
+            return ''
         initialpos = self.startvals[topic]
         target = total - initialpos
         delta = pos - initialpos
diff --git a/tests/test-progress.t b/tests/test-progress.t
--- a/tests/test-progress.t
+++ b/tests/test-progress.t
@@ -141,3 +141,9 @@ test delay time estimates
   loop [==============================>           ] 3/4 2h47m
                                                               \r (esc)
 
+Time estimates should not fail when there's no end point:
+  $ hg -y loop -- -4 2>&1 | python $TESTDIR/filtercr.py
+  
+  loop [ <=>                                              ] 2
+  loop [  <=>                                             ] 3
+                                                              \r (esc)