13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
17
"""Black-box tests for bzr missing."""
27
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
29
def test_missing_quiet(self):
37
30
# <https://bugs.launchpad.net/bzr/+bug/284748>
38
31
# create a source branch
63
56
b_tree.commit(message='more')
65
58
# run missing in a against b
66
# this should not require missing to take out a write lock on a
59
# this should not require missing to take out a write lock on a
67
60
# or b. So we take a write lock on both to test that at the same
68
61
# time. This may let the test pass while the default branch is an
69
62
# os-locking branch, but it will trigger failures with lockdir based
100
93
lines3 = self.run_bzr('missing ../b --theirs-only', retcode=0)[0]
101
94
self.assertEqualDiff('Other branch is up to date.\n', lines3)
103
# relative to a, missing the 'merge' commit
96
# relative to a, missing the 'merge' commit
105
98
lines = self.run_bzr('missing ../a', retcode=1)[0].splitlines()
106
99
self.assertEqual(missing, lines[0])
144
137
self.assertEqualDiff('Other branch is up to date.\n',
145
138
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'))
181
140
def test_missing_check_last_location(self):
182
141
# check that last location shown as filepath not file URL