1
1
# Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
11
# GNU General Public License for more details.
13
13
# You should have received a copy of the GNU General Public License
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
36
36
""" Display Push dialog and perform the needed actions. """
37
def __init__(self, gladefile, comm, dialog):
37
def __init__(self, gladefile, comm):
38
38
""" Initialize the Push dialog. """
39
39
self.gladefile = gladefile
40
40
self.glade = gtk.glade.XML(self.gladefile, 'window_push')
42
# Communication object
47
44
self.window = self.glade.get_widget('window_push')
63
60
self.check_create = self.glade.get_widget('checkbutton_push_create')
65
62
# Get stored location
66
self.notbranch = False
68
loc = info.get_push_location(self.comm.get_path())
69
except errors.NotBranchError:
63
loc = info.get_push_location(self.comm.get_path())
74
65
self.entry_stored.set_text(loc)
77
68
""" Display the Push dialog. """
79
self.dialog.error_dialog(_('Directory is not a branch'),
80
_('You can perform this action only in a branch.'))
84
self.width, self.height = self.window.get_size()
70
self.width, self.height = self.window.get_size()
86
72
def stored_toggled(self, widget):
87
73
if widget.get_active():
119
108
revs = commit.push(self.comm.get_path(),
120
109
overwrite=self.check_overwrite.get_active())
121
110
except errors.NotBranchError:
122
self.dialog.error_dialog(_('Directory is not a branch'),
123
_('You can perform this action only in a branch.'))
111
dialog.error_dialog('Directory is not a branch.')
125
113
except errors.NoLocationKnown:
126
self.dialog.error_dialog(_('Push location is unknown'),
127
_('Please specify a location manually.'))
114
dialog.error_dialog('No location known.')
129
116
except errors.NonExistingParent, errmsg:
130
self.dialog.error_dialog(_('Non existing parent directory'),
131
_("The parent directory (%s)\ndoesn't exist.") % errmsg)
117
dialog.error_dialog('Parent directory doesn\'t exist: %s', errmsg)
133
119
except errors.DivergedBranchesError:
134
self.dialog.error_dialog(_('Branches have been diverged'),
135
_('You cannot push if branches have diverged. Use the\noverwrite option if you want to push anyway.'))
120
dialog.error_dialog('Branches have been diverged.')
139
124
elif radio_specific.get_active():
140
125
location = self.entry_location.get_text()
141
126
if location == '':
142
self.dialog.error_dialog(_('No location specified'),
143
_('Please specify a location or use the default.'))
127
dialog.error_dialog('No location specified.')
149
133
self.check_overwrite.get_active(),
150
134
self.check_create.get_active())
151
135
except errors.NotBranchError:
152
self.dialog.error_dialog(_('Directory is not a branch'),
153
_('You can perform this action only in a branch.'))
136
dialog.error_dialog('Directory is not a branch.')
154
137
self.comm.set_busy(self.window, False)
156
139
except errors.NonExistingParent, errmsg:
157
self.dialog.error_dialog(_('Non existing parent directory'),
158
_("The parent directory (%s)\ndoesn't exist.") % errmsg)
140
dialog.error_dialog('Parent directory doesn\'t exist: %s', errmsg)
159
141
self.comm.set_busy(self.window, False)
161
143
except errors.DivergedBranchesError:
162
self.dialog.error_dialog(_('Branches have been diverged'),
163
_('You cannot push if branches have diverged. Use the\noverwrite option if you want to push anyway.'))
144
dialog.error_dialog('Branches have been diverged.')
164
145
self.comm.set_busy(self.window, False)
166
147
except errors.PathPrefixNotCreated:
167
self.dialog.error_dialog(_('Path prefix not created'),
168
_("The path leading up to the specified location couldn't\nbe created."))
148
dialog.error_dialog('Path prefix couldn\'t be created.')
169
149
self.comm.set_busy(self.window, False)
178
self.dialog.info_dialog(_('Push successful'),
179
_('%d revision(s) pushed.') % revs)
158
dialog.info_dialog('%d revision(s) pushed.' % revs)
181
160
def close(self, widget=None):
182
161
self.window.destroy()