37
from bzrlib.selftest import TestCaseInTempDir
37
from bzrlib.selftest import TestCase
38
38
from bzrlib.weave import Weave, reweave
39
from bzrlib.weavefile import read_weave
40
39
from bzrlib.errors import WeaveParentMismatch
42
class TestReweave(TestCaseInTempDir):
41
class TestReweave(TestCase):
44
43
def test_reweave_add_parents(self):
45
44
"""Reweave inserting new parents
116
115
eq(wc.parent_names('v2'), ['v1', 'x1'])
118
117
self.assertEquals(wc, w1)
119
def build_empty_weave(self, *pattern):
121
for version, parents in pattern:
122
w.add(version, parents, [])
125
def test_reweave_reorder(self):
126
"""Reweave requiring reordering of versions.
128
Weaves must be stored such that parents come before children. When
129
reweaving, we may add new parents to some children, but it is required
130
that there must be *some* valid order that can be found, otherwise the
131
ancestries are contradictory. (For the specific case of inserting
132
ghost revisions there will be no disagreement, only partial knowledge
135
Note that the weaves are only partially ordered: when there are two
136
versions where neither is an ancestor of the other the order in which
137
they occur is unconstrained. When we reweave those versions into
138
another weave, they may become more constrained and it may be
139
necessary to change their order.
141
One simple case of this is
146
We need to recognize that the final weave must show the ordering
147
a[], b[a], c[b]. The version that must be first in the result is
148
not first in either of the input weaves.
150
w1 = self.build_empty_weave(('c', []), ('a', []), ('b', ['a']))
151
w2 = self.build_empty_weave(('b', []), ('c', ['b']), ('a', []))