~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_missing.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-08-17 18:13:57 UTC
  • mfrom: (5268.7.29 transport-segments)
  • Revision ID: pqm@pqm.ubuntu.com-20110817181357-y5q5eth1hk8bl3om
(jelmer) Allow specifying the colocated branch to use in the branch URL,
 and retrieving the branch name using ControlDir._get_selected_branch.
 (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 Canonical Ltd
2
 
# -*- coding: utf-8 -*-
3
 
# vim: encoding=utf-8
 
1
# Copyright (C) 2005-2010 Canonical Ltd
4
2
#
5
3
# This program is free software; you can redistribute it and/or modify
6
4
# it under the terms of the GNU General Public License as published by
14
12
#
15
13
# You should have received a copy of the GNU General Public License
16
14
# along with this program; if not, write to the Free Software
17
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
16
 
19
17
"""Black-box tests for bzr missing."""
20
18
 
28
26
 
29
27
class TestMissing(TestCaseWithTransport):
30
28
 
 
29
    def assertMessages(self, out, must_have=(), must_not_have=()):
 
30
        """Check if commit messages are in or not in the output"""
 
31
        for m in must_have:
 
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)
 
35
 
 
36
    def test_missing_quiet(self):
 
37
        # <https://bugs.launchpad.net/bzr/+bug/284748>
 
38
        # create a source branch
 
39
        #
 
40
        # XXX: This still needs a test that missing is quiet when there are
 
41
        # missing revisions.
 
42
        a_tree = self.make_branch_and_tree('.')
 
43
        self.build_tree_contents([('a', 'initial\n')])
 
44
        a_tree.add('a')
 
45
        a_tree.commit(message='initial')
 
46
 
 
47
        out, err = self.run_bzr('missing -q .')
 
48
        self.assertEqual('', out)
 
49
        self.assertEqual('', err)
 
50
 
31
51
    def test_missing(self):
32
52
        missing = "You are missing 1 revision(s):"
33
53
 
43
63
        b_tree.commit(message='more')
44
64
 
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)
82
102
 
83
 
        # relative to a, missing the 'merge' commit 
 
103
        # relative to a, missing the 'merge' commit
84
104
        os.chdir('../b')
85
105
        lines = self.run_bzr('missing ../a', retcode=1)[0].splitlines()
86
106
        self.assertEqual(missing, lines[0])
93
113
        lines4 = self.run_bzr('missing ../a --short', retcode=1)[0]
94
114
        lines4 = lines4.splitlines()
95
115
        self.assertEqual(4, len(lines4))
 
116
        lines4a = self.run_bzr('missing ../a -S', retcode=1)[0]
 
117
        lines4a = lines4a.splitlines()
 
118
        self.assertEqual(lines4, lines4a)
96
119
        lines5 = self.run_bzr('missing ../a --line', retcode=1)[0]
97
120
        lines5 = lines5.splitlines()
98
121
        self.assertEqual(2, len(lines5))
124
147
        self.assertEqualDiff('Other branch is up to date.\n',
125
148
                             self.run_bzr('missing ../a --theirs-only')[0])
126
149
 
 
150
    def test_missing_filtered(self):
 
151
        # create a source branch
 
152
        a_tree = self.make_branch_and_tree('a')
 
153
        self.build_tree_contents([('a/a', 'initial\n')])
 
154
        a_tree.add('a')
 
155
        a_tree.commit(message='r1')
 
156
        # clone and add differing revisions
 
157
        b_tree = a_tree.bzrdir.sprout('b').open_workingtree()
 
158
 
 
159
        for i in range(2, 6):
 
160
            a_tree.commit(message='a%d' % i)
 
161
            b_tree.commit(message='b%d' % i)
 
162
 
 
163
        os.chdir('a')
 
164
        # local
 
165
        out,err = self.run_bzr('missing ../b --my-revision 3', retcode=1)
 
166
        self.assertMessages(out, ('a3', 'b2', 'b3', 'b4', 'b5'), ('a2', 'a4'))
 
167
 
 
168
        out,err = self.run_bzr('missing ../b --my-revision 3..4', retcode=1)
 
169
        self.assertMessages(out, ('a3', 'a4'), ('a2', 'a5'))
 
170
 
 
171
        #remote
 
172
        out,err = self.run_bzr('missing ../b -r 3', retcode=1)
 
173
        self.assertMessages(out, ('a2', 'a3', 'a4', 'a5', 'b3'), ('b2', 'b4'))
 
174
 
 
175
        out,err = self.run_bzr('missing ../b -r 3..4', retcode=1)
 
176
        self.assertMessages(out, ('b3', 'b4'), ('b2', 'b5'))
 
177
 
 
178
        #both
 
179
        out,err = self.run_bzr('missing ../b --my-revision 3..4 -r 3..4',
 
180
            retcode=1)
 
181
        self.assertMessages(out, ('a3', 'a4', 'b3', 'b4'),
 
182
            ('a2', 'a5', 'b2', 'b5'))
 
183
 
127
184
    def test_missing_check_last_location(self):
128
185
        # check that last location shown as filepath not file URL
129
186
 
146
203
                          'Branches are up to date.\n' % location,
147
204
                          lines)
148
205
        self.assertEquals('', err)
 
206
 
 
207
    def test_missing_directory(self):
 
208
        """Test --directory option"""
 
209
 
 
210
        # create a source branch
 
211
        a_tree = self.make_branch_and_tree('a')
 
212
        self.build_tree_contents([('a/a', 'initial\n')])
 
213
        a_tree.add('a')
 
214
        a_tree.commit(message='initial')
 
215
 
 
216
        # clone and add a differing revision
 
217
        b_tree = a_tree.bzrdir.sprout('b').open_workingtree()
 
218
        self.build_tree_contents([('b/a', 'initial\nmore\n')])
 
219
        b_tree.commit(message='more')
 
220
        
 
221
        out2, err2 = self.run_bzr('missing --directory a b', retcode=1)
 
222
        os.chdir('a')
 
223
        out1, err1 = self.run_bzr('missing ../b', retcode=1)
 
224
        self.assertEqualDiff(out1, out2)
 
225
        self.assertEqualDiff(err1, err2)