~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Ross Lagerwall
  • Date: 2012-08-07 06:32:51 UTC
  • mto: (6437.63.5 2.5)
  • mto: This revision was merged to the branch mainline in revision 6558.
  • Revision ID: rosslagerwall@gmail.com-20120807063251-x9p03ghg2ws8oqjc
Add bzrlib/locale to .bzrignore

bzrlib/locale is generated with ./setup.py build_mo which is in turn called
by ./setup.py build

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2012, 2016 Canonical Ltd
 
1
# Copyright (C) 2005-2012 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
19
19
 
20
20
from bzrlib import (
21
21
    branch,
22
 
    controldir,
 
22
    bzrdir,
23
23
    errors,
24
24
    tests,
25
25
    )
35
35
        base_tree.add(['a', 'b'])
36
36
        base_tree.commit('init')
37
37
        base_tree.unlock()
 
38
        branch = base_tree.branch
38
39
 
39
 
        child_tree = base_tree.branch.create_checkout('child')
 
40
        child_tree = branch.create_checkout('child')
40
41
 
41
42
        self.check_revno(1, 'child')
42
 
        d = controldir.ControlDir.open('child')
 
43
        d = bzrdir.BzrDir.open('child')
43
44
        self.assertNotEqual(None, d.open_branch().get_master_branch())
44
45
 
45
46
        return base_tree, child_tree
46
47
 
47
48
    def check_revno(self, val, loc='.'):
48
49
        self.assertEqual(
49
 
            val, controldir.ControlDir.open(loc).open_branch().last_revision_info()[0])
 
50
            val, bzrdir.BzrDir.open(loc).open_branch().last_revision_info()[0])
50
51
 
51
52
    def test_simple_binding(self):
52
53
        tree = self.make_branch_and_tree('base')
58
59
 
59
60
        self.run_bzr('bind ../base', working_dir='child')
60
61
 
61
 
        d = controldir.ControlDir.open('child')
 
62
        d = bzrdir.BzrDir.open('child')
62
63
        self.assertNotEqual(None, d.open_branch().get_master_branch())
63
64
 
64
65
        self.run_bzr('unbind', working_dir='child')
126
127
 
127
128
    def test_double_binding(self):
128
129
        child_tree = self.create_branches()[1]
129
 
        child_tree.bzrdir.sprout('child2')
 
130
 
 
131
        child2_tree = child_tree.bzrdir.sprout('child2').open_workingtree()
130
132
 
131
133
        # Double binding succeeds, but committing to child2 should fail
132
134
        self.run_bzr('bind ../child', working_dir='child2')
133
135
 
134
 
        # Refresh the child tree object as 'unbind' modified it
135
 
        child2_tree = controldir.ControlDir.open('child2').open_workingtree()
136
136
        self.assertRaises(errors.CommitToDoubleBoundBranch,
137
137
                child2_tree.commit, message='child2', allow_pointless=True)
138
138
 
150
150
        self.run_bzr("commit -m child", retcode=3, working_dir='child')
151
151
        self.check_revno(1, 'child')
152
152
        self.run_bzr('unbind', working_dir='child')
153
 
        # Refresh the child tree/branch objects as 'unbind' modified them
154
 
        child_tree = child_tree.bzrdir.open_workingtree()
155
153
        child_tree.commit(message='child')
156
154
        self.check_revno(2, 'child')
157
155
 
202
200
 
203
201
        self.run_bzr('unbind', working_dir='child')
204
202
 
205
 
        # Refresh the child tree/branch objects as 'unbind' modified them
206
 
        child_tree = child_tree.bzrdir.open_workingtree()
207
203
        child_tree.commit(message='child', allow_pointless=True)
208
204
        self.check_revno(2, 'child')
209
205
 
214
210
        # These branches have diverged, but bind should succeed anyway
215
211
        self.run_bzr('bind ../base', working_dir='child')
216
212
 
217
 
        # Refresh the child tree/branch objects as 'bind' modified them
218
 
        child_tree = child_tree.bzrdir.open_workingtree()
219
213
        # This should turn the local commit into a merge
220
214
        child_tree.update()
221
215
        child_tree.commit(message='merged')
222
216
        self.check_revno(3, 'child')
223
 
        self.assertEqual(child_tree.branch.last_revision(),
 
217
        self.assertEquals(child_tree.branch.last_revision(),
224
218
                          base_tree.branch.last_revision())
225
219
 
226
220
    def test_bind_parent_ahead(self):
254
248
        child_tree = self.create_branches()[1]
255
249
 
256
250
        self.run_bzr('unbind', working_dir='child')
257
 
        # Refresh the child tree/branch objects as 'bind' modified them
258
 
        child_tree = child_tree.bzrdir.open_workingtree()
259
251
        child_tree.commit(message='child', allow_pointless=True)
260
252
        self.check_revno(2, 'child')
261
253
        self.check_revno(1, 'base')
355
347
        branch = tree.branch
356
348
        tree.bzrdir.sprout('child')
357
349
        self.run_bzr('bind --directory=child base')
358
 
        d = controldir.ControlDir.open('child')
 
350
        d = bzrdir.BzrDir.open('child')
359
351
        self.assertNotEqual(None, d.open_branch().get_master_branch())
360
352
        self.run_bzr('unbind -d child')
361
353
        self.assertEqual(None, d.open_branch().get_master_branch())