75
73
# Get stored location
76
74
self.notbranch = False
78
loc = info.get_push_location(self.comm.get_path())
76
from bzrlib.branch import Branch
78
branch = Branch.open_containing(self.comm.get_path())[0]
80
self.entry_stored.set_text(branch.get_push_location())
79
81
except errors.NotBranchError:
80
82
self.notbranch = True
84
self.entry_stored.set_text(loc)
87
86
""" Display the Push dialog. """
122
121
self.comm.set_busy(self.window)
123
122
if self.radio_stored.get_active():
125
revs = commit.push(self.comm.get_path(),
124
revs = do_push(self.comm.get_path(),
126
125
overwrite=self.check_overwrite.get_active())
127
126
except errors.NotBranchError:
128
127
self.dialog.error_dialog(_('Directory is not a branch'),
153
revs = commit.push(self.comm.get_path(), location,
152
revs = do_push(self.comm.get_path(), location,
154
153
self.check_remember.get_active(),
155
154
self.check_overwrite.get_active(),
156
155
self.check_create.get_active())
213
212
def close(self, widget=None):
214
213
self.window.destroy()
215
def do_push(branch, location=None, remember=False, overwrite=False,
216
create_prefix=False):
217
""" Update a mirror of a branch.
219
:param branch: the source branch
221
:param location: the location of the branch that you'd like to update
223
:param remember: if set, the location will be stored
225
:param overwrite: overwrite target location if it diverged
227
:param create_prefix: create the path leading up to the branch if it doesn't exist
229
:return: number of revisions pushed
231
from bzrlib.branch import Branch
232
from bzrlib.transport import get_transport
234
br_from = Branch.open_containing(branch)[0]
236
stored_loc = br_from.get_push_location()
238
if stored_loc is None:
239
raise NoLocationKnown
241
location = stored_loc
243
transport = get_transport(location)
244
location_url = transport.base
246
if br_from.get_push_location() is None or remember:
247
br_from.set_push_location(location_url)
252
dir_to = bzrlib.bzrdir.BzrDir.open(location_url)
253
br_to = dir_to.open_branch()
254
except NotBranchError:
256
transport = transport.clone('..')
257
if not create_prefix:
259
relurl = transport.relpath(location_url)
260
transport.mkdir(relurl)
262
raise NonExistingParent(location)
264
current = transport.base
265
needed = [(transport, transport.relpath(location_url))]
268
transport, relpath = needed[-1]
269
transport.mkdir(relpath)
272
new_transport = transport.clone('..')
273
needed.append((new_transport,
274
new_transport.relpath(transport.base)))
275
if new_transport.base == transport.base:
276
raise PathPrefixNotCreated
277
dir_to = br_from.bzrdir.clone(location_url,
278
revision_id=br_from.last_revision())
279
br_to = dir_to.open_branch()
280
count = len(br_to.revision_history())
282
old_rh = br_to.revision_history()
285
tree_to = dir_to.open_workingtree()
287
# FIXME - what to do here? how should we warn the user?
288
#warning('This transport does not update the working '
289
# 'tree of: %s' % (br_to.base,))
290
count = br_to.pull(br_from, overwrite)
291
except NoWorkingTree:
292
count = br_to.pull(br_from, overwrite)
294
count = tree_to.pull(br_from, overwrite)
295
except DivergedBranches:
296
raise DivergedBranchesError