progress: don't compute estimate without a total
authorAugie Fackler <durin42@gmail.com>
Thu, 16 Dec 2010 07:45:22 -0600
changeset 13154 e11c14f14491
parent 13153 dca5488f0e4f
child 13155 f02d7a562a21
progress: don't compute estimate without a total Without this, computing an estimate crashes. Test included.
hgext/progress.py
tests/test-progress.t
--- a/hgext/progress.py	Tue Dec 14 21:58:13 2010 -0500
+++ b/hgext/progress.py	Thu Dec 16 07:45:22 2010 -0600
@@ -183,6 +183,8 @@
         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
--- a/tests/test-progress.t	Tue Dec 14 21:58:13 2010 -0500
+++ b/tests/test-progress.t	Thu Dec 16 07:45:22 2010 -0600
@@ -141,3 +141,9 @@
   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)