[MERGE] Convert tests.blackbox.test_[pull|nick] to use internals where appropriate
Aaron Bentley
aaron.bentley at utoronto.ca
Thu Aug 16 14:45:08 BST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Daniel Watkins wrote:
> Attached are fixes for tests.blackbox.test_pull and
> tests.blackbox.test_nick.
bb:resubmit
+ def example_branch(self, path='.'):
+ tree = self.make_branch_and_tree(path)
+ self.build_tree_contents([
+ (path + '/hello', 'foo'),
+ (path + '/goodbye', 'baz')])
Please use osutils.pathjoin, rather than string concatenation.
+ os.chdir('..')
+ a = Branch.open('a')
+ b = Branch.open('b')
self.assertEquals(a.revision_history(), b.revision_history()[:-1])
assertEquals? That works? We use assertEqual.
@@ -81,49 +85,46 @@
a.revision_history())
os.chdir('../a')
self.run_bzr('merge ../b')
^^^ The internal version of "merge" is WorkingTree.merge_from_branch()
- - self.run_bzr('commit -m blah4 --unchanged')
+ a_tree.commit(message="blah4", allow_pointless=True)
os.chdir('../b/subdir')
self.run_bzr('pull ../../a')
self.assertEquals(a.revision_history()[-1],
b.revision_history()[-1])
- - self.run_bzr('commit -m blah5 --unchanged')
- - self.run_bzr('commit -m blah6 --unchanged')
+ sub_tree = WorkingTree.open_containing('.')[0]
^^^ Please use WorkingTree.open(). It's more precise.
- - self.run_bzr('pull -d %s .' % c_url)
+ self.run_bzr('pull -d %s a' % c_url)
^^^ I think John pointed out that this breaks with spaces.
+ a_tree = self.make_branch_and_tree('a')
+ self.build_tree_contents([('a/foo', 'original\n')])
+ a_tree.add('foo')
+ a_tree.commit(message='initial commit')
+
+ b_tree = a_tree.bzrdir.sprout('b').open_workingtree()
+
+ self.build_tree_contents([('a/foo', 'changed\n')])
+ a_tree.commit(message='later change')
+
+ self.build_tree_contents([('a/foo', 'a third change')])
+ a_tree.commit(message='a third change')
+
+ self.assertEqual(len(a_tree.branch.revision_history()), 3)
+
+ b_tree.merge_from_branch(a_tree.branch)
+ b_tree.commit(message='merge')
+
+ self.assertEqual(len(b_tree.branch.revision_history()), 2)
+
+ self.build_tree_contents([('a/foo', 'a fourth change\n')])
+ a_tree.commit(message='a fourth change')
+
+ rev_history_a = self.get_rh(a_tree, 4)
# With convergence, we could just pull over the
# new change, but with --overwrite, we want to switch our history
- - os.chdir('../b')
- - bzr('pull --overwrite ../a')
- - rev_history_b = get_rh(4)
+ os.chdir('b')
+ self.run_bzr('pull --overwrite ../a')
+ rev_history_b = self.get_rh(b_tree, 4)
self.assertEqual(rev_history_b, rev_history_a)
@@ -316,3 +289,10 @@
out, err = self.run_bzr('pull ../bundle')
self.assertEqual(err, '')
self.assertEqual(out, 'No revisions to pull.\n')
+
+
+ def get_rh(self, tree, expected_len):
+ # Make sure we don't have trailing empty revisions
^^^ I think this comment is out of date. But the whole function is
questionable, since you're implicitly checking the length by comparing
the revision history against an expected value. So using
tree.branch.revision_history probably makes sense.
Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGxFTk0F+nu1YWqI0RAo9EAJ9VXYFpT46ciSkdVn8PRR/1BPwNngCeL3uu
e0UQmaXp2O4+0iUVaUtIHdw=
=RopN
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list