##// END OF EJS Templates
pull-requests: changed the order of close-branch after merge, so we don't leave open heads....
marcink -
r4436:37e7e17e default
parent child Browse files
Show More
@@ -628,34 +628,42 b' class MercurialRepository(BaseRepository'
628 628 push_branches=push_branches)
629 629
630 630 def _local_merge(self, target_ref, merge_message, user_name, user_email,
631 source_ref, use_rebase=False, dry_run=False):
631 source_ref, use_rebase=False, close_commit_id=None, dry_run=False):
632 632 """
633 633 Merge the given source_revision into the checked out revision.
634 634
635 635 Returns the commit id of the merge and a boolean indicating if the
636 636 commit needs to be pushed.
637 637 """
638 self._update(target_ref.commit_id, clean=True)
638 source_ref_commit_id = source_ref.commit_id
639 target_ref_commit_id = target_ref.commit_id
639 640
640 ancestor = self._ancestor(target_ref.commit_id, source_ref.commit_id)
641 # update our workdir to target ref, for proper merge
642 self._update(target_ref_commit_id, clean=True)
643
644 ancestor = self._ancestor(target_ref_commit_id, source_ref_commit_id)
641 645 is_the_same_branch = self._is_the_same_branch(target_ref, source_ref)
642 646
643 if ancestor == source_ref.commit_id:
644 # Nothing to do, the changes were already integrated
645 return target_ref.commit_id, False
647 if close_commit_id:
648 # NOTE(marcink): if we get the close commit, this is our new source
649 # which will include the close commit itself.
650 source_ref_commit_id = close_commit_id
646 651
647 elif ancestor == target_ref.commit_id and is_the_same_branch:
652 if ancestor == source_ref_commit_id:
653 # Nothing to do, the changes were already integrated
654 return target_ref_commit_id, False
655
656 elif ancestor == target_ref_commit_id and is_the_same_branch:
648 657 # In this case we should force a commit message
649 return source_ref.commit_id, True
658 return source_ref_commit_id, True
650 659
651 660 unresolved = None
652 661 if use_rebase:
653 662 try:
654 bookmark_name = 'rcbook%s%s' % (source_ref.commit_id,
655 target_ref.commit_id)
663 bookmark_name = 'rcbook%s%s' % (source_ref_commit_id, target_ref_commit_id)
656 664 self.bookmark(bookmark_name, revision=source_ref.commit_id)
657 665 self._remote.rebase(
658 source=source_ref.commit_id, dest=target_ref.commit_id)
666 source=source_ref_commit_id, dest=target_ref_commit_id)
659 667 self._remote.invalidate_vcs_cache()
660 668 self._update(bookmark_name, clean=True)
661 669 return self._identify(), True
@@ -678,7 +686,7 b' class MercurialRepository(BaseRepository'
678 686 raise
679 687 else:
680 688 try:
681 self._remote.merge(source_ref.commit_id)
689 self._remote.merge(source_ref_commit_id)
682 690 self._remote.invalidate_vcs_cache()
683 691 self._remote.commit(
684 692 message=safe_str(merge_message),
@@ -820,10 +828,12 b' class MercurialRepository(BaseRepository'
820 828
821 829 needs_push = False
822 830 if merge_possible:
831
823 832 try:
824 833 merge_commit_id, needs_push = shadow_repo._local_merge(
825 834 target_ref, merge_message, merger_name, merger_email,
826 source_ref, use_rebase=use_rebase, dry_run=dry_run)
835 source_ref, use_rebase=use_rebase,
836 close_commit_id=close_commit_id, dry_run=dry_run)
827 837 merge_possible = True
828 838
829 839 # read the state of the close action, if it
@@ -2053,9 +2053,9 b' class MergeCheck(object):'
2053 2053 repo_type = pull_request.target_repo.repo_type
2054 2054 close_msg = ''
2055 2055 if repo_type == 'hg':
2056 close_msg = _('Source branch will be closed after merge.')
2056 close_msg = _('Source branch will be closed before the merge.')
2057 2057 elif repo_type == 'git':
2058 close_msg = _('Source branch will be deleted after merge.')
2058 close_msg = _('Source branch will be deleted after the merge.')
2059 2059
2060 2060 merge_details['close_branch'] = dict(
2061 2061 details={},
General Comments 0
You need to be logged in to leave comments. Login now