def test_weave6(self): w = Weave() w.add_revision(1, ['b'], []) w.add_revision(2, ['c', 'b'], [1]) w.add_revision(3, ['b'], [2]) w.add_revision(4, ['d', 'b'], [1]) self.assertEquals(w.merge(2, 4), [(['c'], ['d']), 'b']) self.assertEquals(w.merge(3, 4), [([], ['d']), 'b']) w.add_revision(5, ['b'], [4]) self.assertEquals(w.merge(4, 5), ['b'])
def test_weave12(self): w = Weave() w.add_revision(1, ['b', 'c', 'd'], []) w.add_revision(2, ['x', 'c', 'd'], [1]) w.add_revision(3, [], [1]) w.add_revision(4, ['b', 'c', 'd'], [3]) self.assertEquals(w.merge(2, 4), [(['x'], ['b']), 'c', 'd'])
def test_weave_cherry_pick(self): w = Weave() w.add_revision(1, ['a', 'b', 'c', 'd', 'e', 'f'], []) w.add_revision(2, ['a', 'b', 'c', 'd', 'e', 'g'], [1]) w.add_revision(3, ['b', 'c', 'c', 'd', 'e', 'f'], []) self.assertEquals(w.cherry_pick(2, 3), ['b', 'c', 'c', 'd', 'e', 'g']) w.add_revision(4, ['a', 'b', 'c', 'd', 'f'], []) self.assertEquals(w.cherry_pick(2, 4), ['a', 'b', 'c', 'd', (['e', 'g'], ['f'])])
def test_weave21(self): w = Weave() w.add_revision(1, ['a', 'b'], []) w.add_revision(2, ['a', 'f', 'y', 'y', 'f', 'b'], [1]) w.add_revision(3, ['a', 'y', 'b'], [1]) w.add_revision(4, ['a', 'p', 'z', 'm', 'y', 'm', 'z', 'p', 'b'], [3]) w.add_revision(5, ['a', 'q', 'z', 'n', 'y', 'n', 'z', 'q', 'b'], [3]) self.assertEquals(w.merge(4, 5), ['a', (['p'], ['q']), 'z', (['m'], ['n']), 'y', (['m'], ['n']), 'z', (['p'], ['q']), 'b'])
def test_weave18(self): w = Weave() w.add_revision(1, [], []) w.add_revision(2, ['f', 'y', 'y', 'f'], [1]) w.add_revision(3, ['y'], [1]) w.add_revision(4, ['p', 'y', 'p'], [3]) w.add_revision(5, ['q', 'y', 'q'], [3]) self.assertEquals(w.merge(4, 5), [(['p'], ['q']), 'y', (['p'], ['q'])])
def test_weave4(self): w = Weave() w.add_revision(1, [], []) self.assertEquals(w.retrieve_revision(1), []) w.add_revision(2, ['x'], [1]) self.assertEquals(w.retrieve_revision(2), ['x']) w.add_revision(3, ['y'], [1]) self.assertEquals(w.retrieve_revision(3), ['y']) self.assertEquals(w.merge(2, 3), [(['x'], ['y'])]) w.add_revision(4, ['x'], [1]) w.add_revision(5, ['z'], [4]) self.assertEquals(w.merge(2, 5), ['z'])
def test_weave15(self): w = Weave() w.add_revision(1, ['a'], []) w.add_revision(2, ['a', 'c'], [1]) w.add_revision(3, ['a', 'd'], [1]) w.add_revision(4, ['a', 'c', 'd'], [2, 3]) w.add_revision(5, ['a', 'd', 'c'], [2, 3]) self.assertEquals(w.merge(4, 5), ['a', (['c'], []), 'd', 'c'])
def test_weave_cherry_pick_with_removal(self): w = Weave() w.add_revision(1, ['a', 'b', 'c', 'd', 'e', 'f'], []) w.add_revision(2, ['a', 'b', 'c', 'e', 'f'], [1]) w.add_revision(3, ['a', 'b', 'd', 'e', 'f'], [1]) self.assertEquals(w.merge(2, 3), ['a', 'b', (['c'], ['d']), 'e', 'f'])