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