363
363
self._check_bound_branch(operation, possible_master_transports)
365
365
# Check that the working tree is up to date
366
old_revno, new_revno = self._check_out_of_date_tree()
366
old_revno, old_revid, new_revno = self._check_out_of_date_tree()
368
368
# Complete configuration setup
369
369
if reporter is not None:
411
411
self.builder.abort()
412
412
raise errors.ExcludesUnsupported(self.branch.repository)
414
if self.builder.updates_branch and self.bound_branch:
416
raise AssertionError(
417
"bound branches not supported for commit builders "
418
"that update the branch")
415
421
self.builder.will_record_deletes()
416
422
# find the location being committed to
445
451
self.builder.abort()
448
self._process_pre_hooks(old_revno, new_revno)
450
# Upload revision data to the master.
451
# this will propagate merged revisions too if needed.
452
if self.bound_branch:
453
self._set_progress_stage("Uploading data to master branch")
454
# 'commit' to the master first so a timeout here causes the
455
# local branch to be out of date
456
(new_revno, self.rev_id) = self.master_branch.import_last_revision_info_and_tags(
457
self.branch, new_revno, self.rev_id, lossy=lossy)
459
self.branch.fetch(self.master_branch, self.rev_id)
461
# and now do the commit locally.
462
self.branch.set_last_revision_info(new_revno, self.rev_id)
464
# Merge local tags to remote
465
if self.bound_branch:
466
self._set_progress_stage("Merging tags to master branch")
467
tag_updates, tag_conflicts = self.branch.tags.merge_to(
468
self.master_branch.tags)
470
warning_lines = [' ' + name for name, _, _ in tag_conflicts]
471
note( gettext("Conflicting tags in bound branch:\n{0}".format(
472
"\n".join(warning_lines))) )
454
self._update_branches(old_revno, old_revid, new_revno)
474
456
# Make the working tree be up to date with the branch. This
475
457
# includes automatic changes scheduled to be made to the tree, such
482
464
self._process_post_hooks(old_revno, new_revno)
483
465
return self.rev_id
467
def _update_branches(self, old_revno, old_revid, new_revno):
468
"""Update the master and local branch to the new revision.
470
This will try to make sure that the master branch is updated
471
before the local branch.
473
:param old_revno: Revision number of master branch before the
475
:param old_revid: Tip of master branch before the commit
476
:param new_revno: Revision number of the new commit
478
if not self.builder.updates_branch:
479
self._process_pre_hooks(old_revno, new_revno)
481
# Upload revision data to the master.
482
# this will propagate merged revisions too if needed.
483
if self.bound_branch:
484
self._set_progress_stage("Uploading data to master branch")
485
# 'commit' to the master first so a timeout here causes the
486
# local branch to be out of date
487
(new_revno, self.rev_id) = self.master_branch.import_last_revision_info_and_tags(
488
self.branch, new_revno, self.rev_id, lossy=self._lossy)
490
self.branch.fetch(self.master_branch, self.rev_id)
492
# and now do the commit locally.
493
self.branch.set_last_revision_info(new_revno, self.rev_id)
496
self._process_pre_hooks(old_revno, new_revno)
498
# The commit builder will already have updated the branch,
500
self.branch.set_last_revision_info(old_revno, old_revid)
503
# Merge local tags to remote
504
if self.bound_branch:
505
self._set_progress_stage("Merging tags to master branch")
506
tag_updates, tag_conflicts = self.branch.tags.merge_to(
507
self.master_branch.tags)
509
warning_lines = [' ' + name for name, _, _ in tag_conflicts]
510
note( gettext("Conflicting tags in bound branch:\n{0}".format(
511
"\n".join(warning_lines))) )
485
513
def _select_reporter(self):
486
514
"""Select the CommitReporter to use."""
544
572
def _check_out_of_date_tree(self):
545
573
"""Check that the working tree is up to date.
547
:return: old_revision_number,new_revision_number tuple
575
:return: old_revision_number, old_revision_id, new_revision_number
550
579
first_tree_parent = self.work_tree.get_parent_ids()[0]
564
593
# ghost parents never appear in revision history.
566
return old_revno,new_revno
595
return old_revno, master_last, new_revno
568
597
def _process_pre_hooks(self, old_revno, new_revno):
569
598
"""Process any registered pre commit hooks."""