14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
19
pygtk.require("2.0")
31
27
import bzrlib.errors as errors
29
from olive import gladefile
30
from dialog import error_dialog, info_dialog
34
33
""" Display Push dialog and perform the needed actions. """
35
def __init__(self, gladefile, comm, dialog):
34
def __init__(self, branch):
36
35
""" Initialize the Push dialog. """
37
self.gladefile = gladefile
38
self.glade = gtk.glade.XML(self.gladefile, 'window_push')
40
# Communication object
36
self.glade = gtk.glade.XML(gladefile, 'window_push')
45
38
self.window = self.glade.get_widget('window_push')
47
42
# Dictionary for signal_autoconnect
48
43
dic = { "on_button_push_push_clicked": self.push,
69
64
self.entry_location.set_sensitive(0)
70
65
self.check_remember.set_sensitive(0)
71
66
self.check_create.set_sensitive(0)
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:
68
self.entry_stored.set_text(branch.get_push_location())
86
71
""" Display the Push dialog. """
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()
73
self.width, self.height = self.window.get_size()
95
75
def stored_toggled(self, widget):
96
76
if widget.get_active():
119
99
def push(self, widget):
121
self.comm.set_busy(self.window)
122
101
if self.radio_stored.get_active():
124
revs = do_push(self.comm.get_path(),
103
revs = do_push(self.branch,
125
104
overwrite=self.check_overwrite.get_active())
126
105
except errors.NotBranchError:
127
self.dialog.error_dialog(_('Directory is not a branch'),
128
_('You can perform this action only in a branch.'))
106
error_dialog(_('Directory is not a branch'),
107
_('You can perform this action only in a branch.'))
130
109
except errors.DivergedBranches:
131
self.dialog.error_dialog(_('Branches have been diverged'),
132
_('You cannot push if branches have diverged. Use the\noverwrite option if you want to push anyway.'))
110
error_dialog(_('Branches have been diverged'),
111
_('You cannot push if branches have diverged. Use the\noverwrite option if you want to push anyway.'))
136
113
elif self.radio_specific.get_active():
137
114
location = self.entry_location.get_text()
138
115
if location == '':
139
self.dialog.error_dialog(_('No location specified'),
140
_('Please specify a location or use the default.'))
116
error_dialog(_('No location specified'),
117
_('Please specify a location or use the default.'))
144
revs = do_push(self.comm.get_path(), location,
121
revs = do_push(self.branch, location,
145
122
self.check_remember.get_active(),
146
123
self.check_overwrite.get_active(),
147
124
self.check_create.get_active())
148
125
except errors.NotBranchError:
149
self.dialog.error_dialog(_('Directory is not a branch'),
150
_('You can perform this action only in a branch.'))
151
self.comm.set_busy(self.window, False)
126
error_dialog(_('Directory is not a branch'),
127
_('You can perform this action only in a branch.'))
153
129
except errors.DivergedBranches:
154
self.dialog.error_dialog(_('Branches have been diverged'),
155
_('You cannot push if branches have diverged. Use the\noverwrite option if you want to push anyway.'))
156
self.comm.set_busy(self.window, False)
130
error_dialog(_('Branches have been diverged'),
131
_('You cannot push if branches have diverged. Use the\noverwrite option if you want to push anyway.'))
161
# This should really never happen
165
self.dialog.info_dialog(_('Push successful'),
166
_('%d revision(s) pushed.') % revs)
135
info_dialog(_('Push successful'),
136
_('%d revision(s) pushed.') % revs)
168
138
def test(self, widget):
169
139
""" Test if write access possible. """
260
230
needed.append((new_transport,
261
231
new_transport.relpath(transport.base)))
262
232
if new_transport.base == transport.base:
263
self.dialog.error_dialog(_('Path prefix not created'),
264
_("The path leading up to the specified location couldn't\nbe created."))
233
error_dialog(_('Path prefix not created'),
234
_("The path leading up to the specified location couldn't\nbe created."))
266
236
dir_to = br_from.bzrdir.clone(location_url,
267
237
revision_id=br_from.last_revision())
271
241
old_rh = br_to.revision_history()
274
tree_to = dir_to.open_workingtree()
275
except errors.NotLocalUrl:
276
# FIXME - what to do here? how should we warn the user?
277
#warning('This transport does not update the working '
278
# 'tree of: %s' % (br_to.base,))
279
count = br_to.pull(br_from, overwrite)
280
except errors.NoWorkingTree:
281
count = br_to.pull(br_from, overwrite)
283
count = tree_to.pull(br_from, overwrite)
284
except errors.DivergedBranches:
243
tree_to = dir_to.open_workingtree()
244
except errors.NotLocalUrl:
245
# FIXME - what to do here? how should we warn the user?
246
#warning('This transport does not update the working '
247
# 'tree of: %s' % (br_to.base,))
248
count = br_to.pull(br_from, overwrite)
249
except errors.NoWorkingTree:
250
count = br_to.pull(br_from, overwrite)
252
count = tree_to.pull(br_from, overwrite)