~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/push.py

  • Committer: Vincent Ladeuil
  • Date: 2011-11-24 15:48:29 UTC
  • mfrom: (6289 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6337.
  • Revision ID: v.ladeuil+lp@free.fr-20111124154829-avowjpsxdl8yp2vz
merge trunk resolving conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""UI helper for the push command."""
18
18
 
19
19
from bzrlib import (
20
 
    bzrdir,
 
20
    controldir,
21
21
    errors,
22
22
    revision as _mod_revision,
23
23
    transport,
26
26
    note,
27
27
    warning,
28
28
    )
 
29
from bzrlib.i18n import gettext
29
30
 
30
31
 
31
32
class PushResult(object):
47
48
        """Write a human-readable description of the result."""
48
49
        if self.branch_push_result is None:
49
50
            if self.stacked_on is not None:
50
 
                note('Created new stacked branch referring to %s.' %
 
51
                note(gettext('Created new stacked branch referring to %s.') %
51
52
                    self.stacked_on)
52
53
            else:
53
 
                note('Created new branch.')
 
54
                note(gettext('Created new branch.'))
54
55
        else:
55
56
            self.branch_push_result.report(to_file)
56
57
 
78
79
    """
79
80
    to_transport = transport.get_transport(location)
80
81
    try:
81
 
        dir_to = bzrdir.BzrDir.open_from_transport(to_transport)
 
82
        dir_to = controldir.ControlDir.open_from_transport(to_transport)
82
83
    except errors.NotBranchError:
83
84
        # Didn't find anything
84
85
        dir_to = None
91
92
                no_tree=no_tree)
92
93
        except errors.FileExists, err:
93
94
            if err.path.endswith('/.bzr'):
94
 
                raise errors.BzrCommandError(
 
95
                raise errors.BzrCommandError(gettext(
95
96
                    "Target directory %s already contains a .bzr directory, "
96
 
                    "but it is not valid." % (location,))
 
97
                    "but it is not valid.") % (location,))
97
98
            if not use_existing_dir:
98
 
                raise errors.BzrCommandError("Target directory %s"
 
99
                raise errors.BzrCommandError(gettext("Target directory %s"
99
100
                     " already exists, but does not have a .bzr"
100
101
                     " directory. Supply --use-existing-dir to push"
101
 
                     " there anyway." % location)
 
102
                     " there anyway.") % location)
102
103
            # This shouldn't occur, but if it does the FileExists error will be
103
104
            # more informative than an UnboundLocalError for br_to.
104
105
            raise
105
106
        except errors.NoSuchFile:
106
107
            if not create_prefix:
107
 
                raise errors.BzrCommandError("Parent directory of %s"
 
108
                raise errors.BzrCommandError(gettext("Parent directory of %s"
108
109
                    " does not exist."
109
110
                    "\nYou may supply --create-prefix to create all"
110
 
                    " leading parent directories."
 
111
                    " leading parent directories.")
111
112
                    % location)
112
113
            # This shouldn't occur (because create_prefix is true, so
113
114
            # create_clone_on_transport should be catching NoSuchFile and
116
117
            # UnboundLocalError for br_to.
117
118
            raise
118
119
        except errors.TooManyRedirections:
119
 
            raise errors.BzrCommandError("Too many redirections trying "
120
 
                                         "to make %s." % location)
 
120
            raise errors.BzrCommandError(gettext("Too many redirections trying "
 
121
                                         "to make %s.") % location)
121
122
        push_result = PushResult()
122
123
        # TODO: Some more useful message about what was copied
123
124
        try:
141
142
            push_result = dir_to.push_branch(br_from, revision_id, overwrite, 
142
143
                remember, create_prefix)
143
144
        except errors.DivergedBranches:
144
 
            raise errors.BzrCommandError('These branches have diverged.'
 
145
            raise errors.BzrCommandError(gettext('These branches have diverged.'
145
146
                                    '  See "bzr help diverged-branches"'
146
 
                                    ' for more information.')
 
147
                                    ' for more information.'))
147
148
        except errors.NoRoundtrippingSupport, e:
148
 
            raise errors.BzrCommandError("It is not possible to losslessly "
149
 
                "push to %s. You may want to use dpush instead." % 
 
149
            raise errors.BzrCommandError(gettext("It is not possible to losslessly "
 
150
                "push to %s. You may want to use dpush instead.") % 
150
151
                    e.target_branch.mapping.vcs.abbreviation)
151
152
        except errors.NoRepositoryPresent:
152
 
            # we have a bzrdir but no branch or repository
 
153
            # we have a controldir but no branch or repository
153
154
            # XXX: Figure out what to do other than complain.
154
 
            raise errors.BzrCommandError("At %s you have a valid .bzr"
 
155
            raise errors.BzrCommandError(gettext("At %s you have a valid .bzr"
155
156
                " control directory, but not a branch or repository. This"
156
157
                " is an unsupported configuration. Please move the target"
157
 
                " directory out of the way and try again." % location)
 
158
                " directory out of the way and try again.") % location)
158
159
        if push_result.workingtree_updated == False:
159
160
            warning("This transport does not update the working " 
160
161
                    "tree of: %s. See 'bzr help working-trees' for "