~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/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
 
1
# Copyright (C) 2005-2009, 2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 
 
17
 
import os
18
 
 
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
16
 
20
17
from bzrlib import (
21
18
    missing,
25
22
    iter_log_revisions,
26
23
    )
27
24
from bzrlib.tests import TestCaseWithTransport
28
 
from bzrlib.workingtree import WorkingTree
29
25
 
30
26
 
31
27
class TestMissing(TestCaseWithTransport):
138
134
class TestFindUnmerged(tests.TestCaseWithTransport):
139
135
 
140
136
    def assertUnmerged(self, local, remote, local_branch, remote_branch,
141
 
                       restrict, include_merges=False,
142
 
                       backward=False):
 
137
            restrict='all', include_merges=False, backward=False,
 
138
            local_revid_range=None, remote_revid_range=None):
143
139
        """Check the output of find_unmerged_mainline_revisions"""
144
140
        local_extra, remote_extra = missing.find_unmerged(
145
 
                                        local_branch, remote_branch, restrict,
146
 
                                        include_merges=include_merges,
147
 
                                        backward=backward)
 
141
            local_branch, remote_branch, restrict,
 
142
            include_merges=include_merges, backward=backward,
 
143
            local_revid_range=local_revid_range,
 
144
            remote_revid_range=remote_revid_range)
148
145
        self.assertEqual(local, local_extra)
149
146
        self.assertEqual(remote, remote_extra)
150
147
 
153
150
        rev1 = tree.commit('one')
154
151
        tree.lock_read()
155
152
        self.addCleanup(tree.unlock)
156
 
        self.assertUnmerged([], [], tree.branch, tree.branch, 'all')
 
153
        self.assertUnmerged([], [], tree.branch, tree.branch)
 
154
        self.assertUnmerged([], [], tree.branch, tree.branch,
 
155
            local_revid_range=(rev1, rev1))
157
156
 
158
157
    def test_one_ahead(self):
159
158
        tree = self.make_branch_and_tree('tree')
160
159
        rev1 = tree.commit('one')
161
160
        tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
162
161
        rev2 = tree2.commit('two')
163
 
        self.assertUnmerged([], [('2', rev2)], tree.branch, tree2.branch, 'all')
164
 
        self.assertUnmerged([('2', rev2)], [], tree2.branch, tree.branch, 'all')
 
162
        self.assertUnmerged([], [('2', rev2)], tree.branch, tree2.branch)
 
163
        self.assertUnmerged([('2', rev2)], [], tree2.branch, tree.branch)
165
164
 
166
165
    def test_restrict(self):
167
166
        tree = self.make_branch_and_tree('tree')
168
167
        rev1 = tree.commit('one')
169
168
        tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
170
169
        rev2 = tree2.commit('two')
171
 
        self.assertUnmerged([], [('2', rev2)], tree.branch, tree2.branch, 'all')
 
170
        self.assertUnmerged([], [('2', rev2)], tree.branch, tree2.branch)
172
171
        self.assertUnmerged([], None, tree.branch, tree2.branch, 'local')
173
172
        self.assertUnmerged(None, [('2', rev2)], tree.branch, tree2.branch,
174
173
                                               'remote')
182
181
        tree.merge_from_branch(tree2.branch)
183
182
        rev4 = tree.commit('four')
184
183
 
185
 
        self.assertUnmerged([('2', rev4)], [], tree.branch, tree2.branch, 'all')
 
184
        self.assertUnmerged([('2', rev4)], [], tree.branch, tree2.branch)
 
185
        self.assertUnmerged([('2', rev4)], [], tree.branch, tree2.branch,
 
186
            local_revid_range=(rev4, rev4))
 
187
        self.assertUnmerged([], [], tree.branch, tree2.branch,
 
188
            local_revid_range=(rev1, rev1))
186
189
 
187
190
    def test_include_merges(self):
188
191
        tree = self.make_branch_and_tree('tree')
199
202
        tree2.merge_from_branch(tree3.branch)
200
203
        rev6 = tree2.commit('six', rev_id='rev6')
201
204
 
