Rev 2827: Fixed blackbox log & missing tests to use internals (Watkins) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Mon Sep 17 20:58:59 BST 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 2827
revision-id: pqm at pqm.ubuntu.com-20070917195855-edm9ckmelvhl05te
parent: pqm at pqm.ubuntu.com-20070917142923-f06edfgw1d0cvj4w
parent: d.m.watkins at warwick.ac.uk-20070916022950-kv9l5nk16gq3zg53
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2007-09-17 20:58:55 +0100
message:
Fixed blackbox log & missing tests to use internals (Watkins)
modified:
bzrlib/tests/blackbox/test_log.py test_log.py-20060112090212-78f6ea560c868e24
bzrlib/tests/blackbox/test_missing.py test_missing.py-20051211212735-a2cf4c1840bb84c4
------------------------------------------------------------
revno: 2809.1.2
merged: d.m.watkins at warwick.ac.uk-20070916022950-kv9l5nk16gq3zg53
parent: d.m.watkins at warwick.ac.uk-20070916022819-btf2wfdajwt94l3a
committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
branch nick: fix_blackbox_test_missinglog
timestamp: Sun 2007-09-16 03:29:50 +0100
message:
Removed unnecessary check as per abentley's on-list comments.
------------------------------------------------------------
revno: 2809.1.1
merged: d.m.watkins at warwick.ac.uk-20070916022819-btf2wfdajwt94l3a
parent: pqm at pqm.ubuntu.com-20070910105743-72rhm2629qiijbsj
parent: d.m.watkins at warwick.ac.uk-20070808124816-5wvk839yjzmfiod6
committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
branch nick: fix_blackbox_test_missinglog
timestamp: Sun 2007-09-16 03:28:19 +0100
message:
Merge in previous changes.
------------------------------------------------------------
revno: 2664.14.2
merged: d.m.watkins at warwick.ac.uk-20070808124816-5wvk839yjzmfiod6
parent: d.m.watkins at warwick.ac.uk-20070808112550-z8ercqz80mktcz2o
committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
branch nick: fix-blackbox-tests
timestamp: Wed 2007-08-08 13:48:16 +0100
message:
Fixed tests.blackbox.test_missing to use internals where appropriate.
------------------------------------------------------------
revno: 2664.14.1
merged: d.m.watkins at warwick.ac.uk-20070808112550-z8ercqz80mktcz2o
parent: pqm at pqm.ubuntu.com-20070731122244-f1jemfecukeevugw
committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
branch nick: fix-blackbox-tests
timestamp: Wed 2007-08-08 12:25:50 +0100
message:
Fixed tests.blackbox.test_log to use internals where appropriate.
=== modified file 'bzrlib/tests/blackbox/test_log.py'
--- a/bzrlib/tests/blackbox/test_log.py 2007-07-19 03:40:54 +0000
+++ b/bzrlib/tests/blackbox/test_log.py 2007-09-16 02:29:50 +0000
@@ -27,19 +27,18 @@
class TestLog(ExternalBase):
- def _prepare(self, format=None):
- if format:
- self.run_bzr(["init", "--format="+format])
- else:
- self.run_bzr("init")
- self.build_tree(['hello.txt', 'goodbye.txt', 'meep.txt'])
- self.run_bzr("add hello.txt")
- self.run_bzr("commit -m message1 hello.txt")
- self.run_bzr("add goodbye.txt")
- self.run_bzr("commit -m message2 goodbye.txt")
- self.run_bzr("add meep.txt")
- self.run_bzr("commit -m message3 meep.txt")
- self.full_log = self.run_bzr("log")[0]
+ def _prepare(self, path='.', format=None):
+ tree = self.make_branch_and_tree(path, format=format)
+ self.build_tree(
+ [path + '/hello.txt', path + '/goodbye.txt', path + '/meep.txt'])
+ tree.add('hello.txt')
+ tree.commit(message='message1')
+ tree.add('goodbye.txt')
+ tree.commit(message='message2')
+ tree.add('meep.txt')
+ tree.commit(message='message3')
+ self.full_log = self.run_bzr(["log", path])[0]
+ return tree
def test_log_null_end_revspec(self):
self._prepare()
@@ -100,14 +99,8 @@
['log', '-r3..1'])
def test_log_revno_n_path(self):
- os.mkdir('branch1')
- os.chdir('branch1')
- self._prepare()
- os.chdir('..')
- os.mkdir('branch2')
- os.chdir('branch2')
- self._prepare()
- os.chdir('..')
+ self._prepare(path='branch1')
+ self._prepare(path='branch2')
log = self.run_bzr("log -r revno:2:branch1..revno:3:branch2",
retcode=3)[0]
log = self.run_bzr("log -r revno:1:branch2..revno:3:branch2")[0]
@@ -127,10 +120,11 @@
err, 'Path does not have any revision history: does-not-exist')
def test_log_with_tags(self):
- self._prepare(format='dirstate-tags')
- self.run_bzr('tag -r1 tag1')
- self.run_bzr('tag -r1 tag1.1')
- self.run_bzr('tag tag3')
+ tree = self._prepare(format='dirstate-tags')
+ branch = tree.branch
+ branch.tags.set_tag('tag1', branch.get_rev_id(1))
+ branch.tags.set_tag('tag1.1', branch.get_rev_id(1))
+ branch.tags.set_tag('tag3', branch.last_revision())
log = self.run_bzr("log -r-1")[0]
self.assertTrue('tags: tag3' in log)
@@ -141,17 +135,14 @@
self.assertContainsRe(log, r'tags: (tag1, tag1\.1|tag1\.1, tag1)')
def test_merged_log_with_tags(self):
- os.mkdir('branch1')
- os.chdir('branch1')
- self._prepare(format='dirstate-tags')
- os.chdir('..')
- self.run_bzr('branch branch1 branch2')
- os.chdir('branch1')
- self.run_bzr('commit -m foobar --unchanged')
- self.run_bzr('tag tag1')
- os.chdir('../branch2')
- self.run_bzr('merge ../branch1')
- self.run_bzr(['commit', '-m', 'merge branch 1'])
+ branch1_tree = self._prepare(path='branch1', format='dirstate-tags')
+ branch1 = branch1_tree.branch
+ branch2_tree = branch1_tree.bzrdir.sprout('branch2').open_workingtree()
+ branch1_tree.commit(message='foobar', allow_pointless=True)
+ branch1.tags.set_tag('tag1', branch1.last_revision())
+ os.chdir('branch2')
+ self.run_bzr('merge ../branch1') # tags don't propagate otherwise
+ branch2_tree.commit(message='merge branch 1')
log = self.run_bzr("log -r-1")[0]
self.assertContainsRe(log, r' tags: tag1')
log = self.run_bzr("log -r3.1.1")[0]
@@ -167,20 +158,18 @@
class TestLogMerges(ExternalBase):
def _prepare(self):
- self.build_tree(['parent/'])
- self.run_bzr('init parent')
- self.run_bzr(['commit', '-m', 'first post', '--unchanged', 'parent'])
- self.run_bzr('branch parent child')
- self.run_bzr(['commit', '-m', 'branch 1', '--unchanged', 'child'])
- self.run_bzr('branch child smallerchild')
- self.run_bzr(['commit', '-m', 'branch 2', '--unchanged',
- 'smallerchild'])
- os.chdir('child')
- self.run_bzr('merge ../smallerchild')
- self.run_bzr(['commit', '-m', 'merge branch 2'])
- os.chdir('../parent')
- self.run_bzr('merge ../child')
- self.run_bzr(['commit', '-m', 'merge branch 1'])
+ parent_tree = self.make_branch_and_tree('parent')
+ parent_tree.commit(message='first post', allow_pointless=True)
+ child_tree = parent_tree.bzrdir.sprout('child').open_workingtree()
+ child_tree.commit(message='branch 1', allow_pointless=True)
+ smaller_tree = \
+ child_tree.bzrdir.sprout('smallerchild').open_workingtree()
+ smaller_tree.commit(message='branch 2', allow_pointless=True)
+ child_tree.merge_from_branch(smaller_tree.branch)
+ child_tree.commit(message='merge branch 2')
+ parent_tree.merge_from_branch(child_tree.branch)
+ parent_tree.commit(message='merge branch 1')
+ os.chdir('parent')
def test_merges_are_indented_by_level(self):
self._prepare()
@@ -438,12 +427,12 @@
tree.commit('add file2')
tree.add('file3')
tree.commit('add file3')
- self.run_bzr('branch parent child')
- print >> file('child/file2', 'wb'), 'hello'
- self.run_bzr(['commit', '-m', 'branch 1', 'child'])
+ child_tree = tree.bzrdir.sprout('child').open_workingtree()
+ self.build_tree_contents([('child/file2', 'hello')])
+ child_tree.commit(message='branch 1')
+ tree.merge_from_branch(child_tree.branch)
+ tree.commit(message='merge child branch')
os.chdir('parent')
- self.run_bzr('merge ../child')
- self.run_bzr(['commit', '-m', 'merge child branch'])
log = self.run_bzr('log file1')[0]
self.assertContainsRe(log, 'revno: 1\n')
self.assertNotContainsRe(log, 'revno: 2\n')
=== modified file 'bzrlib/tests/blackbox/test_missing.py'
--- a/bzrlib/tests/blackbox/test_missing.py 2007-06-26 20:32:49 +0000
+++ b/bzrlib/tests/blackbox/test_missing.py 2007-08-08 12:48:16 +0000
@@ -29,35 +29,30 @@
class TestMissing(TestCaseWithTransport):
def test_missing(self):
- def bzr(*args, **kwargs):
- return self.run_bzr(*args, **kwargs)[0]
missing = "You are missing 1 revision(s):"
# create a source branch
- os.mkdir('a')
- os.chdir('a')
- bzr('init')
- open('a', 'wb').write('initial\n')
- bzr('add a')
- bzr('commit -m inital')
+ a_tree = self.make_branch_and_tree('a')
+ self.build_tree_contents([('a/a', 'initial\n')])
+ a_tree.add('a')
+ a_tree.commit(message='initial')
# clone and add a differing revision
- bzr('branch . ../b')
- os.chdir('../b')
- open('a', 'ab').write('more\n')
- bzr('commit -m more')
+ b_tree = a_tree.bzrdir.sprout('b').open_workingtree()
+ self.build_tree_contents([('b/a', 'initial\nmore\n')])
+ b_tree.commit(message='more')
# run missing in a against b
- os.chdir('../a')
# this should not require missing to take out a write lock on a
# or b. So we take a write lock on both to test that at the same
# time. This may let the test pass while the default branch is an
# os-locking branch, but it will trigger failures with lockdir based
# branches.
- branch_a = Branch.open('.')
- branch_a.lock_write()
- branch_b = Branch.open('../b')
- branch_b.lock_write()
+ a_branch = a_tree.branch
+ a_branch.lock_write()
+ b_branch = b_tree.branch
+ b_branch.lock_write()
+ os.chdir('a')
out,err = self.run_bzr('missing ../b', retcode=1)
lines = out.splitlines()
# we're missing the extra revision here
@@ -68,68 +63,67 @@
# we do not expect any error output.
self.assertEqual('', err)
# unlock the branches for the rest of the test
- branch_a.unlock()
- branch_b.unlock()
+ a_branch.unlock()
+ b_branch.unlock()
# get extra revision from b
- bzr('merge ../b')
- bzr('commit -m merge')
+ a_tree.merge_from_branch(b_branch)
+ a_tree.commit(message='merge')
# compare again, but now we have the 'merge' commit extra
- lines = bzr('missing ../b', retcode=1).splitlines()
+ lines = self.run_bzr('missing ../b', retcode=1)[0].splitlines()
self.assertEqual("You have 1 extra revision(s):", lines[0])
self.assertEqual(8, len(lines))
- lines2 = bzr('missing ../b --mine-only', retcode=1)
+ lines2 = self.run_bzr('missing ../b --mine-only', retcode=1)[0]
lines2 = lines2.splitlines()
self.assertEqual(lines, lines2)
- lines3 = bzr('missing ../b --theirs-only', retcode=1)
+ lines3 = self.run_bzr('missing ../b --theirs-only', retcode=1)[0]
lines3 = lines3.splitlines()
self.assertEqual(0, len(lines3))
# relative to a, missing the 'merge' commit
os.chdir('../b')
- lines = bzr('missing ../a', retcode=1).splitlines()
+ lines = self.run_bzr('missing ../a', retcode=1)[0].splitlines()
self.assertEqual(missing, lines[0])
self.assertEqual(8, len(lines))
- lines2 = bzr('missing ../a --theirs-only', retcode=1)
+ lines2 = self.run_bzr('missing ../a --theirs-only', retcode=1)[0]
lines2 = lines2.splitlines()
self.assertEqual(lines, lines2)
- lines3 = bzr('missing ../a --mine-only', retcode=1)
+ lines3 = self.run_bzr('missing ../a --mine-only', retcode=1)[0]
lines3 = lines3.splitlines()
self.assertEqual(0, len(lines3))
- lines4 = bzr('missing ../a --short', retcode=1)
+ lines4 = self.run_bzr('missing ../a --short', retcode=1)[0]
lines4 = lines4.splitlines()
self.assertEqual(4, len(lines4))
- lines5 = bzr('missing ../a --line', retcode=1)
+ lines5 = self.run_bzr('missing ../a --line', retcode=1)[0]
lines5 = lines5.splitlines()
self.assertEqual(2, len(lines5))
- lines6 = bzr('missing ../a --reverse', retcode=1)
+ lines6 = self.run_bzr('missing ../a --reverse', retcode=1)[0]
lines6 = lines6.splitlines()
self.assertEqual(lines6, lines)
- lines7 = bzr('missing ../a --show-ids', retcode=1)
+ lines7 = self.run_bzr('missing ../a --show-ids', retcode=1)[0]
lines7 = lines7.splitlines()
self.assertEqual(11, len(lines7))
- lines8 = bzr('missing ../a --verbose', retcode=1)
+ lines8 = self.run_bzr('missing ../a --verbose', retcode=1)[0]
lines8 = lines8.splitlines()
self.assertEqual("modified:", lines8[-2])
self.assertEqual(" a", lines8[-1])
# after a pull we're back on track
- bzr('pull')
- self.assertEqual("Branches are up to date.\n", bzr('missing ../a'))
+ b_tree.pull(a_branch)
+ self.assertEqual("Branches are up to date.\n", self.run_bzr('missing ../a')[0])
def test_missing_check_last_location(self):
# check that last location shown as filepath not file URL
# create a source branch
- os.mkdir('a')
- os.chdir('a')
- wt = self.make_branch_and_tree('.')
+ wt = self.make_branch_and_tree('a')
b = wt.branch
- self.build_tree(['foo'])
+ self.build_tree(['a/foo'])
wt.add('foo')
wt.commit('initial')
+ os.chdir('a')
location = osutils.getcwd() + '/'
# clone
More information about the bazaar-commits
mailing list