/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/weave.py

  • Committer: Aaron Bentley
  • Date: 2006-05-20 17:51:13 UTC
  • mfrom: (1718 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1727.
  • Revision ID: aaron.bentley@utoronto.ca-20060520175113-4549e0023f9210bf
Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
470
470
        """
471
471
 
472
472
        assert isinstance(version_id, basestring)
 
473
        self._check_lines_not_unicode(lines)
 
474
        self._check_lines_are_lines(lines)
473
475
        if not sha1:
474
476
            sha1 = sha_strings(lines)
475
477
        if version_id in self._name_map:
717
719
            raise WeaveFormatError("unclosed deletion blocks at end of weave: %s"
718
720
                                   % dset)
719
721
 
 
722
    def plan_merge(self, ver_a, ver_b):
 
723
        """Return pseudo-annotation indicating how the two versions merge.
 
724
 
 
725
        This is computed between versions a and b and their common
 
726
        base.
 
727
 
 
728
        Weave lines present in none of them are skipped entirely.
 
729
        """
 
730
        inc_a = set(self.get_ancestry([ver_a]))
 
731
        inc_b = set(self.get_ancestry([ver_b]))
 
732
        inc_c = inc_a & inc_b
 
733
 
 
734
        for lineno, insert, deleteset, line in\
 
735
            self.walk([ver_a, ver_b]):
 
736
            if deleteset & inc_c:
 
737
                # killed in parent; can't be in either a or b
 
738
                # not relevant to our work
 
739
                yield 'killed-base', line
 
740
            elif insert in inc_c:
 
741
                # was inserted in base
 
742
                killed_a = bool(deleteset & inc_a)
 
743
                killed_b = bool(deleteset & inc_b)
 
744
                if killed_a and killed_b:
 
745
                    yield 'killed-both', line
 
746
                elif killed_a:
 
747
                    yield 'killed-a', line
 
748
                elif killed_b:
 
749
                    yield 'killed-b', line
 
750
                else:
 
751
                    yield 'unchanged', line
 
752
            elif insert in inc_a:
 
753
                if deleteset & inc_a:
 
754
                    yield 'ghost-a', line
 
755
                else:
 
756
                    # new in A; not in B
 
757
                    yield 'new-a', line
 
758
            elif insert in inc_b:
 
759
                if deleteset & inc_b:
 
760
                    yield 'ghost-b', line
 
761
                else:
 
762
                    yield 'new-b', line
 
763
            else:
 
764
                # not in either revision
 
765
                yield 'irrelevant', line
 
766
 
 
767
        yield 'unchanged', ''           # terminator
 
768
 
720
769
    def _extract(self, versions):
721
770
        """Yield annotation of lines in included set.
722
771
 
846
895
                       expected_sha1, measured_sha1))
847
896
        return result
848
897
 
849
 
    def get_sha1(self, name):
850
 
        """Get the stored sha1 sum for the given revision.
851
 
        
852
 
        :param name: The name of the version to lookup
853
 
        """
854
 
        return self._sha1s[self._lookup(name)]
 
898
    def get_sha1(self, version_id):
 
899
        """See VersionedFile.get_sha1()."""
 
900
        return self._sha1s[self._lookup(version_id)]
855
901
 
856
902
    @deprecated_method(zero_eight)
857
903
    def numversions(self):
938
984
        if not other.versions():
939
985
            return          # nothing to update, easy
940
986
 
941
 
        if version_ids:
942
 
            for version_id in version_ids:
943
 
                if not other.has_version(version_id) and not ignore_missing:
944
 
                    raise RevisionNotPresent(version_id, self._weave_name)
945
 
        else:
946
 
            version_ids = other.versions()
 
987
        if not version_ids:
 
988
            # versions is never none, InterWeave checks this.
 
989
            return 0
947
990
 
948
991
        # two loops so that we do not change ourselves before verifying it
949
992
        # will be ok
1425
1468
class InterWeave(InterVersionedFile):
1426
1469
    """Optimised code paths for weave to weave operations."""
1427
1470
    
1428
 
    _matching_file_factory = staticmethod(WeaveFile)
 
1471
    _matching_file_from_factory = staticmethod(WeaveFile)
 
1472
    _matching_file_to_factory = staticmethod(WeaveFile)
1429
1473
    
1430
1474
    @staticmethod
1431
1475
    def is_compatible(source, target):
1438
1482
 
1439
1483
    def join(self, pb=None, msg=None, version_ids=None, ignore_missing=False):
1440
1484
        """See InterVersionedFile.join."""
1441
 
        if self.target.versions() == []:
1442
 
            # optimised copy
 
1485
        version_ids = self._get_source_version_ids(version_ids, ignore_missing)
 
1486
        if self.target.versions() == [] and version_ids is None:
1443
1487
            self.target._copy_weave_content(self.source)
1444
1488
            return
1445
1489
        try: