/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: 2007-08-21 01:40:39 UTC
  • mfrom: (2734 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2735.
  • Revision ID: aaron.bentley@utoronto.ca-20070821014039-pvms1pv6sq5m9as0
Merge from 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
419
    def _add_lines(self, version_id, parents, lines, parent_texts,
453
420
                   left_matching_blocks=None):
454
421
        """See VersionedFile.add_lines."""
455
422
        return self._add(version_id, lines, map(self._lookup, parents))
456
423
 
457
 
    @deprecated_method(zero_eight)
458
 
    def add(self, name, parents, text, sha1=None):
459
 
        """See VersionedFile.add_lines for the non deprecated api."""
460
 
        return self._add(name, text, map(self._maybe_lookup, parents), sha1)
461
 
 
462
424
    def _add(self, version_id, lines, parents, sha1=None):
463
425
        """Add a single text on top of the weave.
464
426
  
598
560
        ## except IndexError:
599
561
        ##     raise ValueError("version %d not present in weave" % v)
600
562
 
601
 
    @deprecated_method(zero_eight)
602
 
    def inclusions(self, version_ids):
603
 
        """Deprecated - see VersionedFile.get_ancestry for the replacement."""
604
 
        if not version_ids:
605
 
            return []
606
 
        if isinstance(version_ids[0], int):
607
 
            return [self._idx_to_name(v) for v in self._inclusions(version_ids)]
608
 
        else:
609
 
            return self.get_ancestry(version_ids)
610
 
 
611
563
    def get_ancestry(self, version_ids, topo_sorted=True):
612
564
        """See VersionedFile.get_ancestry."""
613
565
        if isinstance(version_ids, basestring):
650
602
        for origin, lineno, text in self._extract(incls):
651
603
            yield self._idx_to_name(origin), text
652
604
 
653
 
    @deprecated_method(zero_eight)
654
 
    def _walk(self):
655
 
        """_walk has become visit, a supported api."""
656
 
        return self._walk_internal()
657
 
 
658
605
    def iter_lines_added_or_present_in_versions(self, version_ids=None,
659
606
                                                pb=None):
660
607
        """See VersionedFile.iter_lines_added_or_present_in_versions()."""
671
618
            else:
672
619
                yield line
673
620
 
674
 
    #@deprecated_method(zero_eight)
675
 
    def walk(self, version_ids=None):
676
 
        """See VersionedFile.walk."""
677
 
        return self._walk_internal(version_ids)
678
 
 
679
621
    def _walk_internal(self, version_ids=None):
680
622
        """Helper method for weave actions."""
681
623
        
724
666
        inc_b = set(self.get_ancestry([ver_b]))
725
667
        inc_c = inc_a & inc_b
726
668
 
727
 
        for lineno, insert, deleteset, line in\
728
 
            self.walk([ver_a, ver_b]):
 
669
        for lineno, insert, deleteset, line in self._walk_internal([ver_a, ver_b]):
729
670
            if deleteset & inc_c:
730
671
                # killed in parent; can't be in either a or b
731
672
                # not relevant to our work
847
788
                                   % dset)
848
789
        return result
849
790
 
850
 
    @deprecated_method(zero_eight)
851
 
    def get_iter(self, name_or_index):
852
 
        """Deprecated, please do not use. Lookups are not not needed.
853
 
        
854
 
        Please use get_lines now.
855
 
        """
856
 
        return iter(self.get_lines(self._maybe_lookup(name_or_index)))
857
 
 
858
 
    @deprecated_method(zero_eight)
859
 
    def maybe_lookup(self, name_or_index):
860
 
        """Deprecated, please do not use. Lookups are not not needed."""
861
 
        return self._maybe_lookup(name_or_index)
862
 
 
863
791
    def _maybe_lookup(self, name_or_index):
864
792
        """Convert possible symbolic name to index, or pass through indexes.
865
793
        
870
798
        else:
871
799
            return self._lookup(name_or_index)
872
800
 
873
 
    @deprecated_method(zero_eight)
874
 
    def get(self, version_id):
875
 
        """Please use either Weave.get_text or Weave.get_lines as desired."""
876
 
        return self.get_lines(version_id)
877
 
 
878
801
    def get_lines(self, version_id):
879
802
        """See VersionedFile.get_lines()."""
880
803
        int_index = self._maybe_lookup(version_id)
896
819
        """See VersionedFile.get_sha1s()."""
897
820
        return [self._sha1s[self._lookup(v)] for v in version_ids]
898
821
 
899
 
    @deprecated_method(zero_eight)
900
 
    def numversions(self):
901
 
        """How many versions are in this weave?
902
 
 
903
 
        Deprecated in favour of num_versions.
904
 
        """
905
 
        return self.num_versions()
906
 
 
907
822
    def num_versions(self):
908
823
        """How many versions are in this weave?"""
909
824
        l = len(self._parents)
1067
982
        else:
1068
983
            return False
1069
984
 
1070
 
    @deprecated_method(zero_eight)
1071
 
    def reweave(self, other, pb=None, msg=None):
1072
 
        """reweave has been superseded by plain use of join."""
1073
 
        return self.join(other, pb, msg)
1074
 
 
1075
985
    def _reweave(self, other, pb, msg):
1076
986
        """Reweave self with other - internal helper for join().
1077
987
 
1157
1067
        self._save()
1158
1068
 
1159
1069
 
1160
 
@deprecated_function(zero_eight)
1161
 
def reweave(wa, wb, pb=None, msg=None):
1162
 
    """reweaving is deprecation, please just use weave.join()."""
1163
 
    _reweave(wa, wb, pb, msg)
1164
 
 
1165
1070
def _reweave(wa, wb, pb=None, msg=None):
1166
1071
    """Combine two weaves and return the result.
1167
1072