42
42
self.failUnlessExists('child')
46
46
self.failUnlessExists('.bzr/bound')
49
def check_revno(self, val):
50
self.assertEquals(self.capture('bzr revno').strip(), val)
49
def check_revno(self, val, loc=None):
53
self.assertEquals(self.capture('bzr revno').strip(), str(val))
52
57
def test_bound_commit(self):
104
110
open('a', 'wb').write('new base contents\n')
105
111
bzr('commit', '-m', 'base')
106
self.check_revno('2')
108
114
os.chdir('../child')
109
115
open('b', 'wb').write('new b child contents\n')
110
self.check_revno('1')
111
117
bzr('commit', '-m', 'child', retcode=1)
112
self.check_revno('1')
114
120
bzr('commit', '-m', 'child')
115
self.check_revno('2')
117
123
bzr('bind', retcode=1)
125
def test_commit_remote_bound(self):
126
# It is not possible to commit to a branch
127
# which is bound to a branch which is bound
129
bzr('branch', 'base', 'newbase')
132
# There is no way to know that B has already
133
# been bound by someone else, otherwise it
134
# might be nice if this would fail
135
bzr('bind', '../newbase')
138
bzr('commit', '-m', 'failure', '--unchanged', retcode=1)
141
def test_pull_updates_both(self):
143
self.create_branches()
144
bzr('branch', 'base', 'newchild')
146
open('b', 'wb').write('newchild b contents\n')
147
bzr('commit', '-m', 'newchild')
151
# The pull should succeed, and update
152
# the bound parent branch
153
bzr('pull', '../newchild')
159
def test_bind_diverged(self):
161
self.create_branches()
166
bzr('commit', '-m', 'child', '--unchanged')
171
bzr('commit', '-m', 'base', '--unchanged')
175
# These branches have diverged
176
bzr('bind', '../base', retcode=1)
178
# TODO: In the future, this might require actual changes
179
# to have occurred, rather than just a new revision entry
180
bzr('merge', '../base')
181
bzr('commit', '-m', 'merged')
184
# This should also be possible by doing a 'bzr push' to the
185
# base, rather than doing 'bzr pull' from it
187
bzr('pull', '../child')
191
bzr('bind', '../base')
193
# After binding, the revision history should be identical
194
child_rh = self.capture('bzr revision-history')
196
base_rh = self.capture('bzr revision-history')
197
self.assertEquals(child_rh, base_rh)
199
def test_bind_parent_ahead(self):
201
self.create_branches()
207
bzr('commit', '-m', 'base', '--unchanged')
211
bzr('bind', '../base')
215
def test_bind_child_ahead(self):
217
self.create_branches()
221
bzr('commit', '-m', 'child', '--unchanged')
223
self.check_revno(1, '../base')
225
bzr('bind', '../base')
226
self.check_revno(2, '../base')