34
34
from bzrlib.trace import mutter
35
35
from bzrlib.transport import get_transport
36
36
from bzrlib.transport.memory import MemoryTransport
37
from bzrlib.tsort import topo_sort
37
38
import bzrlib.versionedfile as versionedfile
38
39
from bzrlib.weave import WeaveFile
39
40
from bzrlib.weavefile import read_weave, write_weave
420
421
# and should be a list
421
422
self.assertTrue(isinstance(f.__class__.get_suffixes(), list))
424
def build_graph(self, file, graph):
425
for node in topo_sort(graph.items()):
426
file.add_lines(node, graph[node], [])
423
428
def test_get_graph(self):
424
429
f = self.get_file()
425
f.add_lines('v1', [], ['hello\n'])
426
f.add_lines('v2', ['v1'], ['hello\n', 'world\n'])
427
f.add_lines('v3', ['v2'], ['hello\n', 'cruel\n', 'world\n'])
428
self.assertEqual({'v1': [],
434
self.build_graph(f, graph)
435
self.assertEqual(graph, f.get_graph())
437
def test_get_graph_partial(self):
445
complex_graph.update(simple_a)
450
complex_graph.update(simple_b)
457
complex_graph.update(simple_gam)
459
simple_b_gam.update(simple_gam)
460
simple_b_gam.update(simple_b)
461
self.build_graph(f, complex_graph)
462
self.assertEqual(simple_a, f.get_graph(['a']))
463
self.assertEqual(simple_b, f.get_graph(['b']))
464
self.assertEqual(simple_gam, f.get_graph(['gam']))
465
self.assertEqual(simple_b_gam, f.get_graph(['b', 'gam']))
433
467
def test_get_parents(self):
434
468
f = self.get_file()