31
31
from bzrlib.workingtree import WorkingTree
33
33
from dialog import about, error_dialog, info_dialog
34
from menu import OliveMenu
35
34
from launch import launch
37
36
class OliveHandler:
38
37
""" Signal handler class for Olive. """
39
def __init__(self, comm):
42
self.menu = OliveMenu(self.comm)
38
def __init__(self, path):
39
self.wt, self.path = WorkingTree.open_containing(path)
44
41
def on_about_activate(self, widget):
47
44
def on_menuitem_add_files_activate(self, widget):
48
45
""" Add file(s)... menu handler. """
49
46
from add import OliveAdd
50
wt, path = WorkingTree.open_containing(self.comm.get_path())
51
add = OliveAdd(wt, path,
52
self.comm.get_selected_right())
47
add = OliveAdd(self.wt, self.path, self.comm.get_selected_right())
55
50
def on_menuitem_branch_get_activate(self, widget):
56
51
""" Branch/Get... menu handler. """
57
52
from branch import OliveBranch
58
branch = OliveBranch(self.comm)
53
branch = OliveBranch()
61
56
def on_menuitem_branch_checkout_activate(self, widget):
62
57
""" Branch/Checkout... menu handler. """
63
58
from checkout import OliveCheckout
64
checkout = OliveCheckout(self.comm)
59
checkout = OliveCheckout()
67
62
def on_menuitem_branch_commit_activate(self, widget):
68
63
""" Branch/Commit... menu handler. """
69
64
from commit import OliveCommit
70
wt, path = WorkingTree.open_containing(self.comm.get_path())
71
commit = OliveCommit(wt, path)
65
commit = OliveCommit(self.wt, self.path)
74
68
def on_menuitem_branch_missing_revisions_activate(self, widget):
83
local_branch = Branch.open_containing(self.comm.get_path())[0]
84
except NotBranchError:
85
error_dialog(_('Directory is not a branch'),
86
_('You can perform this action only in a branch.'))
76
local_branch = self.wt.branch
89
78
other_branch = local_branch.get_parent()
90
79
if other_branch is None:
114
103
self.comm.set_busy(self.comm.window_main)
105
branch_to = self.wt.branch
107
location = branch_to.get_parent()
109
error_dialog(_('Parent location is unknown'),
110
_('Pulling is not possible until there is a parent location.'))
118
from bzrlib.workingtree import WorkingTree
119
tree_to = WorkingTree.open_containing(self.comm.get_path())[0]
120
branch_to = tree_to.branch
121
except errors.NoWorkingTree:
123
branch_to = Branch.open_containing(self.comm.get_path())[0]
124
except errors.NotBranchError:
125
error_dialog(_('Directory is not a branch'),
126
_('You can perform this action only in a branch.'))
128
location = branch_to.get_parent()
130
error_dialog(_('Parent location is unknown'),
131
_('Pulling is not possible until there is a parent location.'))
135
branch_from = Branch.open(location)
136
except errors.NotBranchError:
137
error_dialog(_('Directory is not a branch'),
138
_('You can perform this action only in a branch.'))
140
if branch_to.get_parent() is None:
141
branch_to.set_parent(branch_from.base)
143
old_rh = branch_to.revision_history()
144
if tree_to is not None:
145
tree_to.pull(branch_from)
147
branch_to.pull(branch_from)
149
info_dialog(_('Pull successful'),
150
_('%d revision(s) pulled.') % ret)
153
self.comm.set_busy(self.comm.window_main, False)
114
branch_from = Branch.open(location)
115
except errors.NotBranchError:
116
error_dialog(_('Directory is not a branch'),
117
_('You can perform this action only in a branch.'))
119
if branch_to.get_parent() is None:
120
branch_to.set_parent(branch_from.base)
122
old_rh = branch_to.revision_history()
123
if tree_to is not None:
124
tree_to.pull(branch_from)
126
branch_to.pull(branch_from)
128
info_dialog(_('Pull successful'), _('%d revision(s) pulled.') % ret)
155
130
def on_menuitem_branch_push_activate(self, widget):
156
131
""" Branch/Push... menu handler. """
161
136
def on_menuitem_branch_status_activate(self, widget):
162
137
""" Branch/Status... menu handler. """
163
138
from status import OliveStatus
164
wt, wtpath = WorkingTree.open_containing(self.comm.get_path())
165
status = OliveStatus(wt, wtpath)
139
status = OliveStatus(self.wt, self.path)
168
142
def on_menuitem_branch_initialize_activate(self, widget):
228
202
""" Statistics/Differences... menu handler. """
229
203
from bzrlib.plugins.gtk.viz.diffwin import DiffWindow
230
204
window = DiffWindow()
231
wt = WorkingTree.open_containing(self.comm.get_path())[0]
232
parent_tree = wt.branch.repository.revision_tree(wt.branch.last_revision())
233
window.set_diff(wt.branch.nick, wt, parent_tree)
205
parent_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
206
window.set_diff(self.wt.branch.nick, self.wt, parent_tree)
236
209
def on_menuitem_stats_infos_activate(self, widget):