21
21
pygtk.require("2.0")
32
29
from bzrlib import version_info
34
if version_info < (0, 9):
35
# function deprecated after 0.9
36
from bzrlib.delta import compare_trees
38
31
import bzrlib.errors as errors
39
32
from bzrlib.workingtree import WorkingTree
34
from dialog import error_dialog
35
from olive import gladefile
42
38
""" Display Commit dialog and perform the needed actions. """
43
def __init__(self, gladefile, comm, dialog):
39
def __init__(self, wt, wtpath):
44
40
""" Initialize the Commit dialog. """
45
self.gladefile = gladefile
46
self.glade = gtk.glade.XML(self.gladefile, 'window_commit', 'olive-gtk')
48
# Communication object
41
self.glade = gtk.glade.XML(gladefile, 'window_commit', 'olive-gtk')
53
46
# Get some important widgets
54
47
self.window = self.glade.get_widget('window_commit')
55
48
self.checkbutton_local = self.glade.get_widget('checkbutton_commit_local')
56
49
self.textview = self.glade.get_widget('textview_commit')
57
50
self.file_view = self.glade.get_widget('treeview_commit_select')
59
# Check if current location is a branch
61
(self.wt, path) = WorkingTree.open_containing(self.comm.get_path())
62
branch = self.wt.branch
63
except errors.NotBranchError:
69
file_id = self.wt.path2id(path)
52
file_id = self.wt.path2id(wtpath)
71
54
self.notbranch = False
72
55
if file_id is None:
77
60
self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
78
if version_info < (0, 9):
79
self.delta = compare_trees(self.old_tree, self.wt)
81
self.delta = self.wt.changes_from(self.old_tree)
61
self.delta = self.wt.changes_from(self.old_tree)
83
63
# Dictionary for signal_autoconnect
84
64
dic = { "on_button_commit_commit_clicked": self.commit,
94
74
""" Display the Push dialog. """
96
self.dialog.error_dialog(_('Directory is not a branch'),
76
error_dialog(_('Directory is not a branch'),
97
77
_('You can perform this action only in a branch.'))
100
from olive.backend.info import is_checkout
101
if is_checkout(self.comm.get_path()):
80
if self.wt.branch.get_bound_location() is not None:
102
81
# we have a checkout, so the local commit checkbox must appear
103
82
self.checkbutton_local.show()
168
143
local=self.checkbutton_local.get_active(),
169
144
specific_files=specific_files)
170
145
except errors.NotBranchError:
171
self.dialog.error_dialog(_('Directory is not a branch'),
146
error_dialog(_('Directory is not a branch'),
172
147
_('You can perform this action only in a branch.'))
173
self.comm.set_busy(self.window, False)
175
149
except errors.LocalRequiresBoundBranch:
176
self.dialog.error_dialog(_('Directory is not a checkout'),
150
error_dialog(_('Directory is not a checkout'),
177
151
_('You can perform local commit only on checkouts.'))
178
self.comm.set_busy(self.window, False)
180
153
except errors.PointlessCommit:
181
self.dialog.error_dialog(_('No changes to commit'),
154
error_dialog(_('No changes to commit'),
182
155
_('Try force commit if you want to commit anyway.'))
183
self.comm.set_busy(self.window, False)
185
157
except errors.ConflictsInTree:
186
self.dialog.error_dialog(_('Conflicts in tree'),
158
error_dialog(_('Conflicts in tree'),
187
159
_('You need to resolve the conflicts before committing.'))
188
self.comm.set_busy(self.window, False)
190
161
except errors.StrictCommitFailed:
191
self.dialog.error_dialog(_('Strict commit failed'),
162
error_dialog(_('Strict commit failed'),
192
163
_('There are unknown files in the working tree.\nPlease add or delete them.'))
193
self.comm.set_busy(self.window, False)
195
165
except errors.BoundBranchOutOfDate, errmsg:
196
self.dialog.error_dialog(_('Bound branch is out of date'),
166
error_dialog(_('Bound branch is out of date'),
197
167
_('%s') % errmsg)
198
self.comm.set_busy(self.window, False)
169
except errors.BzrError, msg:
170
error_dialog(_('Unknown bzr error'), str(msg))
172
except Exception, msg:
173
error_dialog(_('Unknown error'), str(msg))
204
self.comm.refresh_right()
206
178
def close(self, widget=None):
207
179
self.window.destroy()