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
34
if bzrlib.version_info[1] < 9:
34
if bzrlib.version_info < (0, 9):
35
35
# function deprecated after 0.9
36
36
from bzrlib.delta import compare_trees
38
38
import bzrlib.errors as errors
39
39
from bzrlib.workingtree import WorkingTree
41
from dialog import OliveDialog
44
42
""" Display Commit dialog and perform the needed actions. """
45
def __init__(self, gladefile, comm):
43
def __init__(self, gladefile, comm, dialog):
46
44
""" Initialize the Commit dialog. """
47
45
self.gladefile = gladefile
48
46
self.glade = gtk.glade.XML(self.gladefile, 'window_commit')
48
# Communication object
52
self.dialog = OliveDialog(self.gladefile)
53
# Get the Commit dialog widget
54
self.window = self.glade.get_widget('window_commit')
54
56
# Check if current location is a branch
56
58
(self.wt, path) = WorkingTree.open_containing(self.comm.get_path())
72
74
self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
73
if bzrlib.version_info[1] < 9:
75
if bzrlib.version_info < (0, 9):
74
76
self.delta = compare_trees(self.old_tree, self.wt)
76
78
self.delta = self.wt.changes_from(self.old_tree)
78
# Get the Commit dialog widget
79
self.window = self.glade.get_widget('window_commit')
81
80
# Dictionary for signal_autoconnect
82
81
dic = { "on_button_commit_commit_clicked": self.commit,
83
82
"on_button_commit_cancel_clicked": self.close }
96
95
""" Display the Push dialog. """
98
self.dialog.error_dialog('Directory is not a branch.')
97
self.dialog.error_dialog('Directory is not a branch',
98
'You can perform this action only in a branch.')
100
101
from olive.backend.info import is_checkout
101
102
if is_checkout(self.comm.get_path()):
169
170
local=self.checkbutton_local.get_active(),
170
171
specific_files=specific_files)
171
172
except errors.NotBranchError:
172
self.dialog.error_dialog('Directory is not a branch.')
173
self.dialog.error_dialog('Directory is not a branch',
174
'You can perform this action only in a branch.')
173
175
self.comm.set_busy(self.window, False)
175
177
except errors.LocalRequiresBoundBranch:
176
self.dialog.error_dialog('Local commit requires a bound branch.')
178
self.dialog.error_dialog('Directory is not a checkout',
179
'You can perform local commit only on checkouts.')
177
180
self.comm.set_busy(self.window, False)
179
182
except errors.PointlessCommit:
180
self.dialog.error_dialog('No changes to commit. Try force commit.')
183
self.dialog.error_dialog('No changes to commit',
184
'Try force commit if you want to commit anyway.')
181
185
self.comm.set_busy(self.window, False)
183
187
except errors.ConflictsInTree:
184
self.dialog.error_dialog('Conflicts in tree. Please resolve them first.')
188
self.dialog.error_dialog('Conflicts in tree'
189
'You need to resolve the conflicts before committing.')
185
190
self.comm.set_busy(self.window, False)
187
192
except errors.StrictCommitFailed:
188
self.dialog.error_dialog('Strict commit failed. There are unknown files.')
193
self.dialog.error_dialog('Strict commit failed'
194
'There are unknown files in the working tree.\nPlease add or delete them.')
189
195
self.comm.set_busy(self.window, False)
191
197
except errors.BoundBranchOutOfDate, errmsg:
192
self.dialog.error_dialog('Bound branch is out of date: %s' % errmsg)
198
self.dialog.error_dialog('Bound branch is out of date',
193
200
self.comm.set_busy(self.window, False)