~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/weave.py

  • Committer: Aaron Bentley
  • Date: 2007-08-21 01:32:29 UTC
  • mfrom: (2727 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2736.
  • Revision ID: aaron.bentley@utoronto.ca-20070821013229-miopsemz249tv0bl
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
88
88
import bzrlib.errors as errors
89
89
from bzrlib.osutils import sha_strings
90
90
import bzrlib.patiencediff
91
 
from bzrlib.symbol_versioning import (deprecated_method,
92
 
        deprecated_function,
93
 
        zero_eight,
94
 
        )
95
91
from bzrlib.tsort import topo_sort
96
92
from bzrlib.versionedfile import VersionedFile, InterVersionedFile
97
93
from bzrlib.weavefile import _read_weave_v5, write_weave_v5
228
224
    def __ne__(self, other):
229
225
        return not self.__eq__(other)
230
226
 
231
 
    @deprecated_method(zero_eight)
232
 
    def idx_to_name(self, index):
233
 
        """Old public interface, the public interface is all names now."""
234
 
        return index
235
 
 
236
227
    def _idx_to_name(self, version):
237
228
        return self._names[version]
238
229
 
239
 
    @deprecated_method(zero_eight)
240
 
    def lookup(self, name):
241
 
        """Backwards compatibility thunk:
242
 
 
243
 
        Return name, as name is valid in the api now, and spew deprecation
244
 
        warnings everywhere.
245
 
        """
246
 
        return name
247
 
 
248
230
    def _lookup(self, name):
249
231
        """Convert symbolic version name to index."""
250
232
        self.check_not_reserved_id(name)
253
235
        except KeyError:
254
236
            raise RevisionNotPresent(name, self._weave_name)
255
237
 
256
 
    @deprecated_method(zero_eight)
257
 
    def iter_names(self):
258
 
        """Deprecated convenience function, please see VersionedFile.names()."""
259
 
        return iter(self.names())
260
 
 
261
 
    @deprecated_method(zero_eight)
262
 
    def names(self):
263
 
        """See Weave.versions for the current api."""
264
 
        return self.versions()
265
 
 
266
238
    def versions(self):
267
239
        """See VersionedFile.versions."""
268
240
        return self._names[:]
444
416
            raise RevisionAlreadyPresent(name, self._weave_name)
445
417
        return idx
446
418
 
447
 
    @deprecated_method(zero_eight)
448
 
    def add_identical(self, old_rev_id, new_rev_id, parents):
449
 
        """Please use Weave.clone_text now."""
450
 
        return self.clone_text(new_rev_id, old_rev_id, parents)
451
 
 
452
 
    def _add_lines(self, version_id, parents, lines, parent_texts):
 
419
    def _add_lines(self, version_id, parents, lines, parent_texts,
 
420
                   left_matching_blocks=None):
453
421
        """See VersionedFile.add_lines."""
454
422
        return self._add(version_id, lines, map(self._lookup, parents))
455
423
 
456
 
    @deprecated_method(zero_eight)
457
 
    def add(self, name, parents, text, sha1=None):
458
 
        """See VersionedFile.add_lines for the non deprecated api."""
459
 
        return self._add(name, text, map(self._maybe_lookup, parents), sha1)
460
 
 
461
424
    def _add(self, version_id, lines, parents, sha1=None):
462
425
        """Add a single text on top of the weave.
463
426
  
597
560
        ## except IndexError:
598
561
        ##     raise ValueError("version %d not present in weave" % v)
599
562
 
600
 
    @deprecated_method(zero_eight)
601
 
    def inclusions(self, version_ids):
602
 
        """Deprecated - see VersionedFile.get_ancestry for the replacement."""
603
 
        if not version_ids:
604
 
            return []
605
 
        if isinstance(version_ids[0], int):
606
 
            return [self._idx_to_name(v) for v in self._inclusions(version_ids)]
607
 
        else:
608
 
            return self.get_ancestry(version_ids)
609
 
 
610
563
    def get_ancestry(self, version_ids, topo_sorted=True):
611
564
        """See VersionedFile.get_ancestry."""
612
565
        if isinstance(version_ids, basestring):
649
602
        for origin, lineno, text in self._extract(incls):
650
603
            yield self._idx_to_name(origin), text
651
604
 
652
 
    @deprecated_method(zero_eight)
653
 
    def _walk(self):
654
 
        """_walk has become visit, a supported api."""
655
 
        return self._walk_internal()
656
 
 
657
605
    def iter_lines_added_or_present_in_versions(self, version_ids=None,
658
606
                                                pb=None):
659
607
        """See VersionedFile.iter_lines_added_or_present_in_versions()."""
670
618
            else:
671
619
                yield line
672
620
 
673
 
    #@deprecated_method(zero_eight)
674
 
    def walk(self, version_ids=None):
675
 
        """See VersionedFile.walk."""
676
 
        return self._walk_internal(version_ids)
677
 
 
678
621
    def _walk_internal(self, version_ids=None):
679
622
        """Helper method for weave actions."""
680
623
        
723
666
        inc_b = set(self.get_ancestry([ver_b]))
724
667
        inc_c = inc_a & inc_b
725
668
 
726
 
        for lineno, insert, deleteset, line in\
727
 
            self.walk([ver_a, ver_b]):
 
669
        for lineno, insert, deleteset, line in self._walk_internal([ver_a, ver_b]):
728
670
            if deleteset & inc_c:
729
671
                # killed in parent; can't be in either a or b
730
672
                # not relevant to our work
846
788
                                   % dset)
847
789
        return result
848
790
 
849
 
    @deprecated_method(zero_eight)
850
 
    def get_iter(self, name_or_index):
851
 
        """Deprecated, please do not use. Lookups are not not needed.
852
 
        
853
 
        Please use get_lines now.
854
 
        """
855
 
        return iter(self.get_lines(self._maybe_lookup(name_or_index)))
856
 
 
857
 
    @deprecated_method(zero_eight)
858
 
    def maybe_lookup(self, name_or_index):
859
 
        """Deprecated, please do not use. Lookups are not not needed."""
860
 
        return self._maybe_lookup(name_or_index)
861
 
 
862
791
    def _maybe_lookup(self, name_or_index):
863
792
        """Convert possible symbolic name to index, or pass through indexes.
864
793
        
869
798
        else:
870
799
            return self._lookup(name_or_index)
871
800
 
872
 
    @deprecated_method(zero_eight)
873
 
    def get(self, version_id):
874
 
        """Please use either Weave.get_text or Weave.get_lines as desired."""
875
 
        return self.get_lines(version_id)
876
 
 
877
801
    def get_lines(self, version_id):
878
802
        """See VersionedFile.get_lines()."""
879
803
        int_index = self._maybe_lookup(version_id)
895
819
        """See VersionedFile.get_sha1s()."""
896
820
        return [self._sha1s[self._lookup(v)] for v in version_ids]
897
821
 
898
 
    @deprecated_method(zero_eight)
899
 
    def numversions(self):
900
 
        """How many versions are in this weave?
901
 
 
902
 
        Deprecated in favour of num_versions.
903
 
        """
904
 
        return self.num_versions()
905
 
 
906
822
    def num_versions(self):
907
823
        """How many versions are in this weave?"""
908
824
        l = len(self._parents)
1066
982
        else:
1067
983
            return False
1068
984
 
1069
 
    @deprecated_method(zero_eight)
1070
 
    def reweave(self, other, pb=None, msg=None):
1071
 
        """reweave has been superseded by plain use of join."""
1072
 
        return self.join(other, pb, msg)
1073
 
 
1074
985
    def _reweave(self, other, pb, msg):
1075
986
        """Reweave self with other - internal helper for join().
1076
987
 
1109
1020
            # new file, save it
1110
1021
            self._save()
1111
1022
 
1112
 
    def _add_lines(self, version_id, parents, lines, parent_texts):
 
1023
    def _add_lines(self, version_id, parents, lines, parent_texts,
 
1024
        left_matching_blocks=None):
1113
1025
        """Add a version and save the weave."""
1114
1026
        self.check_not_reserved_id(version_id)
1115
1027
        result = super(WeaveFile, self)._add_lines(version_id, parents, lines,
1155
1067
        self._save()
1156
1068
 
1157
1069
 
1158
 
@deprecated_function(zero_eight)
1159
 
def reweave(wa, wb, pb=None, msg=None):
1160
 
    """reweaving is deprecation, please just use weave.join()."""
1161
 
    _reweave(wa, wb, pb, msg)
1162
 
 
1163
1070
def _reweave(wa, wb, pb=None, msg=None):
1164
1071
    """Combine two weaves and return the result.
1165
1072