75
75
def on_menuitem_branch_missing_revisions_activate(self, widget):
76
76
""" Branch/Missing revisions menu handler. """
77
import olive.backend.update as update
79
78
self.comm.set_busy(self.comm.window_main)
82
ret = update.missing(self.comm.get_path())
83
except errors.NotBranchError:
84
self.dialog.error_dialog(_('Directory is not a branch'),
85
_('You can perform this action only in a branch.'))
86
except errors.ConnectionError:
87
self.dialog.error_dialog(_('Connection error'),
88
_('Cannot connect to remote location.\nPlease try again later.'))
89
except errors.NoLocationKnown:
90
self.dialog.error_dialog(_('Parent location is unknown'),
91
_('Cannot determine missing revisions if no parent location is known.'))
84
local_branch = Branch.open_containing(self.comm.get_path())[0]
85
except NotBranchError:
86
self.dialog.error_dialog(_('Directory is not a branch'),
87
_('You can perform this action only in a branch.'))
90
other_branch = local_branch.get_parent()
91
if other_branch is None:
92
self.dialog.error_dialog(_('Parent location is unknown'),
93
_('Cannot determine missing revisions if no parent location is known.'))
96
remote_branch = Branch.open(other_branch)
98
if remote_branch.base == local_branch.base:
99
remote_branch = local_branch
101
ret = len(local_branch.missing_revisions(remote_branch))
94
104
self.dialog.info_dialog(_('There are missing revisions'),
95
105
_('%d revision(s) missing.') % ret)
97
107
self.dialog.info_dialog(_('Local branch up to date'),
98
108
_('There are no missing revisions.'))
100
self.comm.set_busy(self.comm.window_main, False)
110
self.comm.set_busy(self.comm.window_main, False)
102
112
def on_menuitem_branch_pull_activate(self, widget):
103
113
""" Branch/Pull menu handler. """
104
import olive.backend.update as update
106
115
self.comm.set_busy(self.comm.window_main)
109
ret = update.pull(self.comm.get_path())
110
except errors.NotBranchError:
111
self.dialog.error_dialog(_('Directory is not a branch'),
112
_('You can perform this action only in a branch.'))
113
except errors.NoLocationKnown:
114
self.dialog.error_dialog(_('Parent location is unknown'),
115
_('Pulling is not possible until there is no parent location.'))
119
from bzrlib.workingtree import WorkingTree
120
tree_to = WorkingTree.open_containing(self.comm.get_path())[0]
121
branch_to = tree_to.branch
122
except errors.NoWorkingTree:
124
branch_to = Branch.open_containing(self.comm.get_path())[0]
125
except errors.NotBranchError:
126
self.dialog.error_dialog(_('Directory is not a branch'),
127
_('You can perform this action only in a branch.'))
129
location = branch_to.get_parent()
131
self.dialog.error_dialog(_('Parent location is unknown'),
132
_('Pulling is not possible until there is a parent location.'))
136
branch_from = Branch.open(location)
137
except errors.NotBranchError:
138
self.dialog.error_dialog(_('Directory is not a branch'),
139
_('You can perform this action only in a branch.'))
141
if branch_to.get_parent() is None:
142
branch_to.set_parent(branch_from.base)
144
old_rh = branch_to.revision_history()
145
if tree_to is not None:
146
tree_to.pull(branch_from)
148
branch_to.pull(branch_from)
117
150
self.dialog.info_dialog(_('Pull successful'),
118
151
_('%d revision(s) pulled.') % ret)
120
self.comm.set_busy(self.comm.window_main, False)
154
self.comm.set_busy(self.comm.window_main, False)
122
156
def on_menuitem_branch_push_activate(self, widget):
123
157
""" Branch/Push... menu handler. """
134
168
def on_menuitem_branch_initialize_activate(self, widget):
135
169
""" Initialize current directory. """
136
import olive.backend.init as init
139
init.init(self.comm.get_path())
171
location = self.comm.get_path()
172
from bzrlib.builtins import get_format_type
174
format = get_format_type('default')
176
if not os.path.exists(location):
180
existing_bzrdir = bzrdir.BzrDir.open(location)
181
except NotBranchError:
182
bzrdir.BzrDir.create_branch_convenience(location, format=format)
184
if existing_bzrdir.has_branch():
185
if existing_bzrdir.has_workingtree():
186
raise AlreadyBranchError(location)
188
raise BranchExistsWithoutWorkingTree(location)
190
existing_bzrdir.create_branch()
191
existing_bzrdir.create_workingtree()
140
192
except errors.AlreadyBranchError, errmsg:
141
193
self.dialog.error_dialog(_('Directory is already a branch'),
142
194
_('The current directory (%s) is already a branch.\nYou can start using it, or initialize another directory.') % errmsg)
143
195
except errors.BranchExistsWithoutWorkingTree, errmsg:
144
196
self.dialog.error_dialog(_('Branch without a working tree'),
145
197
_('The current directory (%s)\nis a branch without a working tree.') % errmsg)
149
self.dialog.info_dialog(_('Ininialize successful'),
199
self.dialog.info_dialog(_('Initialize successful'),
150
200
_('Directory successfully initialized.'))
151
201
self.comm.refresh_right()
244
294
m_commit = self.menu.ui.get_widget('/context_right/commit')
245
295
m_diff = self.menu.ui.get_widget('/context_right/diff')
246
296
# check if we're in a branch
247
if not is_branch(self.comm.get_path()):
298
from bzrlib.branch import Branch
299
Branch.open_containing(self.comm.get_path())
300
m_add.set_sensitive(True)
301
m_remove.set_sensitive(True)
302
m_commit.set_sensitive(True)
303
m_diff.set_sensitive(True)
304
except errors.NotBranchError:
248
305
m_add.set_sensitive(False)
249
306
m_remove.set_sensitive(False)
250
307
m_commit.set_sensitive(False)
251
308
m_diff.set_sensitive(False)
253
m_add.set_sensitive(True)
254
m_remove.set_sensitive(True)
255
m_commit.set_sensitive(True)
256
m_diff.set_sensitive(True)
257
309
self.menu.right_context_menu().popup(None, None, None, 0,