[Pkg-bazaar-commits] ./bzr/unstable r894: - small optimization for weave extract

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


------------------------------------------------------------
revno: 894
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Mon 2005-07-11 15:45:11 +1000
message:
  - small optimization for weave extract
  
  - show progressbar during weave check
modified:
  bzrlib/weave.py
-------------- next part --------------
=== modified file 'bzrlib/weave.py'
--- a/bzrlib/weave.py	2005-07-11 04:53:07 +0000
+++ b/bzrlib/weave.py	2005-07-11 05:45:11 +0000
@@ -326,35 +326,33 @@
 
         lineno = 0         # line of weave, 0-based
 
-        isactive = False
+        isactive = None
 
         WFE = WeaveFormatError
 
         for l in self._l:
             if isinstance(l, tuple):
                 c, v = l
+                isactive = None
                 if c == '{':
                     assert v not in istack
                     istack.append(v)
-                    if not dset:
-                        isactive = (v in included)
                 elif c == '}':
                     oldv = istack.pop()
                     assert oldv == v
-                    isactive = (not dset) and (istack and istack[-1] in included)
                 elif c == '[':
                     if v in included:
                         assert v not in dset
                         dset.add(v)
-                        isactive = False
                 else:
                     assert c == ']'
                     if v in included:
                         assert v in dset
                         dset.remove(v)
-                        isactive = (not dset) and (istack and istack[-1] in included)
             else:
                 assert isinstance(l, basestring)
+                if isactive is None:
+                    isactive = (not dset) and istack and (istack[-1] in included)
                 if isactive:
                     yield istack[-1], lineno, l
             lineno += 1
@@ -399,7 +397,7 @@
         return l
 
 
-    def check(self):
+    def check(self, progress_bar=None):
         # check no circular inclusions
         for version in range(self.numversions()):
             inclusions = list(self._v[version])
@@ -412,7 +410,10 @@
         # try extracting all versions; this is a bit slow and parallel
         # extraction could be used
         import sha
-        for version in range(self.numversions()):
+        nv = self.numversions()
+        for version in range(nv):
+            if progress_bar:
+                progress_bar.update('checking text', version, nv)
             s = sha.new()
             for l in self.get_iter(version):
                 s.update(l)
@@ -586,6 +587,11 @@
     import sys
     import os
     from weavefile import write_weave, read_weave
+    from bzrlib.progress import ProgressBar
+
+    #import psyco
+    #psyco.full()
+
     cmd = argv[1]
 
     def readit():
@@ -633,7 +639,9 @@
         
     elif cmd == 'check':
         w = readit()
-        w.check()
+        pb = ProgressBar()
+        w.check(pb)
+        pb.clear()
 
     elif cmd == 'inclusions':
         w = readit()



More information about the Pkg-bazaar-commits mailing list