285
291
'rev_id':self.rev_id})
293
self._cleanup_bound_branch()
287
294
self.branch.unlock()
296
def _check_bound_branch(self):
297
"""Check to see if the local branch is bound.
299
If it is bound, then most of the commit will actually be
300
done using the remote branch as the target branch.
301
Only at the end will the local branch be updated.
303
# TODO: jam 20051230 Consider a special error for the case
304
# where the local branch is bound, and can't access the
306
self.master_branch = self.branch.get_bound_branch()
307
if not self.master_branch:
310
# If the master branch is bound, we must fail
311
master_bound_location = self.master_branch.get_bound_location()
312
if master_bound_location:
313
raise CommitToDoubleBoundBranch(self.branch,
314
self.master_branch, master_bound_location)
316
# TODO: jam 20051230 We could automatically push local
317
# commits to the remote branch if they would fit.
318
# But for now, just require remote to be identical
321
# Make sure the local branch is identical to the master
322
master_rh = self.master_branch.revision_history()
323
local_rh = self.branch.revision_history()
324
if local_rh != master_rh:
325
raise errors.BoundBranchOutOfDate(self.branch,
328
# Now things are ready to change the master branch
330
self.bound_branch = self.branch
331
self.master_branch.lock_write()
332
self.branch = self.master_branch
334
# Check to see if we have any pending merges. If we do
335
# those need to be pushed into the master branch
336
pending_merges = self.work_tree.pending_merges()
338
from bzrlib.fetch import fetch
339
for revision_id in pending_merges:
340
fetch(self.master_branch, self.bound_branch, revision_id)
342
def _cleanup_bound_branch(self):
343
"""Executed at the end of a try/finally to cleanup a bound branch.
345
If the branch wasn't bound, this is a no-op.
346
If it was, it resents self.branch to the local branch, instead
349
if not self.bound_branch:
351
self.branch = self.bound_branch
352
self.master_branch.unlock()
354
def _update_bound_branch(self):
355
"""Update the local bound branch, after commit.
357
This only runs if the commit to the remote branch succeeds.
359
if not self.bound_branch:
361
# We always want the local branch to look like the remote one
362
self.bound_branch.pull(self.master_branch)
289
364
def _record_inventory(self):
290
365
"""Store the inventory for the new revision."""
291
366
inv_text = serializer_v5.write_inventory_to_string(self.new_inv)