changeset 14279:b039b667515d

debugbuilddag: output progress information
author Martin Geisler <mg@aragost.com>
date Mon, 09 May 2011 14:40:49 +0200
parents 59c820a6ca79
children 98e4d3914c2e
files mercurial/commands.py tests/test-debugbuilddag.t
diffstat 2 files changed, 52 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Mon May 09 14:33:08 2011 +0200
+++ b/mercurial/commands.py	Mon May 09 14:40:49 2011 +0200
@@ -1005,15 +1005,16 @@
     if len(cl) > 0:
         raise util.Abort(_('repository is not empty'))
 
+    # determine number of revs in DAG
+    total = 0
+    for type, data in dagparser.parsedag(text):
+        if type == 'n':
+            total += 1
+
     if mergeable_file:
         linesperrev = 2
-        # determine number of revs in DAG
-        n = 0
-        for type, data in dagparser.parsedag(text):
-            if type == 'n':
-                n += 1
         # make a file with k lines per rev
-        initialmergedlines = [str(i) for i in xrange(0, n * linesperrev)]
+        initialmergedlines = [str(i) for i in xrange(0, total * linesperrev)]
         initialmergedlines.append("")
 
     tags = []
@@ -1024,6 +1025,7 @@
         at = -1
         atbranch = 'default'
         nodeids = []
+        ui.progress(_('building'), 0, unit=_('revisions'), total=total)
         for type, data in dagparser.parsedag(text):
             if type == 'n':
                 ui.note('node %s\n' % str(data))
@@ -1092,8 +1094,10 @@
             elif type == 'a':
                 ui.note('branch %s\n' % data)
                 atbranch = data
+            ui.progress(_('building'), id, unit=_('revisions'), total=total)
         tr.close()
     finally:
+        ui.progress(_('building'), None)
         tr.release()
 
     if tags:
--- a/tests/test-debugbuilddag.t	Mon May 09 14:33:08 2011 +0200
+++ b/tests/test-debugbuilddag.t	Mon May 09 14:40:49 2011 +0200
@@ -4,7 +4,48 @@
 plain
 
   $ hg init
-  $ hg debugbuilddag '+2:f +3:p2 @temp <f+4 @default /p2 +2'
+  $ hg debugbuilddag '+2:f +3:p2 @temp <f+4 @default /p2 +2' \
+  > --config extensions.progress= --config progress.assume-tty=1 \
+  > --config progress.delay=0 --config progress.refresh=0 \
+  > --config progress.width=60 2>&1 | \
+  > python $TESTDIR/filtercr.py
+  
+  building [                                          ]  0/12
+  building [                                          ]  0/12
+  building [                                          ]  0/12
+  building [                                          ]  0/12
+  building [==>                                       ]  1/12
+  building [==>                                       ]  1/12
+  building [==>                                       ]  1/12
+  building [==>                                       ]  1/12
+  building [======>                                   ]  2/12
+  building [======>                                   ]  2/12
+  building [=========>                                ]  3/12
+  building [=========>                                ]  3/12
+  building [=============>                            ]  4/12
+  building [=============>                            ]  4/12
+  building [=============>                            ]  4/12
+  building [=============>                            ]  4/12
+  building [=============>                            ]  4/12
+  building [=============>                            ]  4/12
+  building [================>                         ]  5/12
+  building [================>                         ]  5/12
+  building [====================>                     ]  6/12
+  building [====================>                     ]  6/12
+  building [=======================>                  ]  7/12
+  building [=======================>                  ]  7/12
+  building [===========================>              ]  8/12
+  building [===========================>              ]  8/12
+  building [===========================>              ]  8/12
+  building [===========================>              ]  8/12
+  building [==============================>           ]  9/12
+  building [==============================>           ]  9/12
+  building [==================================>       ] 10/12
+  building [==================================>       ] 10/12
+  building [=====================================>    ] 11/12
+  building [=====================================>    ] 11/12
+                                                              \r (esc)
+
 tags
   $ cat .hg/localtags
   66f7d451a68b85ed82ff5fcc254daf50c74144bd f