67
65
self.label_test = self.glade.get_widget('label_push_test')
68
66
self.image_test = self.glade.get_widget('image_push_test')
71
self.entry_location.set_sensitive(0)
72
self.check_remember.set_sensitive(0)
73
self.check_create.set_sensitive(0)
75
68
# Get stored location
76
69
self.notbranch = False
78
loc = info.get_push_location(self.comm.get_path())
71
from bzrlib.branch import Branch
73
branch = Branch.open_containing(self.comm.get_path())[0]
75
self.entry_stored.set_text(branch.get_push_location())
79
76
except errors.NotBranchError:
80
77
self.notbranch = True
84
self.entry_stored.set_text(loc)
87
81
""" Display the Push dialog. """
96
90
def stored_toggled(self, widget):
97
91
if widget.get_active():
98
self.entry_stored.set_sensitive(1)
99
self.entry_location.set_sensitive(0)
100
self.check_remember.set_sensitive(0)
101
self.check_create.set_sensitive(0)
92
self.entry_stored.show()
93
self.entry_location.hide()
94
self.check_remember.hide()
95
self.check_create.hide()
96
self.window.resize(self.width, self.height)
103
self.entry_stored.set_sensitive(0)
104
self.entry_location.set_sensitive(1)
105
self.check_remember.set_sensitive(1)
106
self.check_create.set_sensitive(1)
98
self.entry_stored.hide()
99
self.entry_location.show()
100
self.check_remember.show()
101
self.check_create.show()
108
103
def specific_toggled(self, widget):
109
104
if widget.get_active():
110
self.entry_stored.set_sensitive(0)
111
self.entry_location.set_sensitive(1)
112
self.check_remember.set_sensitive(1)
113
self.check_create.set_sensitive(1)
105
self.entry_stored.hide()
106
self.entry_location.show()
107
self.check_remember.show()
108
self.check_create.show()
115
self.entry_stored.set_sensitive(1)
116
self.entry_location.set_sensitive(0)
117
self.check_remember.set_sensitive(0)
118
self.check_create.set_sensitive(0)
110
self.entry_stored.show()
111
self.entry_location.hide()
112
self.check_remember.hide()
113
self.check_create.hide()
120
115
def push(self, widget):
122
117
self.comm.set_busy(self.window)
123
118
if self.radio_stored.get_active():
125
revs = commit.push(self.comm.get_path(),
120
revs = do_push(self.comm.get_path(),
126
121
overwrite=self.check_overwrite.get_active())
127
122
except errors.NotBranchError:
128
123
self.dialog.error_dialog(_('Directory is not a branch'),
153
revs = commit.push(self.comm.get_path(), location,
148
revs = do_push(self.comm.get_path(), location,
154
149
self.check_remember.get_active(),
155
150
self.check_overwrite.get_active(),
156
151
self.check_create.get_active())
200
195
if (proto == 'sftp') or (proto == 'file') or (proto == 'ftp'):
201
196
# have write acces (most probably)
202
197
self.image_test.set_from_stock(gtk.STOCK_YES, 4)
203
self.label_test.set_markup(_('<b>Write access is probably available</b>'))
198
self.label_test.set_markup(_('<b>Write access is available most probably</b>'))
205
200
# no write access
206
201
self.image_test.set_from_stock(gtk.STOCK_NO, 4)
213
208
def close(self, widget=None):
214
209
self.window.destroy()
211
def do_push(branch, location=None, remember=False, overwrite=False,
212
create_prefix=False):
213
""" Update a mirror of a branch.
215
:param branch: the source branch
217
:param location: the location of the branch that you'd like to update
219
:param remember: if set, the location will be stored
221
:param overwrite: overwrite target location if it diverged
223
:param create_prefix: create the path leading up to the branch if it doesn't exist
225
:return: number of revisions pushed
227
from bzrlib.branch import Branch
228
from bzrlib.transport import get_transport
230
br_from = Branch.open_containing(branch)[0]
232
stored_loc = br_from.get_push_location()
234
if stored_loc is None:
235
raise NoLocationKnown
237
location = stored_loc
239
transport = get_transport(location)
240
location_url = transport.base
242
if br_from.get_push_location() is None or remember:
243
br_from.set_push_location(location_url)
248
dir_to = bzrlib.bzrdir.BzrDir.open(location_url)
249
br_to = dir_to.open_branch()
250
except NotBranchError:
252
transport = transport.clone('..')
253
if not create_prefix:
255
relurl = transport.relpath(location_url)
256
transport.mkdir(relurl)
258
raise NonExistingParent(location)
260
current = transport.base
261
needed = [(transport, transport.relpath(location_url))]
264
transport, relpath = needed[-1]
265
transport.mkdir(relpath)
268
new_transport = transport.clone('..')
269
needed.append((new_transport,
270
new_transport.relpath(transport.base)))
271
if new_transport.base == transport.base:
272
raise PathPrefixNotCreated
273
dir_to = br_from.bzrdir.clone(location_url,
274
revision_id=br_from.last_revision())
275
br_to = dir_to.open_branch()
276
count = len(br_to.revision_history())
278
old_rh = br_to.revision_history()
281
tree_to = dir_to.open_workingtree()
283
# FIXME - what to do here? how should we warn the user?
284
#warning('This transport does not update the working '
285
# 'tree of: %s' % (br_to.base,))
286
count = br_to.pull(br_from, overwrite)
287
except NoWorkingTree:
288
count = br_to.pull(br_from, overwrite)
290
count = tree_to.pull(br_from, overwrite)
291
except DivergedBranches:
292
raise DivergedBranchesError