~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Aaron Bentley
  • Date: 2007-12-21 02:25:16 UTC
  • mfrom: (1551.20.3 Aaron's mergeable stuff)
  • mto: This revision was merged to the branch mainline in revision 3187.
  • Revision ID: aaron.bentley@utoronto.ca-20071221022516-hd721fevdx6o7h8i
Merge from other bzr.ab

Show diffs side-by-side

added added

removed removed

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