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
32
32
import olive.backend.errors as errors
33
33
import olive.backend.info as info
35
from dialog import OliveDialog
38
36
""" Display Push dialog and perform the needed actions. """
39
def __init__(self, gladefile, comm):
37
def __init__(self, gladefile, comm, dialog):
40
38
""" Initialize the Push dialog. """
41
39
self.gladefile = gladefile
42
40
self.glade = gtk.glade.XML(self.gladefile, 'window_push')
42
# Communication object
45
self.dialog = OliveDialog(self.gladefile)
47
47
self.window = self.glade.get_widget('window_push')
77
77
""" Display the Push dialog. """
79
self.dialog.error_dialog('Directory is not a branch.')
79
self.dialog.error_dialog('Directory is not a branch',
80
'You can perform this action only in a branch.')
118
119
revs = commit.push(self.comm.get_path(),
119
120
overwrite=self.check_overwrite.get_active())
120
121
except errors.NotBranchError:
121
self.dialog.error_dialog('Directory is not a branch.')
122
self.dialog.error_dialog('Directory is not a branch',
123
'You can perform this action only in a branch.')
123
125
except errors.NoLocationKnown:
124
self.dialog.error_dialog('No location known.')
126
self.dialog.error_dialog('Push location is unknown',
127
'Please specify a location manually.')
126
129
except errors.NonExistingParent, errmsg:
127
self.dialog.error_dialog('Parent directory doesn\'t exist: %s', errmsg)
130
self.dialog.error_dialog("Non existing parent directory",
131
"The parent directory (%s)\ndoesn't exist." % errmsg)
129
133
except errors.DivergedBranchesError:
130
self.dialog.error_dialog('Branches have been diverged.')
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.')
134
139
elif radio_specific.get_active():
135
140
location = self.entry_location.get_text()
136
141
if location == '':
137
self.dialog.error_dialog('No location specified.')
142
self.dialog.error_dialog('No location specified',
143
'Please specify a location or use the default.')
143
149
self.check_overwrite.get_active(),
144
150
self.check_create.get_active())
145
151
except errors.NotBranchError:
146
self.dialog.error_dialog('Directory is not a branch.')
152
self.dialog.error_dialog('Directory is not a branch',
153
'You can perform this action only in a branch.')
147
154
self.comm.set_busy(self.window, False)
149
156
except errors.NonExistingParent, errmsg:
150
self.dialog.error_dialog('Parent directory doesn\'t exist: %s', errmsg)
157
self.dialog.error_dialog("Non existing parent directory",
158
"The parent directory (%s)\ndoesn't exist." % errmsg)
151
159
self.comm.set_busy(self.window, False)
153
161
except errors.DivergedBranchesError:
154
self.dialog.error_dialog('Branches have been diverged.')
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.')
155
164
self.comm.set_busy(self.window, False)
157
166
except errors.PathPrefixNotCreated:
158
self.dialog.error_dialog('Path prefix couldn\'t be created.')
167
self.dialog.error_dialog("Path prefix not created",
168
"The path leading up to the specified location couldn't\nbe created.")
159
169
self.comm.set_busy(self.window, False)
168
self.dialog.info_dialog('%d revision(s) pushed.' % revs)
178
self.dialog.info_dialog('Push successful',
179
'%d revision(s) pushed.' % revs)
170
181
def close(self, widget=None):
171
182
self.window.destroy()