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 dialog import error_dialog, info_dialog
30
from guifiles import GLADEFILENAME
34
34
""" Display Push dialog and perform the needed actions. """
35
def __init__(self, gladefile, comm, dialog):
35
def __init__(self, branch):
36
36
""" Initialize the Push dialog. """
37
self.gladefile = gladefile
38
self.glade = gtk.glade.XML(self.gladefile, 'window_push')
40
# Communication object
37
self.glade = gtk.glade.XML(GLADEFILENAME, 'window_push')
45
39
self.window = self.glade.get_widget('window_push')
47
43
# Dictionary for signal_autoconnect
48
44
dic = { "on_button_push_push_clicked": self.push,
69
65
self.entry_location.set_sensitive(0)
70
66
self.check_remember.set_sensitive(0)
71
67
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:
69
self.entry_stored.set_text(branch.get_push_location() or '')
86
72
""" 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()
74
self.width, self.height = self.window.get_size()
95
76
def stored_toggled(self, widget):
96
77
if widget.get_active():
119
100
def push(self, widget):
121
self.comm.set_busy(self.window)
122
102
if self.radio_stored.get_active():
124
revs = do_push(self.comm.get_path(),
104
revs = do_push(self.branch,
125
105
overwrite=self.check_overwrite.get_active())
126
except errors.NotBranchError:
127
self.dialog.error_dialog(_('Directory is not a branch'),
128
_('You can perform this action only in a branch.'))
130
106
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.'))
107
response = question_dialog(_('Branches have been diverged'),
108
_('You cannot push if branches have diverged. \nOverwrite?'))
109
if response == gtk.RESPONSE_OK:
110
revs = do_push(self.branch, overwrite=True)
136
112
elif self.radio_specific.get_active():
137
113
location = self.entry_location.get_text()
138
114
if location == '':
139
self.dialog.error_dialog(_('No location specified'),
140
_('Please specify a location or use the default.'))
115
error_dialog(_('No location specified'),
116
_('Please specify a location or use the default.'))
144
revs = do_push(self.comm.get_path(), location,
120
revs = do_push(self.branch, location,
145
121
self.check_remember.get_active(),
146
self.check_overwrite.get_active(),
147
123
self.check_create.get_active())
148
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)
153
124
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)
161
# This should really never happen
125
response = question_dialog(_('Branches have been diverged'),
126
_('You cannot push if branches have diverged. \nOverwrite?'))
127
if response == gtk.RESPONSE_OK:
128
revs = do_push(self.branch, location,
129
self.check_remember.get_active(),
131
self.check_create.get_active())
165
self.dialog.info_dialog(_('Push successful'),
166
_('%d revision(s) pushed.') % revs)
136
info_dialog(_('Push successful'),
137
_('%d revision(s) pushed.') % revs)
168
139
def test(self, widget):
169
140
""" Test if write access possible. """
214
185
from bzrlib.bzrdir import BzrDir
215
186
from bzrlib.transport import get_transport
217
br_from = Branch.open_containing(branch)[0]
219
190
stored_loc = br_from.get_push_location()
220
191
if location is None:
221
192
if stored_loc is None:
222
self.dialog.error_dialog(_('Push location is unknown'),
223
_('Please specify a location manually.'))
193
error_dialog(_('Push location is unknown'),
194
_('Please specify a location manually.'))
226
197
location = stored_loc
260
231
needed.append((new_transport,
261
232
new_transport.relpath(transport.base)))
262
233
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."))
234
error_dialog(_('Path prefix not created'),
235
_("The path leading up to the specified location couldn't\nbe created."))
266
237
dir_to = br_from.bzrdir.clone(location_url,
267
238
revision_id=br_from.last_revision())
271
242
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:
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)