67
67
# FIXME: the conflict markers should be *7* characters
69
69
from copy import copy
70
from cStringIO import StringIO
73
from breezy.lazy_import import lazy_import
72
from .lazy_import import lazy_import
74
73
lazy_import(globals(), """
75
74
from breezy import tsort
81
from breezy.errors import (WeaveError, WeaveFormatError, WeaveParentMismatch,
80
from .errors import (WeaveError, WeaveFormatError, WeaveParentMismatch,
82
81
RevisionAlreadyPresent,
83
82
RevisionNotPresent,
84
83
UnavailableRepresentation,
86
from breezy.osutils import dirname, sha, sha_strings, split_lines
87
import breezy.patiencediff
88
from breezy.revision import NULL_REVISION
89
from breezy.symbol_versioning import *
90
from breezy.trace import mutter
91
from breezy.versionedfile import (
85
from .osutils import dirname, sha, sha_strings, split_lines
86
from . import patiencediff
87
from .revision import NULL_REVISION
91
from .symbol_versioning import *
92
from .trace import mutter
93
from .versionedfile import (
92
94
AbsentContentFactory,
95
97
sort_groupcompress,
98
from breezy.weavefile import _read_weave_v5, write_weave_v5
100
from .weavefile import _read_weave_v5, write_weave_v5
101
103
class WeaveContentFactory(ContentFactory):
751
753
NOT FOR PUBLIC USE.
753
if isinstance(name_or_index, (int, long)):
755
# GZ 2017-04-01: This used to check for long as well, but I don't think
756
# there are python implementations with sys.maxsize > sys.maxint
757
if isinstance(name_or_index, int):
754
758
return name_or_index
756
760
return self._lookup(name_or_index)
878
882
raise errors.WeaveTextDiffers(name, self, other)
879
883
self_parents = self._parents[this_idx]
880
884
other_parents = other._parents[other_idx]
881
n1 = set([self._names[i] for i in self_parents])
882
n2 = set([other._names[i] for i in other_parents])
885
n1 = {self._names[i] for i in self_parents}
886
n2 = {other._names[i] for i in other_parents}
883
887
if not self._compatible_parents(n1, n2):
884
888
raise WeaveParentMismatch("inconsistent parents "
885
889
"for version {%s}: %s vs %s" % (name, n1, n2))
921
925
self._filemode = filemode
923
927
f = self._transport.get(name + WeaveFile.WEAVE_SUFFIX)
924
_read_weave_v5(StringIO(f.read()), self)
928
_read_weave_v5(BytesIO(f.read()), self)
925
929
except errors.NoSuchFile:
941
945
def copy_to(self, name, transport):
942
946
"""See VersionedFile.copy_to()."""
943
947
# as we are all in memory always, just serialise to the new place.
945
949
write_weave_v5(self, sio)
947
951
transport.put_file(name + WeaveFile.WEAVE_SUFFIX, sio, self._filemode)