26
26
from errors import show_bzr_error
28
# FIXME: This needs to be public JRV 20070714
29
from bzrlib.builtins import _create_prefix
28
30
from bzrlib.config import LocationConfig
29
31
import bzrlib.errors as errors
49
51
# Create the widgets
50
52
self._label_location = gtk.Label(_("Location:"))
51
53
self._label_test = gtk.Label(_("(click the Test button to check write access)"))
52
self._check_prefix = gtk.CheckButton(_("Create the path _leading up to the location"),
54
54
self._combo = gtk.ComboBoxEntry()
55
55
self._button_test = gtk.Button(_("_Test"), use_underline=True)
56
56
self._button_push = gtk.Button(_("_Push"), use_underline=True)
76
76
self._hbox_test.pack_start(self._image_test, False, False)
77
77
self._hbox_test.pack_start(self._label_test, True, True)
78
78
self.vbox.pack_start(self._hbox_location)
79
self.vbox.pack_start(self._check_prefix)
80
79
self.vbox.pack_start(self._hbox_test)
81
80
self.action_area.pack_start(self._button_test)
82
81
self.action_area.pack_end(self._button_push)
138
137
self.branch.set_push_location(location)
141
revs = do_push(self.branch,
144
create_prefix=self._check_prefix.get_active())
140
revs = do_push(self.branch, location=location, overwrite=False)
145
141
except errors.DivergedBranches:
146
142
response = question_dialog(_('Branches have been diverged'),
147
143
_('You cannot push if branches have diverged.\nOverwrite?'))
148
144
if response == gtk.RESPONSE_OK:
149
revs = do_push(self.branch, location=location,
151
create_prefix=self._check_prefix.get_active()
145
revs = do_push(self.branch, location=location, overwrite=True)
155
148
self._history.add_entry(location)
159
152
self.response(gtk.RESPONSE_OK)
161
def do_push(branch, location, overwrite, create_prefix):
154
def do_push(br_from, location, overwrite):
162
155
""" Update a mirror of a branch.
164
:param branch: the source branch
157
:param br_from: the source branch
166
159
:param location: the location of the branch that you'd like to update
168
161
:param overwrite: overwrite target location if it diverged
170
:param create_prefix: create the path leading up to the branch if it doesn't exist
172
163
:return: number of revisions pushed
174
165
from bzrlib.bzrdir import BzrDir
185
176
except errors.NotBranchError:
186
177
# create a branch.
187
178
transport = transport.clone('..')
188
if not create_prefix:
190
relurl = transport.relpath(location_url)
191
transport.mkdir(relurl)
192
except errors.NoSuchFile:
193
error_dialog(_('Non existing parent directory'),
194
_("The parent directory (%s)\ndoesn't exist.") % location)
180
relurl = transport.relpath(location_url)
181
transport.mkdir(relurl)
182
except errors.NoSuchFile:
183
response = question_dialog(_('Non existing parent directory'),
184
_("The parent directory (%s)\ndoesn't exist. Create?") % location)
185
if response == gtk.RESPONSE_OK:
186
_create_prefix(transport)
197
current = transport.base
198
needed = [(transport, transport.relpath(location_url))]
201
transport, relpath = needed[-1]
202
transport.mkdir(relpath)
204
except errors.NoSuchFile:
205
new_transport = transport.clone('..')
206
needed.append((new_transport,
207
new_transport.relpath(transport.base)))
208
if new_transport.base == transport.base:
209
error_dialog(_('Path prefix not created'),
210
_("The path leading up to the specified location couldn't\nbe created."))
212
189
dir_to = br_from.bzrdir.clone(location_url,
213
190
revision_id=br_from.last_revision())
214
191
br_to = dir_to.open_branch()