1
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
1
# Copyright (C) 2008 Canonical Ltd
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
88
br_to = br_from.create_clone_on_transport(to_transport,
89
revision_id=revision_id, stacked_on=stacked_on,
90
create_prefix=create_prefix, use_existing_dir=use_existing_dir)
91
except errors.FileExists, err:
92
if err.path.endswith('/.bzr'):
93
raise errors.BzrCommandError(
94
"Target directory %s already contains a .bzr directory, "
95
"but it is not valid." % (location,))
96
if not use_existing_dir:
97
raise errors.BzrCommandError("Target directory %s"
98
" already exists, but does not have a .bzr"
99
" directory. Supply --use-existing-dir to push"
100
" there anyway." % location)
101
# This shouldn't occur, but if it does the FileExists error will be
102
# more informative than an UnboundLocalError for br_to.
104
except errors.NoSuchFile:
105
if not create_prefix:
106
raise errors.BzrCommandError("Parent directory of %s"
108
"\nYou may supply --create-prefix to create all"
109
" leading parent directories."
111
# This shouldn't occur (because create_prefix is true, so
112
# create_clone_on_transport should be catching NoSuchFile and
113
# creating the missing directories) but if it does the original
114
# NoSuchFile error will be more informative than an
115
# UnboundLocalError for br_to.
117
except errors.TooManyRedirections:
118
raise errors.BzrCommandError("Too many redirections trying "
119
"to make %s." % location)
89
br_to = br_from.create_clone_on_transport(to_transport,
90
revision_id=revision_id, stacked_on=stacked_on,
91
create_prefix=create_prefix, use_existing_dir=use_existing_dir)
120
92
push_result = PushResult()
121
93
# TODO: Some more useful message about what was copied
136
108
"already exists at the destination location.")
138
110
push_result = dir_to.push_branch(br_from, revision_id, overwrite,
139
remember, create_prefix)
140
112
except errors.DivergedBranches:
141
113
raise errors.BzrCommandError('These branches have diverged.'
142
' See "bzr help diverged-branches"'
143
' for more information.')
144
except errors.NoRoundtrippingSupport, e:
145
raise errors.BzrCommandError("It is not possible to losslessly "
146
"push to %s. You may want to use dpush instead." %
147
e.target_branch.mapping.vcs.abbreviation)
114
' Try using "merge" and then "push".')
148
115
except errors.NoRepositoryPresent:
149
116
# we have a bzrdir but no branch or repository
150
117
# XXX: Figure out what to do other than complain.