Rev 2388: Split get_revision_graph tests out of repository_implementations.test_repository. in file:///home/robertc/source/baz/netsim/
Robert Collins
robertc at robertcollins.net
Sat Mar 31 02:11:24 BST 2007
At file:///home/robertc/source/baz/netsim/
------------------------------------------------------------
revno: 2388
revision-id: robertc at robertcollins.net-20070331011121-inbkb9pi7lmgbfhs
parent: pqm at pqm.ubuntu.com-20070329191009-2b533e883212576c
committer: Robert Collins <robertc at robertcollins.net>
branch nick: netsim
timestamp: Sat 2007-03-31 11:11:21 +1000
message:
Split get_revision_graph tests out of repository_implementations.test_repository.
added:
bzrlib/tests/repository_implementations/test_revision_graph.py test_revision_graph.-20070331011036-7x4dtgs5sopm7kcq-1
modified:
bzrlib/tests/repository_implementations/__init__.py __init__.py-20060131092037-9564957a7d4a841b
bzrlib/tests/repository_implementations/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
=== added file 'bzrlib/tests/repository_implementations/test_revision_graph.py'
--- a/bzrlib/tests/repository_implementations/test_revision_graph.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/repository_implementations/test_revision_graph.py 2007-03-31 01:11:21 +0000
@@ -0,0 +1,80 @@
+# Copyright (C) 2007 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+"""Tests for revision graph access."""
+
+from bzrlib.errors import (NoSuchRevision,
+ )
+from bzrlib.revision import NULL_REVISION
+from bzrlib.tests.repository_implementations.test_repository import (
+ TestCaseWithComplexRepository,
+ )
+
+
+class TestRevisionGraph(TestCaseWithComplexRepository):
+
+ def test_get_revision_graph(self):
+ # we can get a mapping of id->parents for the entire revision graph or bits thereof.
+ self.assertEqual({'rev1':[],
+ 'rev2':['rev1'],
+ 'rev3':['rev2'],
+ 'rev4':['rev3'],
+ },
+ self.bzrdir.open_repository().get_revision_graph(None))
+ self.assertEqual({'rev1':[]},
+ self.bzrdir.open_repository().get_revision_graph('rev1'))
+ self.assertEqual({'rev1':[],
+ 'rev2':['rev1']},
+ self.bzrdir.open_repository().get_revision_graph('rev2'))
+ self.assertRaises(NoSuchRevision,
+ self.bzrdir.open_repository().get_revision_graph,
+ 'orphan')
+ # and ghosts are not mentioned
+ self.assertEqual({'rev1':[],
+ 'rev2':['rev1'],
+ 'rev3':['rev2'],
+ },
+ self.bzrdir.open_repository().get_revision_graph('rev3'))
+ # and we can ask for the NULLREVISION graph
+ self.assertEqual({},
+ self.bzrdir.open_repository().get_revision_graph(NULL_REVISION))
+
+ def test_get_revision_graph_with_ghosts(self):
+ # we can get a graph object with roots, ghosts, ancestors and
+ # descendants.
+ repo = self.bzrdir.open_repository()
+ graph = repo.get_revision_graph_with_ghosts([])
+ self.assertEqual(set(['rev1']), graph.roots)
+ self.assertEqual(set(['ghost1', 'ghost2']), graph.ghosts)
+ self.assertEqual({'rev1':[],
+ 'rev2':['rev1'],
+ 'rev3':['rev2', 'ghost1'],
+ 'rev4':['rev3', 'ghost1', 'ghost2'],
+ },
+ graph.get_ancestors())
+ self.assertEqual({'ghost1':{'rev3':1, 'rev4':1},
+ 'ghost2':{'rev4':1},
+ 'rev1':{'rev2':1},
+ 'rev2':{'rev3':1},
+ 'rev3':{'rev4':1},
+ 'rev4':{},
+ },
+ graph.get_descendants())
+ # and we can ask for the NULLREVISION graph
+ graph = repo.get_revision_graph_with_ghosts([NULL_REVISION])
+ self.assertEqual({}, graph.get_ancestors())
+ self.assertEqual({}, graph.get_descendants())
+
=== modified file 'bzrlib/tests/repository_implementations/__init__.py'
--- a/bzrlib/tests/repository_implementations/__init__.py 2007-02-21 05:34:56 +0000
+++ b/bzrlib/tests/repository_implementations/__init__.py 2007-03-31 01:11:21 +0000
@@ -51,6 +51,7 @@
'bzrlib.tests.repository_implementations.test_reconcile',
'bzrlib.tests.repository_implementations.test_repository',
'bzrlib.tests.repository_implementations.test_revision',
+ 'bzrlib.tests.repository_implementations.test_revision_graph',
'bzrlib.tests.repository_implementations.test_statistics',
]
registry = repository.format_registry
=== modified file 'bzrlib/tests/repository_implementations/test_repository.py'
--- a/bzrlib/tests/repository_implementations/test_repository.py 2007-03-29 06:24:19 +0000
+++ b/bzrlib/tests/repository_implementations/test_repository.py 2007-03-31 01:11:21 +0000
@@ -460,6 +460,8 @@
def setUp(self):
super(TestCaseWithComplexRepository, self).setUp()
tree_a = self.make_branch_and_tree('a')
+ # save the tree for later mutations
+ self.tree_a = tree_a
self.bzrdir = tree_a.branch.bzrdir
# add a corrupt inventory 'orphan'
# this may need some generalising for knits.
@@ -478,6 +480,11 @@
tree_a.add_parent_tree_id('ghost1')
tree_a.add_parent_tree_id('ghost2')
tree_a.commit('rev4', rev_id='rev4', allow_pointless=True)
+ # the resulting graph is:
+ # rev1: [], rev2:[rev1], rev3:[rev2, ghost1], rev4[rev3, ghost1, ghost2]
+
+
+class TestRevisionTrees(TestCaseWithComplexRepository):
def test_revision_trees(self):
revision_ids = ['rev1', 'rev2', 'rev3', 'rev4']
@@ -497,6 +504,9 @@
revisions]
assert deltas1 == deltas2
+
+class TestAllRevisionIds(TestCaseWithComplexRepository):
+
def test_all_revision_ids(self):
# all_revision_ids -> all revisions
self.assertEqual(['rev1', 'rev2', 'rev3', 'rev4'],
@@ -508,58 +518,6 @@
self.assertRaises(errors.NoSuchRevision,
self.bzrdir.open_repository().get_ancestry, 'orphan')
- def test_get_revision_graph(self):
- # we can get a mapping of id->parents for the entire revision graph or bits thereof.
- self.assertEqual({'rev1':[],
- 'rev2':['rev1'],
- 'rev3':['rev2'],
- 'rev4':['rev3'],
- },
- self.bzrdir.open_repository().get_revision_graph(None))
- self.assertEqual({'rev1':[]},
- self.bzrdir.open_repository().get_revision_graph('rev1'))
- self.assertEqual({'rev1':[],
- 'rev2':['rev1']},
- self.bzrdir.open_repository().get_revision_graph('rev2'))
- self.assertRaises(NoSuchRevision,
- self.bzrdir.open_repository().get_revision_graph,
- 'orphan')
- # and ghosts are not mentioned
- self.assertEqual({'rev1':[],
- 'rev2':['rev1'],
- 'rev3':['rev2'],
- },
- self.bzrdir.open_repository().get_revision_graph('rev3'))
- # and we can ask for the NULLREVISION graph
- self.assertEqual({},
- self.bzrdir.open_repository().get_revision_graph(NULL_REVISION))
-
- def test_get_revision_graph_with_ghosts(self):
- # we can get a graph object with roots, ghosts, ancestors and
- # descendants.
- repo = self.bzrdir.open_repository()
- graph = repo.get_revision_graph_with_ghosts([])
- self.assertEqual(set(['rev1']), graph.roots)
- self.assertEqual(set(['ghost1', 'ghost2']), graph.ghosts)
- self.assertEqual({'rev1':[],
- 'rev2':['rev1'],
- 'rev3':['rev2', 'ghost1'],
- 'rev4':['rev3', 'ghost1', 'ghost2'],
- },
- graph.get_ancestors())
- self.assertEqual({'ghost1':{'rev3':1, 'rev4':1},
- 'ghost2':{'rev4':1},
- 'rev1':{'rev2':1},
- 'rev2':{'rev3':1},
- 'rev3':{'rev4':1},
- 'rev4':{},
- },
- graph.get_descendants())
- # and we can ask for the NULLREVISION graph
- graph = repo.get_revision_graph_with_ghosts([NULL_REVISION])
- self.assertEqual({}, graph.get_ancestors())
- self.assertEqual({}, graph.get_descendants())
-
def test_reserved_id(self):
repo = self.make_repository('repository')
self.assertRaises(errors.ReservedId, repo.add_inventory, 'reserved:',
More information about the bazaar-commits
mailing list