~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/push.py

  • Committer: Tarmac
  • Author(s): Vincent Ladeuil
  • Date: 2017-01-30 14:42:05 UTC
  • mfrom: (6620.1.1 trunk)
  • Revision ID: tarmac-20170130144205-r8fh2xpmiuxyozpv
Merge  2.7 into trunk including fix for bug #1657238 [r=vila]

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2008-2012 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
16
16
 
17
17
"""UI helper for the push command."""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
19
21
from bzrlib import (
20
 
    bzrdir,
 
22
    controldir,
21
23
    errors,
22
24
    revision as _mod_revision,
23
25
    transport,
66
68
    :param location: the url of the destination
67
69
    :param to_file: the output stream
68
70
    :param verbose: if True, display more output than normal
69
 
    :param overwrite: if False, a current branch at the destination may not
70
 
        have diverged from the source, otherwise the push fails
 
71
    :param overwrite: list of things to overwrite ("history", "tags")
 
72
        or boolean indicating for everything
71
73
    :param remember: if True, store the location as the push location for
72
74
        the source branch
73
75
    :param stacked_on: the url of the branch, if any, to stack on;
79
81
    """
80
82
    to_transport = transport.get_transport(location)
81
83
    try:
82
 
        dir_to = bzrdir.BzrDir.open_from_transport(to_transport)
 
84
        dir_to = controldir.ControlDir.open_from_transport(to_transport)
83
85
    except errors.NotBranchError:
84
86
        # Didn't find anything
85
87
        dir_to = None
90
92
                revision_id=revision_id, stacked_on=stacked_on,
91
93
                create_prefix=create_prefix, use_existing_dir=use_existing_dir,
92
94
                no_tree=no_tree)
 
95
        except errors.AlreadyControlDirError, err:
 
96
            raise errors.BzrCommandError(gettext(
 
97
                "Target directory %s already contains a .bzr directory, "
 
98
                "but it is not valid.") % (location,))
93
99
        except errors.FileExists, err:
94
 
            if err.path.endswith('/.bzr'):
95
 
                raise errors.BzrCommandError(gettext(
96
 
                    "Target directory %s already contains a .bzr directory, "
97
 
                    "but it is not valid.") % (location,))
98
100
            if not use_existing_dir:
99
101
                raise errors.BzrCommandError(gettext("Target directory %s"
100
102
                     " already exists, but does not have a .bzr"
133
135
        # Remembers if asked explicitly or no previous location is set
134
136
        if (remember
135
137
            or (remember is None and br_from.get_push_location() is None)):
 
138
            # FIXME: Should be done only if we succeed ? -- vila 2012-01-18
136
139
            br_from.set_push_location(br_to.base)
137
140
    else:
138
141
        if stacked_on is not None:
150
153
                "push to %s. You may want to use dpush instead.") % 
151
154
                    e.target_branch.mapping.vcs.abbreviation)
152
155
        except errors.NoRepositoryPresent:
153
 
            # we have a bzrdir but no branch or repository
 
156
            # we have a controldir but no branch or repository
154
157
            # XXX: Figure out what to do other than complain.
155
158
            raise errors.BzrCommandError(gettext("At %s you have a valid .bzr"
156
159
                " control directory, but not a branch or repository. This"