~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/push.py

  • Committer: Vincent Ladeuil
  • Date: 2011-08-20 09:28:27 UTC
  • mfrom: (5050.78.2 2.2)
  • mto: (5609.48.8 2.3)
  • mto: This revision was merged to the branch mainline in revision 6090.
  • Revision ID: v.ladeuil+lp@free.fr-20110820092827-9dyakfslp0r3hb1k
Merge 2.2 into 2.3 (including fix for #614713, #609187 and #812928)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008 Canonical Ltd
 
1
# Copyright (C) 2008, 2009, 2010 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
17
17
"""UI helper for the push command."""
18
18
 
19
19
from bzrlib import (
20
 
    builtins,
21
 
    branch,
22
20
    bzrdir,
23
21
    errors,
24
22
    revision as _mod_revision,
59
57
 
60
58
def _show_push_branch(br_from, revision_id, location, to_file, verbose=False,
61
59
    overwrite=False, remember=False, stacked_on=None, create_prefix=False,
62
 
    use_existing_dir=False):
 
60
    use_existing_dir=False, no_tree=False):
63
61
    """Push a branch to a location.
64
62
 
65
63
    :param br_from: the source branch
89
87
        try:
90
88
            br_to = br_from.create_clone_on_transport(to_transport,
91
89
                revision_id=revision_id, stacked_on=stacked_on,
92
 
                create_prefix=create_prefix, use_existing_dir=use_existing_dir)
93
 
        except errors.FileExists:
 
90
                create_prefix=create_prefix, use_existing_dir=use_existing_dir,
 
91
                no_tree=no_tree)
 
92
        except errors.FileExists, err:
 
93
            if err.path.endswith('/.bzr'):
 
94
                raise errors.BzrCommandError(
 
95
                    "Target directory %s already contains a .bzr directory, "
 
96
                    "but it is not valid." % (location,))
94
97
            if not use_existing_dir:
95
98
                raise errors.BzrCommandError("Target directory %s"
96
 
                     " already exists, but does not have a valid .bzr"
 
99
                     " already exists, but does not have a .bzr"
97
100
                     " directory. Supply --use-existing-dir to push"
98
101
                     " there anyway." % location)
 
102
            # This shouldn't occur, but if it does the FileExists error will be
 
103
            # more informative than an UnboundLocalError for br_to.
 
104
            raise
99
105
        except errors.NoSuchFile:
100
106
            if not create_prefix:
101
107
                raise errors.BzrCommandError("Parent directory of %s"
103
109
                    "\nYou may supply --create-prefix to create all"
104
110
                    " leading parent directories."
105
111
                    % location)
 
112
            # This shouldn't occur (because create_prefix is true, so
 
113
            # create_clone_on_transport should be catching NoSuchFile and
 
114
            # creating the missing directories) but if it does the original
 
115
            # NoSuchFile error will be more informative than an
 
116
            # UnboundLocalError for br_to.
 
117
            raise
106
118
        except errors.TooManyRedirections:
107
119
            raise errors.BzrCommandError("Too many redirections trying "
108
120
                                         "to make %s." % location)
130
142
            raise errors.BzrCommandError('These branches have diverged.'
131
143
                                    '  See "bzr help diverged-branches"'
132
144
                                    ' for more information.')
 
145
        except errors.NoRoundtrippingSupport, e:
 
146
            raise errors.BzrCommandError("It is not possible to losslessly "
 
147
                "push to %s. You may want to use dpush instead." % 
 
148
                    e.target_branch.mapping.vcs.abbreviation)
133
149
        except errors.NoRepositoryPresent:
134
150
            # we have a bzrdir but no branch or repository
135
151
            # XXX: Figure out what to do other than complain.