74
73
def on_menuitem_branch_missing_revisions_activate(self, widget):
75
74
""" Branch/Missing revisions menu handler. """
76
import olive.backend.update as update
78
76
self.comm.set_busy(self.comm.window_main)
81
ret = update.missing(self.comm.get_path())
82
except errors.NotBranchError:
83
self.dialog.error_dialog(_('Directory is not a branch'),
84
_('You can perform this action only in a branch.'))
85
except errors.ConnectionError:
86
self.dialog.error_dialog(_('Connection error'),
87
_('Cannot connect to remote location.\nPlease try again later.'))
88
except errors.NoLocationKnown:
89
self.dialog.error_dialog(_('Parent location is unknown'),
90
_('Cannot determine missing revisions if no parent location is known.'))
82
local_branch = Branch.open_containing(self.comm.get_path())[0]
83
except NotBranchError:
84
self.dialog.error_dialog(_('Directory is not a branch'),
85
_('You can perform this action only in a branch.'))
88
other_branch = local_branch.get_parent()
89
if other_branch is None:
90
self.dialog.error_dialog(_('Parent location is unknown'),
91
_('Cannot determine missing revisions if no parent location is known.'))
94
remote_branch = Branch.open(other_branch)
96
if remote_branch.base == local_branch.base:
97
remote_branch = local_branch
99
ret = len(local_branch.missing_revisions(remote_branch))
93
102
self.dialog.info_dialog(_('There are missing revisions'),
94
103
_('%d revision(s) missing.') % ret)
96
105
self.dialog.info_dialog(_('Local branch up to date'),
97
106
_('There are no missing revisions.'))
99
self.comm.set_busy(self.comm.window_main, False)
108
self.comm.set_busy(self.comm.window_main, False)
101
110
def on_menuitem_branch_pull_activate(self, widget):
102
111
""" Branch/Pull menu handler. """
103
import olive.backend.update as update
105
113
self.comm.set_busy(self.comm.window_main)
108
ret = update.pull(self.comm.get_path())
109
except errors.NotBranchError:
110
self.dialog.error_dialog(_('Directory is not a branch'),
111
_('You can perform this action only in a branch.'))
112
except errors.NoLocationKnown:
113
self.dialog.error_dialog(_('Parent location is unknown'),
114
_('Pulling is not possible until there is no parent location.'))
117
from bzrlib.workingtree import WorkingTree
118
tree_to = WorkingTree.open_containing(self.comm.get_path())[0]
119
branch_to = tree_to.branch
120
except errors.NoWorkingTree:
122
branch_to = Branch.open_containing(self.comm.get_path())[0]
123
except errors.NotBranchError:
124
self.dialog.error_dialog(_('Directory is not a branch'),
125
_('You can perform this action only in a branch.'))
127
location = branch_to.get_parent()
129
self.dialog.error_dialog(_('Parent location is unknown'),
130
_('Pulling is not possible until there is a parent location.'))
134
branch_from = Branch.open(location)
135
except errors.NotBranchError:
136
self.dialog.error_dialog(_('Directory is not a branch'),
137
_('You can perform this action only in a branch.'))
139
if branch_to.get_parent() is None:
140
branch_to.set_parent(branch_from.base)
142
old_rh = branch_to.revision_history()
143
if tree_to is not None:
144
tree_to.pull(branch_from)
146
branch_to.pull(branch_from)
116
148
self.dialog.info_dialog(_('Pull successful'),
117
149
_('%d revision(s) pulled.') % ret)
119
self.comm.set_busy(self.comm.window_main, False)
152
self.comm.set_busy(self.comm.window_main, False)
121
154
def on_menuitem_branch_push_activate(self, widget):
122
155
""" Branch/Push... menu handler. """
133
166
def on_menuitem_branch_initialize_activate(self, widget):
134
167
""" Initialize current directory. """
135
import olive.backend.init as init
138
init.init(self.comm.get_path())
169
location = self.comm.get_path()
170
from bzrlib.builtins import get_format_type
172
format = get_format_type('default')
174
if not os.path.exists(location):
178
existing_bzrdir = bzrdir.BzrDir.open(location)
179
except NotBranchError:
180
bzrdir.BzrDir.create_branch_convenience(location, format=format)
182
if existing_bzrdir.has_branch():
183
if existing_bzrdir.has_workingtree():
184
raise AlreadyBranchError(location)
186
raise BranchExistsWithoutWorkingTree(location)
188
existing_bzrdir.create_branch()
189
existing_bzrdir.create_workingtree()
139
190
except errors.AlreadyBranchError, errmsg:
140
191
self.dialog.error_dialog(_('Directory is already a branch'),
141
192
_('The current directory (%s) is already a branch.\nYou can start using it, or initialize another directory.') % errmsg)
142
193
except errors.BranchExistsWithoutWorkingTree, errmsg:
143
194
self.dialog.error_dialog(_('Branch without a working tree'),
144
195
_('The current directory (%s)\nis a branch without a working tree.') % errmsg)
148
self.dialog.info_dialog(_('Ininialize successful'),
197
self.dialog.info_dialog(_('Initialize successful'),
149
198
_('Directory successfully initialized.'))
150
199
self.comm.refresh_right()
214
263
def on_treeview_left_button_press_event(self, widget, event):
215
264
""" Occurs when somebody right-clicks in the bookmark list. """
216
265
if event.button == 3:
217
# Don't show context with nothing selected
218
if self.comm.get_selected_left() == None:
221
266
self.menu.left_context_menu().popup(None, None, None, 0,
224
269
def on_treeview_left_row_activated(self, treeview, path, view_column):
225
270
""" Occurs when somebody double-clicks or enters an item in the
226
271
bookmark list. """
272
self.comm.set_busy(treeview)
228
274
newdir = self.comm.get_selected_left()
232
self.comm.set_busy(treeview)
233
275
self.comm.set_path(newdir)
234
277
self.comm.refresh_right()
235
279
self.comm.set_busy(treeview, False)
237
281
def on_treeview_right_button_press_event(self, widget, event):
243
287
m_commit = self.menu.ui.get_widget('/context_right/commit')
244
288
m_diff = self.menu.ui.get_widget('/context_right/diff')
245
289
# check if we're in a branch
246
if not is_branch(self.comm.get_path()):
291
from bzrlib.branch import Branch
292
Branch.open_containing(self.comm.get_path())
247
293
m_add.set_sensitive(False)
248
294
m_remove.set_sensitive(False)
249
295
m_commit.set_sensitive(False)
250
296
m_diff.set_sensitive(False)
297
except errors.NotBranchError:
252
298
m_add.set_sensitive(True)
253
299
m_remove.set_sensitive(True)
254
300
m_commit.set_sensitive(True)