29
27
class TestMissing(TestCaseWithTransport):
29
def assertMessages(self, out, must_have=(), must_not_have=()):
30
"""Check if commit messages are in or not in the output"""
32
self.assertContainsRe(out, r'\nmessage:\n %s\n' % m)
33
for m in must_not_have:
34
self.assertNotContainsRe(out, r'\nmessage:\n %s\n' % m)
36
def test_missing_quiet(self):
37
# <https://bugs.launchpad.net/bzr/+bug/284748>
38
# create a source branch
40
# XXX: This still needs a test that missing is quiet when there are
42
a_tree = self.make_branch_and_tree('.')
43
self.build_tree_contents([('a', 'initial\n')])
45
a_tree.commit(message='initial')
47
out, err = self.run_bzr('missing -q .')
48
self.assertEqual('', out)
49
self.assertEqual('', err)
31
51
def test_missing(self):
32
52
missing = "You are missing 1 revision(s):"
43
63
b_tree.commit(message='more')
45
65
# run missing in a against b
46
# this should not require missing to take out a write lock on a
66
# this should not require missing to take out a write lock on a
47
67
# or b. So we take a write lock on both to test that at the same
48
68
# time. This may let the test pass while the default branch is an
49
69
# os-locking branch, but it will trigger failures with lockdir based
80
100
lines3 = self.run_bzr('missing ../b --theirs-only', retcode=0)[0]
81
101
self.assertEqualDiff('Other branch is up to date.\n', lines3)
83
# relative to a, missing the 'merge' commit
103
# relative to a, missing the 'merge' commit
85
105
lines = self.run_bzr('missing ../a', retcode=1)[0].splitlines()
86
106
self.assertEqual(missing, lines[0])
124
144
self.assertEqualDiff('Other branch is up to date.\n',
125
145
self.run_bzr('missing ../a --theirs-only')[0])
147
def test_missing_filtered(self):
148
# create a source branch
149
a_tree = self.make_branch_and_tree('a')
150
self.build_tree_contents([('a/a', 'initial\n')])
152
a_tree.commit(message='r1')
153
# clone and add differing revisions
154
b_tree = a_tree.bzrdir.sprout('b').open_workingtree()
156
for i in range(2, 6):
157
a_tree.commit(message='a%d' % i)
158
b_tree.commit(message='b%d' % i)
162
out,err = self.run_bzr('missing ../b --my-revision 3', retcode=1)
163
self.assertMessages(out, ('a3', 'b2', 'b3', 'b4', 'b5'), ('a2', 'a4'))
165
out,err = self.run_bzr('missing ../b --my-revision 3..4', retcode=1)
166
self.assertMessages(out, ('a3', 'a4'), ('a2', 'a5'))
169
out,err = self.run_bzr('missing ../b -r 3', retcode=1)
170
self.assertMessages(out, ('a2', 'a3', 'a4', 'a5', 'b3'), ('b2', 'b4'))
172
out,err = self.run_bzr('missing ../b -r 3..4', retcode=1)
173
self.assertMessages(out, ('b3', 'b4'), ('b2', 'b5'))
176
out,err = self.run_bzr('missing ../b --my-revision 3..4 -r 3..4',
178
self.assertMessages(out, ('a3', 'a4', 'b3', 'b4'),
179
('a2', 'a5', 'b2', 'b5'))
127
181
def test_missing_check_last_location(self):
128
182
# check that last location shown as filepath not file URL
143
197
# check last location
144
198
lines, err = self.run_bzr('missing', working_dir='../b')
145
self.assertEquals('Using last location: %s\n'
199
self.assertEquals('Using saved parent location: %s\n'
146
200
'Branches are up to date.\n' % location,
148
202
self.assertEquals('', err)