~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/weave.py

  • Committer: Martin Pool
  • Date: 2005-07-11 05:45:11 UTC
  • Revision ID: mbp@sourcefrog.net-20050711054511-aab2162e0f02dc64
- small optimization for weave extract

- show progressbar during weave check

Show diffs side-by-side

added added

removed removed

Lines of Context:
326
326
 
327
327
        lineno = 0         # line of weave, 0-based
328
328
 
329
 
        isactive = False
 
329
        isactive = None
330
330
 
331
331
        WFE = WeaveFormatError
332
332
 
333
333
        for l in self._l:
334
334
            if isinstance(l, tuple):
335
335
                c, v = l
 
336
                isactive = None
336
337
                if c == '{':
337
338
                    assert v not in istack
338
339
                    istack.append(v)
339
 
                    if not dset:
340
 
                        isactive = (v in included)
341
340
                elif c == '}':
342
341
                    oldv = istack.pop()
343
342
                    assert oldv == v
344
 
                    isactive = (not dset) and (istack and istack[-1] in included)
345
343
                elif c == '[':
346
344
                    if v in included:
347
345
                        assert v not in dset
348
346
                        dset.add(v)
349
 
                        isactive = False
350
347
                else:
351
348
                    assert c == ']'
352
349
                    if v in included:
353
350
                        assert v in dset
354
351
                        dset.remove(v)
355
 
                        isactive = (not dset) and (istack and istack[-1] in included)
356
352
            else:
357
353
                assert isinstance(l, basestring)
 
354
                if isactive is None:
 
355
                    isactive = (not dset) and istack and (istack[-1] in included)
358
356
                if isactive:
359
357
                    yield istack[-1], lineno, l
360
358
            lineno += 1
399
397
        return l
400
398
 
401
399
 
402
 
    def check(self):
 
400
    def check(self, progress_bar=None):
403
401
        # check no circular inclusions
404
402
        for version in range(self.numversions()):
405
403
            inclusions = list(self._v[version])
412
410
        # try extracting all versions; this is a bit slow and parallel
413
411
        # extraction could be used
414
412
        import sha
415
 
        for version in range(self.numversions()):
 
413
        nv = self.numversions()
 
414
        for version in range(nv):
 
415
            if progress_bar:
 
416
                progress_bar.update('checking text', version, nv)
416
417
            s = sha.new()
417
418
            for l in self.get_iter(version):
418
419
                s.update(l)
586
587
    import sys
587
588
    import os
588
589
    from weavefile import write_weave, read_weave
 
590
    from bzrlib.progress import ProgressBar
 
591
 
 
592
    #import psyco
 
593
    #psyco.full()
 
594
 
589
595
    cmd = argv[1]
590
596
 
591
597
    def readit():
633
639
        
634
640
    elif cmd == 'check':
635
641
        w = readit()
636
 
        w.check()
 
642
        pb = ProgressBar()
 
643
        w.check(pb)
 
644
        pb.clear()
637
645
 
638
646
    elif cmd == 'inclusions':
639
647
        w = readit()