21
21
pygtk.require("2.0")
29
31
import bzrlib.errors as errors
31
from olive import gladefile
34
34
""" Display Push dialog and perform the needed actions. """
35
def __init__(self, branch):
35
def __init__(self, gladefile, comm, dialog):
36
36
""" Initialize the Push dialog. """
37
self.glade = gtk.glade.XML(gladefile, 'window_push')
37
self.gladefile = gladefile
38
self.glade = gtk.glade.XML(self.gladefile, 'window_push')
40
# Communication object
39
45
self.window = self.glade.get_widget('window_push')
43
47
# Dictionary for signal_autoconnect
44
48
dic = { "on_button_push_push_clicked": self.push,
65
69
self.entry_location.set_sensitive(0)
66
70
self.check_remember.set_sensitive(0)
67
71
self.check_create.set_sensitive(0)
69
self.entry_stored.set_text(branch.get_push_location())
74
self.notbranch = False
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())
81
except errors.NotBranchError:
72
86
""" Display the Push dialog. """
74
self.width, self.height = self.window.get_size()
88
self.dialog.error_dialog(_('Directory is not a branch'),
89
_('You can perform this action only in a branch.'))
93
self.width, self.height = self.window.get_size()
76
95
def stored_toggled(self, widget):
77
96
if widget.get_active():
100
119
def push(self, widget):
121
self.comm.set_busy(self.window)
102
122
if self.radio_stored.get_active():
104
revs = do_push(self.branch,
105
overwrite=self.check_overwrite.get_active())
124
revs = do_push(self.comm.get_path(),
125
overwrite=self.check_overwrite.get_active())
106
126
except errors.NotBranchError:
107
error_dialog(_('Directory is not a branch'),
127
self.dialog.error_dialog(_('Directory is not a branch'),
108
128
_('You can perform this action only in a branch.'))
110
except errors.DivergedBranches:
111
error_dialog(_('Branches have been diverged'),
130
except errors.NoLocationKnown:
131
self.dialog.error_dialog(_('Push location is unknown'),
132
_('Please specify a location manually.'))
134
except errors.NonExistingParent, errmsg:
135
self.dialog.error_dialog(_('Non existing parent directory'),
136
_("The parent directory (%s)\ndoesn't exist.") % errmsg)
138
except errors.DivergedBranchesError:
139
self.dialog.error_dialog(_('Branches have been diverged'),
112
140
_('You cannot push if branches have diverged. Use the\noverwrite option if you want to push anyway.'))
114
144
elif self.radio_specific.get_active():
115
145
location = self.entry_location.get_text()
116
146
if location == '':
117
error_dialog(_('No location specified'),
147
self.dialog.error_dialog(_('No location specified'),
118
148
_('Please specify a location or use the default.'))
122
revs = do_push(self.branch, location,
123
self.check_remember.get_active(),
124
self.check_overwrite.get_active(),
125
self.check_create.get_active())
152
revs = do_push(self.comm.get_path(), location,
153
self.check_remember.get_active(),
154
self.check_overwrite.get_active(),
155
self.check_create.get_active())
126
156
except errors.NotBranchError:
127
error_dialog(_('Directory is not a branch'),
157
self.dialog.error_dialog(_('Directory is not a branch'),
128
158
_('You can perform this action only in a branch.'))
130
except errors.DivergedBranches:
131
error_dialog(_('Branches have been diverged'),
159
self.comm.set_busy(self.window, False)
161
except errors.NonExistingParent, errmsg:
162
self.dialog.error_dialog(_('Non existing parent directory'),
163
_("The parent directory (%s)\ndoesn't exist.") % errmsg)
164
self.comm.set_busy(self.window, False)
166
except errors.DivergedBranchesError:
167
self.dialog.error_dialog(_('Branches have been diverged'),
132
168
_('You cannot push if branches have diverged. Use the\noverwrite option if you want to push anyway.'))
169
self.comm.set_busy(self.window, False)
171
except errors.PathPrefixNotCreated:
172
self.dialog.error_dialog(_('Path prefix not created'),
173
_("The path leading up to the specified location couldn't\nbe created."))
174
self.comm.set_busy(self.window, False)
179
# This should really never happen
136
info_dialog(_('Push successful'),
183
self.dialog.info_dialog(_('Push successful'),
137
184
_('%d revision(s) pushed.') % revs)
139
186
def test(self, widget):
208
dir_to = BzrDir.open(location_url)
252
dir_to = bzrlib.bzrdir.BzrDir.open(location_url)
209
253
br_to = dir_to.open_branch()
210
except errors.NotBranchError:
254
except NotBranchError:
211
255
# create a branch.
212
256
transport = transport.clone('..')
213
257
if not create_prefix:
215
259
relurl = transport.relpath(location_url)
216
260
transport.mkdir(relurl)
217
except errors.NoSuchFile:
218
error_dialog(_('Non existing parent directory'),
219
_("The parent directory (%s)\ndoesn't exist.") % location)
262
raise NonExistingParent(location)
222
264
current = transport.base
223
265
needed = [(transport, transport.relpath(location_url))]
226
268
transport, relpath = needed[-1]
227
269
transport.mkdir(relpath)
229
except errors.NoSuchFile:
230
272
new_transport = transport.clone('..')
231
273
needed.append((new_transport,
232
274
new_transport.relpath(transport.base)))
233
275
if new_transport.base == transport.base:
234
error_dialog(_('Path prefix not created'),
235
_("The path leading up to the specified location couldn't\nbe created."))
276
raise PathPrefixNotCreated
237
277
dir_to = br_from.bzrdir.clone(location_url,
238
278
revision_id=br_from.last_revision())
239
279
br_to = dir_to.open_branch()
242
282
old_rh = br_to.revision_history()
244
tree_to = dir_to.open_workingtree()
245
except errors.NotLocalUrl:
246
# FIXME - what to do here? how should we warn the user?
247
#warning('This transport does not update the working '
248
# 'tree of: %s' % (br_to.base,))
249
count = br_to.pull(br_from, overwrite)
250
except errors.NoWorkingTree:
251
count = br_to.pull(br_from, overwrite)
253
count = tree_to.pull(br_from, overwrite)
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