~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_branch/test_bound_sftp.py

  • Committer: Robert Collins
  • Date: 2010-04-08 04:34:03 UTC
  • mfrom: (5138 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5139.
  • Revision ID: robertc@robertcollins.net-20100408043403-56z0d07vdqrx7f3t
Update bugfix for 528114 to trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 Robey Pointer <robey@lag.net>, Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2009, 2010 Robey Pointer <robey@lag.net>, 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
import os
21
21
 
22
 
import bzrlib
23
22
from bzrlib import (
 
23
    branch,
24
24
    bzrdir,
 
25
    errors,
 
26
    tests,
25
27
    )
26
 
from bzrlib.branch import Branch
27
 
from bzrlib.bzrdir import (BzrDir,
28
 
                           BzrDirFormat,
29
 
                           BzrDirFormat6,
30
 
                           BzrDirMetaFormat1,
31
 
                           )
32
 
import bzrlib.errors as errors
33
 
from bzrlib.tests import TestSkipped
34
 
from bzrlib.tests import TestCaseWithTransport
35
 
from bzrlib.transport.local import LocalURLServer
36
 
from bzrlib.transport.memory import MemoryServer
37
 
 
38
 
 
39
 
class BoundSFTPBranch(TestCaseWithTransport):
 
28
from bzrlib.tests import test_server
 
29
from bzrlib.transport import memory
 
30
 
 
31
 
 
32
class BoundSFTPBranch(tests.TestCaseWithTransport):
40
33
 
41
34
    def setUp(self):
42
 
        TestCaseWithTransport.setUp(self)
43
 
        self.vfs_transport_factory = MemoryServer
44
 
        if self.transport_server is LocalURLServer:
 
35
        tests.TestCaseWithTransport.setUp(self)
 
36
        self.vfs_transport_factory = memory.MemoryServer
 
37
        if self.transport_server is test_server.LocalURLServer:
45
38
            self.transport_server = None
46
39
 
47
40
    def create_branches(self):
48
41
        self.build_tree(['base/', 'base/a', 'base/b'])
49
42
        format = bzrdir.format_registry.make_bzrdir('knit')
50
43
        try:
51
 
            wt_base = BzrDir.create_standalone_workingtree(
 
44
            wt_base = bzrdir.BzrDir.create_standalone_workingtree(
52
45
                self.get_url('base'), format=format)
53
46
        except errors.NotLocalUrl:
54
 
            raise TestSkipped('Not a local URL')
 
47
            raise tests.TestSkipped('Not a local URL')
55
48
 
56
49
        b_base = wt_base.branch
57
50
 
60
53
        wt_base.commit('first', rev_id='r@b-1')
61
54
 
62
55
        wt_child = b_base.bzrdir.sprout('child').open_workingtree()
63
 
        self.sftp_base = Branch.open(self.get_url('base'))
 
56
        self.sftp_base = branch.Branch.open(self.get_url('base'))
64
57
        wt_child.branch.bind(self.sftp_base)
65
58
        # check the branch histories are ready for using in tests.
66
59
        self.assertEqual(['r@b-1'], b_base.revision_history())
70
63
    def test_simple_binding(self):
71
64
        self.build_tree(['base/', 'base/a', 'base/b', 'child/'])
72
65
        try:
73
 
            wt_base = BzrDir.create_standalone_workingtree(self.get_url('base'))
 
66
            wt_base = bzrdir.BzrDir.create_standalone_workingtree(
 
67
                self.get_url('base'))
74
68
        except errors.NotLocalUrl:
75
 
            raise TestSkipped('Not a local URL')
 
69
            raise tests.TestSkipped('Not a local URL')
76
70
 
77
71
        wt_base.add('a')
78
72
        wt_base.add('b')
83
77
        # may not be bindable-from, and we want to test the side effects etc
84
78
        # of bondage.
85
79
        format = bzrdir.format_registry.make_bzrdir('knit')
86
 
        b_child = BzrDir.create_branch_convenience('child', format=format)
 
80
        b_child = bzrdir.BzrDir.create_branch_convenience(
 
81
            'child', format=format)
87
82
        self.assertEqual(None, b_child.get_bound_location())
88
83
        self.assertEqual(None, b_child.get_master_branch())
89
84
 
90
 
        sftp_b_base = Branch.open(self.get_url('base'))
 
85
        sftp_b_base = branch.Branch.open(self.get_url('base'))
91
86
        b_child.bind(sftp_b_base)
92
87
        self.assertEqual(sftp_b_base.base, b_child.get_bound_location())
93
88
        # the bind must not have given b_child history:
125
120
        self.assertRaises(errors.BoundBranchOutOfDate,
126
121
                wt_child.commit, 'child', rev_id='r@c-2')
127
122
 
128
 
        sftp_b_base = Branch.open(self.get_url('base'))
 
123
        sftp_b_base = branch.Branch.open(self.get_url('base'))
129
124
 
130
125
        # This is all that cmd_update does
131
126
        wt_child.pull(sftp_b_base, overwrite=False)
170
165
        self.assertEqual(['r@b-1', 'r@c-2'], wt_child.branch.revision_history())
171
166
        self.assertEqual(['r@b-1', 'r@b-2'], b_base.revision_history())
172
167
 
173
 
        sftp_b_base = Branch.open(self.get_url('base'))
 
168
        sftp_b_base = branch.Branch.open(self.get_url('base'))
174
169
        self.assertRaises(errors.DivergedBranches,
175
170
                wt_child.branch.bind, sftp_b_base)
176
171
 
181
176
 
182
177
        b_base.bzrdir.sprout('newbase')
183
178
 
184
 
        sftp_b_base = Branch.open(self.get_url('base'))
185
 
        sftp_b_newbase = Branch.open(self.get_url('newbase'))
 
179
        sftp_b_base = branch.Branch.open(self.get_url('base'))
 
180
        sftp_b_newbase = branch.Branch.open(self.get_url('newbase'))
186
181
 
187
182
        sftp_b_base.bind(sftp_b_newbase)
188
183
 
208
203
        b_base.bzrdir.open_workingtree().commit('base', rev_id='r@b-2')
209
204
        self.assertEqual(['r@b-1', 'r@b-2'], b_base.revision_history())
210
205
 
211
 
        sftp_b_base = Branch.open(self.get_url('base'))
 
206
        sftp_b_base = branch.Branch.open(self.get_url('base'))
212
207
 
213
208
        self.assertRaises(errors.DivergedBranches,
214
209
                wt_child.branch.bind, sftp_b_base)
236
231
        self.assertEqual(['r@b-1', 'r@b-2'], b_base.revision_history())
237
232
        self.assertEqual(['r@b-1'], wt_child.branch.revision_history())
238
233
 
239
 
        sftp_b_base = Branch.open(self.get_url('base'))
 
234
        sftp_b_base = branch.Branch.open(self.get_url('base'))
240
235
        wt_child.branch.bind(sftp_b_base)
241
236
 
242
237
        self.assertEqual(['r@b-1'], wt_child.branch.revision_history())
265
260
        self.assertEqual(['r@b-1', 'r@c-2'], wt_child.branch.revision_history())
266
261
        self.assertEqual(['r@b-1'], b_base.revision_history())
267
262
 
268
 
        sftp_b_base = Branch.open(self.get_url('base'))
 
263
        sftp_b_base = branch.Branch.open(self.get_url('base'))
269
264
        wt_child.branch.bind(sftp_b_base)
270
265
 
271
266
        self.assertEqual(['r@b-1'], b_base.revision_history())