~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/push.py

  • Committer: Jelmer Vernooij
  • Date: 2011-04-09 19:25:42 UTC
  • mto: (5777.5.1 inventoryworkingtree)
  • mto: This revision was merged to the branch mainline in revision 5781.
  • Revision ID: jelmer@samba.org-20110409192542-8bbedp36s7nj928e
Split InventoryTree out of Tree.

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