202
 
        self.assertUnmerged([], [('2', 'rev2', 0), ('3', 'rev3',0 ),
 
205
        self.assertUnmerged([], [('2', 'rev2', 0), ('3', 'rev3', 0),
203
206
                                 ('4', 'rev6', 0),
204
207
                                 ('3.1.1', 'rev4', 1), ('3.1.2', 'rev5', 1),
205
208
                                 ],
206
 
                            tree.branch, tree2.branch, 'all',
 
209
                            tree.branch, tree2.branch,
207
210
                            include_merges=True)
208
211
 
209
212
        self.assertUnmerged([], [('4', 'rev6', 0),
210
213
                                 ('3.1.2', 'rev5', 1), ('3.1.1', 'rev4', 1),
211
 
                                 ('3', 'rev3',0 ), ('2', 'rev2', 0),
 
214
                                 ('3', 'rev3', 0), ('2', 'rev2', 0),
212
215
                                 ],
213
 
                            tree.branch, tree2.branch, 'all',
 
216
                            tree.branch, tree2.branch,
214
217
                            include_merges=True,
215
218
                            backward=True)
 
219
 
 
220
        self.assertUnmerged([], [('4', 'rev6', 0)],
 
221
            tree.branch, tree2.branch,
 
222
            include_merges=True, remote_revid_range=(rev6, rev6))
 
223
 
 
224
        self.assertUnmerged([], [('3', 'rev3', 0), ('3.1.1', 'rev4', 1)],
 
225
                    tree.branch, tree2.branch,
 
226
                    include_merges=True, remote_revid_range=(rev3, rev4))
 
227
 
 
228
        self.assertUnmerged([], [('4', 'rev6', 0), ('3.1.2', 'rev5', 1)],
 
229
                    tree.branch, tree2.branch,
 
230
                    include_merges=True, remote_revid_range=(rev5, rev6))
 
231
 
 
232
    def test_revision_range(self):
 
233
        local = self.make_branch_and_tree('local')
 
234
        lrevid1 = local.commit('one')
 
235
        remote = local.bzrdir.sprout('remote').open_workingtree()
 
236
        rrevid2 = remote.commit('two')
 
237
        rrevid3 = remote.commit('three')
 
238
        rrevid4 = remote.commit('four')
 
239
        lrevid2 = local.commit('two')
 
240
        lrevid3 = local.commit('three')
 
241
        lrevid4 = local.commit('four')
 
242
        local_extra = [('2', lrevid2), ('3', lrevid3), ('4', lrevid4)]
 
243
        remote_extra = [('2', rrevid2), ('3', rrevid3), ('4', rrevid4)]
 
244
 
 
245
        # control
 
246
        self.assertUnmerged(local_extra, remote_extra,
 
247
            local.branch, remote.branch)
 
248
        self.assertUnmerged(local_extra, remote_extra,
 
249
            local.branch, remote.branch, local_revid_range=(None, None),
 
250
            remote_revid_range=(None, None))
 
251
 
 
252
        # exclude local revisions
 
253
        self.assertUnmerged([('2', lrevid2)], remote_extra,
 
254
            local.branch, remote.branch, local_revid_range=(lrevid2, lrevid2))
 
255
        self.assertUnmerged([('2', lrevid2), ('3', lrevid3)], remote_extra,
 
256
            local.branch, remote.branch, local_revid_range=(lrevid2, lrevid3))
 
257
        self.assertUnmerged([('2', lrevid2), ('3', lrevid3)], None,
 
258
            local.branch, remote.branch, 'local',
 
259
            local_revid_range=(lrevid2, lrevid3))
 
260
 
 
261
        # exclude remote revisions
 
262
        self.assertUnmerged(local_extra, [('2', rrevid2)],
 
263
            local.branch, remote.branch, remote_revid_range=(None, rrevid2))
 
264
        self.assertUnmerged(local_extra, [('2', rrevid2)],
 
265
            local.branch, remote.branch, remote_revid_range=(lrevid1, rrevid2))
 
266
        self.assertUnmerged(local_extra, [('2', rrevid2)],
 
267
            local.branch, remote.branch, remote_revid_range=(rrevid2, rrevid2))
 
268
        self.assertUnmerged(local_extra, [('2', rrevid2), ('3', rrevid3)],
 
269
            local.branch, remote.branch, remote_revid_range=(None, rrevid3))
 
270
        self.assertUnmerged(local_extra, [('2', rrevid2), ('3', rrevid3)],
 
271
            local.branch, remote.branch, remote_revid_range=(rrevid2, rrevid3))
 
272
        self.assertUnmerged(local_extra, [('3', rrevid3)],
 
273
            local.branch, remote.branch, remote_revid_range=(rrevid3, rrevid3))
 
274
        self.assertUnmerged(None, [('2', rrevid2), ('3', rrevid3)],
 
275
            local.branch, remote.branch, 'remote',
 
276
            remote_revid_range=(rrevid2, rrevid3))
 
277
 
 
278
        # exclude local and remote revisions
 
279
        self.assertUnmerged([('3', lrevid3)], [('3', rrevid3)],
 
280
            local.branch, remote.branch, local_revid_range=(lrevid3, lrevid3),
 
281
            remote_revid_range=(rrevid3, rrevid3))