67
67
# the possible relationships.
70
from cStringIO import StringIO
71
from difflib import SequenceMatcher
73
from difflib import SequenceMatcher
75
76
from bzrlib.trace import mutter
76
77
from bzrlib.errors import (WeaveError, WeaveFormatError, WeaveParentMismatch,
84
85
from bzrlib.symbol_versioning import *
85
86
from bzrlib.tsort import topo_sort
86
87
from bzrlib.versionedfile import VersionedFile
88
from bzrlib.weavefile import _read_weave_v5, write_weave_v5
89
91
class Weave(VersionedFile):
836
838
setattr(self, attr, getattr(new_weave, attr))
841
class WeaveFile(Weave):
842
"""A WeaveFile represents a Weave on disk and writes on change."""
844
def __init__(self, name, transport):
845
super(WeaveFile, self).__init__(name)
846
self._transport = transport
848
_read_weave_v5(self._transport.get(name), self)
849
except errors.NoSuchFile:
853
def add_lines(self, version_id, parents, lines):
854
"""Add a version and save the weave."""
855
super(WeaveFile, self).add_lines(version_id, parents, lines)
859
"""Save the weave."""
861
write_weave_v5(self, sio)
863
self._transport.put(self._weave_name, sio)
865
def join(self, other, pb=None, msg=None, version_ids=None):
866
"""Join other into self and save."""
867
super(WeaveFile, self).join(other, pb, msg, version_ids)
839
871
def reweave(wa, wb, pb=None, msg=None):
840
872
"""Combine two weaves and return the result.