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,
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)
231
@deprecated_method(zero_eight)
232
def idx_to_name(self, index):
233
"""Old public interface, the public interface is all names now."""
236
227
def _idx_to_name(self, version):
237
228
return self._names[version]
239
@deprecated_method(zero_eight)
240
def lookup(self, name):
241
"""Backwards compatibility thunk:
243
Return name, as name is valid in the api now, and spew deprecation
248
230
def _lookup(self, name):
249
231
"""Convert symbolic version name to index."""
250
232
self.check_not_reserved_id(name)
254
236
raise RevisionNotPresent(name, self._weave_name)
256
@deprecated_method(zero_eight)
257
def iter_names(self):
258
"""Deprecated convenience function, please see VersionedFile.names()."""
259
return iter(self.names())
261
@deprecated_method(zero_eight)
263
"""See Weave.versions for the current api."""
264
return self.versions()
266
238
def versions(self):
267
239
"""See VersionedFile.versions."""
268
240
return self._names[:]
444
416
raise RevisionAlreadyPresent(name, self._weave_name)
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)
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))
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)
461
424
def _add(self, version_id, lines, parents, sha1=None):
462
425
"""Add a single text on top of the weave.
597
560
## except IndexError:
598
561
## raise ValueError("version %d not present in weave" % v)
600
@deprecated_method(zero_eight)
601
def inclusions(self, version_ids):
602
"""Deprecated - see VersionedFile.get_ancestry for the replacement."""
605
if isinstance(version_ids[0], int):
606
return [self._idx_to_name(v) for v in self._inclusions(version_ids)]
608
return self.get_ancestry(version_ids)
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
652
@deprecated_method(zero_eight)
654
"""_walk has become visit, a supported api."""
655
return self._walk_internal()
657
605
def iter_lines_added_or_present_in_versions(self, version_ids=None,
659
607
"""See VersionedFile.iter_lines_added_or_present_in_versions()."""
673
#@deprecated_method(zero_eight)
674
def walk(self, version_ids=None):
675
"""See VersionedFile.walk."""
676
return self._walk_internal(version_ids)
678
621
def _walk_internal(self, version_ids=None):
679
622
"""Helper method for weave actions."""
723
666
inc_b = set(self.get_ancestry([ver_b]))
724
667
inc_c = inc_a & inc_b
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
849
@deprecated_method(zero_eight)
850
def get_iter(self, name_or_index):
851
"""Deprecated, please do not use. Lookups are not not needed.
853
Please use get_lines now.
855
return iter(self.get_lines(self._maybe_lookup(name_or_index)))
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)
862
791
def _maybe_lookup(self, name_or_index):
863
792
"""Convert possible symbolic name to index, or pass through indexes.
870
799
return self._lookup(name_or_index)
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)
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]
898
@deprecated_method(zero_eight)
899
def numversions(self):
900
"""How many versions are in this weave?
902
Deprecated in favour of num_versions.
904
return self.num_versions()
906
822
def num_versions(self):
907
823
"""How many versions are in this weave?"""
908
824
l = len(self._parents)
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)
1074
985
def _reweave(self, other, pb, msg):
1075
986
"""Reweave self with other - internal helper for join().
1109
1020
# new file, save it
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,
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)
1163
1070
def _reweave(wa, wb, pb=None, msg=None):
1164
1071
"""Combine two weaves and return the result.