21
21
pygtk.require("2.0")
32
29
from bzrlib import version_info
34
31
import bzrlib.errors as errors
35
32
from bzrlib.workingtree import WorkingTree
34
from dialog import error_dialog
35
from olive import gladefile
38
38
""" Display Commit dialog and perform the needed actions. """
39
def __init__(self, gladefile, comm, dialog):
39
def __init__(self, wt, wtpath):
40
40
""" Initialize the Commit dialog. """
41
self.gladefile = gladefile
42
self.glade = gtk.glade.XML(self.gladefile, 'window_commit', 'olive-gtk')
44
# Communication object
41
self.glade = gtk.glade.XML(gladefile, 'window_commit', 'olive-gtk')
49
46
# Get some important widgets
50
47
self.window = self.glade.get_widget('window_commit')
51
48
self.checkbutton_local = self.glade.get_widget('checkbutton_commit_local')
52
49
self.textview = self.glade.get_widget('textview_commit')
53
50
self.file_view = self.glade.get_widget('treeview_commit_select')
55
# Check if current location is a branch
57
(self.wt, path) = WorkingTree.open_containing(self.comm.get_path())
58
branch = self.wt.branch
59
except errors.NotBranchError:
65
file_id = self.wt.path2id(path)
52
file_id = self.wt.path2id(wtpath)
67
54
self.notbranch = False
68
55
if file_id is None:
73
60
self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
74
if version_info < (0, 9):
75
self.delta = compare_trees(self.old_tree, self.wt)
77
self.delta = self.wt.changes_from(self.old_tree)
61
self.delta = self.wt.changes_from(self.old_tree)
79
63
# Dictionary for signal_autoconnect
80
64
dic = { "on_button_commit_commit_clicked": self.commit,
90
74
""" Display the Push dialog. """
92
self.dialog.error_dialog(_('Directory is not a branch'),
76
error_dialog(_('Directory is not a branch'),
93
77
_('You can perform this action only in a branch.'))
96
from bzrlib.branch import Branch
97
branch = Branch.open_containing(self.comm.get_path())[0]
99
if branch.get_bound_location() is not None:
80
if self.wt.branch.get_bound_location() is not None:
100
81
# we have a checkout, so the local commit checkbox must appear
101
82
self.checkbutton_local.show()
166
143
local=self.checkbutton_local.get_active(),
167
144
specific_files=specific_files)
168
145
except errors.NotBranchError:
169
self.dialog.error_dialog(_('Directory is not a branch'),
146
error_dialog(_('Directory is not a branch'),
170
147
_('You can perform this action only in a branch.'))
171
self.comm.set_busy(self.window, False)
173
149
except errors.LocalRequiresBoundBranch:
174
self.dialog.error_dialog(_('Directory is not a checkout'),
150
error_dialog(_('Directory is not a checkout'),
175
151
_('You can perform local commit only on checkouts.'))
176
self.comm.set_busy(self.window, False)
178
153
except errors.PointlessCommit:
179
self.dialog.error_dialog(_('No changes to commit'),
154
error_dialog(_('No changes to commit'),
180
155
_('Try force commit if you want to commit anyway.'))
181
self.comm.set_busy(self.window, False)
183
157
except errors.ConflictsInTree:
184
self.dialog.error_dialog(_('Conflicts in tree'),
158
error_dialog(_('Conflicts in tree'),
185
159
_('You need to resolve the conflicts before committing.'))
186
self.comm.set_busy(self.window, False)
188
161
except errors.StrictCommitFailed:
189
self.dialog.error_dialog(_('Strict commit failed'),
162
error_dialog(_('Strict commit failed'),
190
163
_('There are unknown files in the working tree.\nPlease add or delete them.'))
191
self.comm.set_busy(self.window, False)
193
165
except errors.BoundBranchOutOfDate, errmsg:
194
self.dialog.error_dialog(_('Bound branch is out of date'),
166
error_dialog(_('Bound branch is out of date'),
195
167
_('%s') % errmsg)
196
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))
202
self.comm.refresh_right()
204
178
def close(self, widget=None):
205
179
self.window.destroy()