~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/weave.py

Lots of updates for 'bzr check'
Added get_sha1() to Weave, 
Updated RevisionTree so that it takes a Branch 
(thus it can use get_transaction()),
changed 'bzr check' so that it uses Weave.check(),
rather than having each file extract its own text

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
# the possible relationships.
68
68
 
69
69
 
 
70
import os
70
71
import sha
71
72
from difflib import SequenceMatcher
72
73
 
586
587
    get = get_lines
587
588
 
588
589
 
 
590
    def get_sha1(self, name):
 
591
        """Get the stored sha1 sum for the given revision.
 
592
        
 
593
        :param name: The name of the version to lookup
 
594
        """
 
595
        return self._sha1s[self.lookup(name)]
 
596
 
589
597
    def mash_iter(self, included):
590
598
        """Return composed version of multiple included versions."""
591
599
        included = map(self.maybe_lookup, included)
627
635
        texts = [[] for i in range(nv)]
628
636
        inclusions = []
629
637
        for i in range(nv):
630
 
            if progress_bar:
631
 
                progress_bar.update('determining ancestry', i, nv)
632
638
            # For creating the ancestry, IntSet is much faster (3.7s vs 0.17s)
633
639
            # The problem is that set membership is much more expensive
634
640
            new_inc = set([i])
639
645
            inclusions.append(new_inc)
640
646
 
641
647
        nlines = len(self._weave)
 
648
 
 
649
        update_text = 'checking weave'
 
650
        if self._weave_name:
 
651
            short_name = os.path.basename(self._weave_name)
 
652
            update_text = 'checking %s' % (short_name,)
 
653
            update_text = update_text[:25]
 
654
 
642
655
        for lineno, insert, deleteset, line in self._walk():
643
656
            if progress_bar:
644
 
                progress_bar.update('processing line', lineno, nlines)
 
657
                progress_bar.update(update_text, lineno, nlines)
645
658
 
646
659
            for j, j_inc in enumerate(inclusions):
647
660
                # The active inclusion must be an ancestor,
651
664
                    sha1s[j].update(line)
652
665
 
653
666
        for version in range(nv):
654
 
            if progress_bar:
655
 
                progress_bar.update('checking text', version, nv)
656
667
            hd = sha1s[version].hexdigest()
657
668
            expected = self._sha1s[version]
658
669
            if hd != expected: