~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Aaron Bentley
  • Date: 2007-12-17 16:04:08 UTC
  • mto: (1551.19.24 Aaron's mergeable stuff)
  • mto: This revision was merged to the branch mainline in revision 3187.
  • Revision ID: abentley@panoramicfeedback.com-20071217160408-cyyassjx3lsw088c
Merge prefers submit branch, but falls back to parent branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
2888
2888
        from bzrlib.tag import _merge_tags_if_possible
2889
2889
        assert revision is None or len(revision) < 3
2890
2890
        # find the branch locations
2891
 
        other_loc, location = self._select_branch_location(tree, location,
 
2891
        other_loc, user_location = self._select_branch_location(tree, location,
2892
2892
            revision, -1)
2893
2893
        if revision is not None and len(revision) == 2:
2894
 
            base_loc, location = self._select_branch_location(tree, location,
2895
 
                                                              revision, 0)
 
2894
            base_loc, _unused = self._select_branch_location(tree,
 
2895
                location, revision, 0)
2896
2896
        else:
2897
2897
            base_loc = other_loc
2898
2898
        # Open the branches
2919
2919
        else:
2920
2920
            base_revision_id = None
2921
2921
        # Remember where we merge from
2922
 
        if ((tree.branch.get_parent() is None or remember) and
2923
 
            other_branch is not None):
2924
 
            tree.branch.set_parent(other_branch.base)
 
2922
        if ((remember or tree.branch.get_submit_branch() is None) and
 
2923
             user_location is not None):
 
2924
            tree.branch.set_submit_branch(other_branch.base)
2925
2925
        _merge_tags_if_possible(other_branch, tree.branch)
2926
2926
        merger = _mod_merge.Merger.from_revision_ids(pb, tree,
2927
2927
            other_revision_id, base_revision_id, other_branch, base_branch)
2932
2932
            allow_pending = True
2933
2933
        return merger, allow_pending
2934
2934
 
2935
 
    def _select_branch_location(self, tree, location, revision=None,
 
2935
    def _select_branch_location(self, tree, user_location, revision=None,
2936
2936
                                index=None):
2937
2937
        """Select a branch location, according to possible inputs.
2938
2938
 
2940
2940
        ``revision`` and ``index`` must be supplied.)
2941
2941
 
2942
2942
        Otherwise, the ``location`` parameter is used.  If it is None, then the
2943
 
        ``parent`` location is used, and a note is printed.
 
2943
        ``submit`` or ``parent`` location is used, and a note is printed.
2944
2944
 
2945
2945
        :param tree: The working tree to select a branch for merging into
2946
2946
        :param location: The location entered by the user
2947
2947
        :param revision: The revision parameter to the command
2948
2948
        :param index: The index to use for the revision parameter.  Negative
2949
2949
            indices are permitted.
2950
 
        :return: (selected_location, default_location).  The default location
2951
 
            will be the user-entered location, if any, or else the remembered
2952
 
            location.
 
2950
        :return: (selected_location, user_location).  The default location
 
2951
            will be the user-entered location.
2953
2952
        """
2954
2953
        if (revision is not None and index is not None
2955
2954
            and revision[index] is not None):
2956
2955
            branch = revision[index].get_branch()
2957
2956
            if branch is not None:
2958
 
                return branch, location
2959
 
        location = self._get_remembered_parent(tree, location, 'Merging from')
2960
 
        return location, location
 
2957
                return branch, branch
 
2958
        if user_location is None:
 
2959
            location = self._get_remembered(tree, 'Merging from')
 
2960
        else:
 
2961
            location = user_location
 
2962
        return location, user_location
2961
2963
 
2962
 
    # TODO: move up to common parent; this isn't merge-specific anymore. 
2963
 
    def _get_remembered_parent(self, tree, supplied_location, verb_string):
 
2964
    def _get_remembered(self, tree, verb_string):
2964
2965
        """Use tree.branch's parent if none was supplied.
2965
2966
 
2966
2967
        Report if the remembered location was used.
2967
2968
        """
2968
 
        if supplied_location is not None:
2969
 
            return supplied_location
2970
 
        stored_location = tree.branch.get_parent()
 
2969
        stored_location = tree.branch.get_submit_branch()
 
2970
        if stored_location is None:
 
2971
            stored_location = tree.branch.get_parent()
2971
2972
        mutter("%s", stored_location)
2972
2973
        if stored_location is None:
2973
2974
            raise errors.BzrCommandError("No location specified or remembered")