[Pkg-bazaar-commits] ./bzr/unstable r889: - show progress bar during inventory conversion to weave, and make profiling optional

Martin Pool mbp at sourcefrog.net
Fri Apr 10 08:21:21 UTC 2009


------------------------------------------------------------
revno: 889
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Mon 2005-07-11 13:49:54 +1000
message:
  - show progress bar during inventory conversion to weave, and make profiling optional
modified:
  bzrlib/progress.py
  tools/convertinv.py
-------------- next part --------------
=== modified file 'bzrlib/progress.py'
--- a/bzrlib/progress.py	2005-06-17 07:34:04 +0000
+++ b/bzrlib/progress.py	2005-07-11 03:49:54 +0000
@@ -16,10 +16,7 @@
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 
-"""
-Simple text-mode progress indicator.
-
-Everyone loves ascii art!
+"""Simple text-mode progress indicator.
 
 To display an indicator, create a ProgressBar object.  Call it,
 passing Progress objects indicating the current state.  When done,

=== modified file 'tools/convertinv.py'
--- a/tools/convertinv.py	2005-07-11 03:45:21 +0000
+++ b/tools/convertinv.py	2005-07-11 03:49:54 +0000
@@ -22,45 +22,55 @@
 import bzrlib.branch
 from bzrlib.weave import Weave
 from bzrlib.weavefile import write_weave
+from bzrlib.progress import ProgressBar
 import tempfile
 import hotshot
+import sys
 
 def convert():
     WEAVE_NAME = "inventory.weave"
 
+    pb = ProgressBar()
+
     wf = Weave()
 
     b = bzrlib.branch.find_branch('.')
 
-    print 'converting...'
-
     parents = set()
     revno = 1
-    for rev_id in b.revision_history():
-        print revno
+    rev_history = b.revision_history()
+    for rev_id in rev_history:
+        pb.update('converting inventory', revno, len(rev_history))
         inv_xml = b.inventory_store[rev_id].readlines()
         weave_id = wf.add(parents, inv_xml)
         parents.add(weave_id)
         revno += 1
 
+    pb.update('write weave', None, None)
     write_weave(wf, file(WEAVE_NAME, 'wb'))
 
-
-
-
-prof_f = tempfile.NamedTemporaryFile()
-
-prof = hotshot.Profile(prof_f.name)
-
-prof.runcall(convert) 
-prof.close()
-
-import hotshot.stats
-stats = hotshot.stats.load(prof_f.name)
-#stats.strip_dirs()
-stats.sort_stats('time')
-## XXX: Might like to write to stderr or the trace file instead but
-## print_stats seems hardcoded to stdout
-stats.print_stats(20)
+    pb.clear()
+
+
+def profile_convert(): 
+    prof_f = tempfile.NamedTemporaryFile()
+
+    prof = hotshot.Profile(prof_f.name)
+
+    prof.runcall(convert) 
+    prof.close()
+
+    import hotshot.stats
+    stats = hotshot.stats.load(prof_f.name)
+    #stats.strip_dirs()
+    stats.sort_stats('time')
+    ## XXX: Might like to write to stderr or the trace file instead but
+    ## print_stats seems hardcoded to stdout
+    stats.print_stats(20)
             
 
+if '-p' in sys.argv[1:]:
+    profile_convert()
+else:
+    convert()
+    



More information about the Pkg-bazaar-commits mailing list