Rev 2476: Use BranchBuilder in test_ancestry. in file:///home/robertc/source/baz/use-build-branch/

Robert Collins robertc at robertcollins.net
Fri Apr 27 04:42:53 BST 2007


At file:///home/robertc/source/baz/use-build-branch/

------------------------------------------------------------
revno: 2476
revision-id: robertc at robertcollins.net-20070427034250-8gie8hxmx3e2cgc3
parent: robertc at robertcollins.net-20070427033909-bsuz8ogd7r75dbfl
committer: Robert Collins <robertc at robertcollins.net>
branch nick: use-build-branch
timestamp: Fri 2007-04-27 13:42:50 +1000
message:
  Use BranchBuilder in test_ancestry.
modified:
  bzrlib/tests/test_ancestry.py  test_ancestry.py-20050913023709-69768e94848312c6
=== modified file 'bzrlib/tests/test_ancestry.py'
--- a/bzrlib/tests/test_ancestry.py	2006-10-16 01:50:48 +0000
+++ b/bzrlib/tests/test_ancestry.py	2007-04-27 03:42:50 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005 Canonical Ltd
+# Copyright (C) 2005, 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
@@ -21,6 +21,7 @@
 
 from bzrlib.tests import TestCaseWithMemoryTransport
 from bzrlib.branch import Branch
+from bzrlib.branchbuilder import BranchBuilder
 from bzrlib.revision import is_ancestor
 
 
@@ -33,29 +34,25 @@
 
     def test_straightline_ancestry(self):
         """Test ancestry file when just committing."""
-        tree = self.make_branch_and_memory_tree('.')
-        branch = tree.branch
-        tree.lock_write()
-        tree.add('')
-        rev_id_one = tree.commit('one')
-        rev_id_two = tree.commit('two', allow_pointless=True)
-        tree.unlock()
-
+        builder = BranchBuilder(self.get_transport())
+        rev_id_one = builder.build_commit()
+        rev_id_two = builder.build_commit()
+        branch = builder.get_branch()
         self.assertAncestryEqual([None, rev_id_one, rev_id_two],
             rev_id_two, branch)
         self.assertAncestryEqual([None, rev_id_one], rev_id_one, branch)
 
-    def test_none_is_always_an_ancestor(self):
-        tree = self.make_branch_and_memory_tree('.')
-        tree.lock_write()
-        tree.add('')
-        # note this is tested before any commits are done.
-        self.assertTrue(is_ancestor(None, None, tree.branch))
-        rev_id = tree.commit('one')
-        tree.unlock()
-        self.assertTrue(is_ancestor(None, None, tree.branch))
-        self.assertTrue(is_ancestor(rev_id, None, tree.branch))
-        self.assertFalse(is_ancestor(None, rev_id, tree.branch))
+    def test_none_is_ancestor_empty_branch(self):
+        branch = self.make_branch('.')
+        self.assertTrue(is_ancestor(None, None, branch))
+
+    def test_none_is_ancestor_non_empty_branch(self):
+        builder = BranchBuilder(self.get_transport())
+        rev_id = builder.build_commit()
+        branch = builder.get_branch()
+        self.assertTrue(is_ancestor(None, None, branch))
+        self.assertTrue(is_ancestor(rev_id, None, branch))
+        self.assertFalse(is_ancestor(None, rev_id, branch))
 
 
 # TODO: check that ancestry is updated to include indirectly merged revisions



More information about the bazaar-commits mailing list