32
32
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
34
import bzrlib.errors as errors
39
35
from bzrlib.workingtree import WorkingTree
37
from dialog import error_dialog
42
40
""" Display Commit dialog and perform the needed actions. """
43
def __init__(self, gladefile, comm, dialog):
41
def __init__(self, gladefile, wt, wtpath):
44
42
""" Initialize the Commit dialog. """
45
43
self.gladefile = gladefile
46
44
self.glade = gtk.glade.XML(self.gladefile, 'window_commit', 'olive-gtk')
48
# Communication object
53
49
# Get some important widgets
54
50
self.window = self.glade.get_widget('window_commit')
55
51
self.checkbutton_local = self.glade.get_widget('checkbutton_commit_local')
56
52
self.textview = self.glade.get_widget('textview_commit')
57
53
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)
55
file_id = self.wt.path2id(wtpath)
71
57
self.notbranch = False
72
58
if file_id is None:
77
63
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)
64
self.delta = self.wt.changes_from(self.old_tree)
83
66
# Dictionary for signal_autoconnect
84
67
dic = { "on_button_commit_commit_clicked": self.commit,
94
77
""" Display the Push dialog. """
96
self.dialog.error_dialog(_('Directory is not a branch'),
79
error_dialog(_('Directory is not a branch'),
97
80
_('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()):
83
if self.wt.branch.get_bound_location() is not None:
102
84
# we have a checkout, so the local commit checkbox must appear
103
85
self.checkbutton_local.show()
168
147
local=self.checkbutton_local.get_active(),
169
148
specific_files=specific_files)
170
149
except errors.NotBranchError:
171
self.dialog.error_dialog(_('Directory is not a branch'),
150
error_dialog(_('Directory is not a branch'),
172
151
_('You can perform this action only in a branch.'))
173
self.comm.set_busy(self.window, False)
175
153
except errors.LocalRequiresBoundBranch:
176
self.dialog.error_dialog(_('Directory is not a checkout'),
154
error_dialog(_('Directory is not a checkout'),
177
155
_('You can perform local commit only on checkouts.'))
178
self.comm.set_busy(self.window, False)
180
157
except errors.PointlessCommit:
181
self.dialog.error_dialog(_('No changes to commit'),
158
error_dialog(_('No changes to commit'),
182
159
_('Try force commit if you want to commit anyway.'))
183
self.comm.set_busy(self.window, False)
185
161
except errors.ConflictsInTree:
186
self.dialog.error_dialog(_('Conflicts in tree'),
162
error_dialog(_('Conflicts in tree'),
187
163
_('You need to resolve the conflicts before committing.'))
188
self.comm.set_busy(self.window, False)
190
165
except errors.StrictCommitFailed:
191
self.dialog.error_dialog(_('Strict commit failed'),
166
error_dialog(_('Strict commit failed'),
192
167
_('There are unknown files in the working tree.\nPlease add or delete them.'))
193
self.comm.set_busy(self.window, False)
195
169
except errors.BoundBranchOutOfDate, errmsg:
196
self.dialog.error_dialog(_('Bound branch is out of date'),
170
error_dialog(_('Bound branch is out of date'),
197
171
_('%s') % errmsg)
198
self.comm.set_busy(self.window, False)
173
except errors.BzrError, msg:
174
error_dialog(_('Unknown bzr error'), str(msg))
176
except Exception, msg:
177
error_dialog(_('Unknown error'), str(msg))
204
181
self.comm.refresh_right()