40
42
self.gladefile = gladefile
43
self.dialog = OliveDialog(self.gladefile)
45
self.menu = OliveMenu(self.gladefile, self.comm, self.dialog)
45
self.menu = OliveMenu(self.gladefile, self.comm)
47
47
def on_about_activate(self, widget):
50
50
def on_menuitem_add_files_activate(self, widget):
51
51
""" Add file(s)... menu handler. """
52
52
from add import OliveAdd
53
add = OliveAdd(self.gladefile, self.comm, self.dialog)
53
add = OliveAdd(self.gladefile, self.comm)
56
56
def on_menuitem_branch_get_activate(self, widget):
57
57
""" Branch/Get... menu handler. """
58
58
from branch import OliveBranch
59
branch = OliveBranch(self.gladefile, self.comm, self.dialog)
59
branch = OliveBranch(self.gladefile, self.comm)
62
62
def on_menuitem_branch_checkout_activate(self, widget):
63
63
""" Branch/Checkout... menu handler. """
64
64
from checkout import OliveCheckout
65
checkout = OliveCheckout(self.gladefile, self.comm, self.dialog)
65
checkout = OliveCheckout(self.gladefile, self.comm)
68
68
def on_menuitem_branch_commit_activate(self, widget):
69
69
""" Branch/Commit... menu handler. """
70
70
from commit import OliveCommit
71
commit = OliveCommit(self.gladefile, self.comm, self.dialog)
71
wt, path = WorkingTree.open_containing(self.comm.get_path())
72
commit = OliveCommit(self.gladefile, wt, path)
74
75
def on_menuitem_branch_missing_revisions_activate(self, widget):
75
76
""" Branch/Missing revisions menu handler. """
76
import olive.backend.update as update
78
78
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.'))
84
local_branch = Branch.open_containing(self.comm.get_path())[0]
85
except NotBranchError:
86
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
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))
93
self.dialog.info_dialog(_('There are missing revisions'),
104
info_dialog(_('There are missing revisions'),
94
105
_('%d revision(s) missing.') % ret)
96
self.dialog.info_dialog(_('Local branch up to date'),
107
info_dialog(_('Local branch up to date'),
97
108
_('There are no missing revisions.'))
99
self.comm.set_busy(self.comm.window_main, False)
110
self.comm.set_busy(self.comm.window_main, False)
101
112
def on_menuitem_branch_pull_activate(self, widget):
102
113
""" Branch/Pull menu handler. """
103
import olive.backend.update as update
105
115
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.'))
116
self.dialog.info_dialog(_('Pull successful'),
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
error_dialog(_('Directory is not a branch'),
127
_('You can perform this action only in a branch.'))
129
location = branch_to.get_parent()
131
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
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)
150
info_dialog(_('Pull successful'),
117
151
_('%d revision(s) pulled.') % ret)
119
self.comm.set_busy(self.comm.window_main, False)
154
self.comm.set_busy(self.comm.window_main, False)
121
156
def on_menuitem_branch_push_activate(self, widget):
122
157
""" Branch/Push... menu handler. """
123
158
from push import OlivePush
124
push = OlivePush(self.gladefile, self.comm, self.dialog)
159
push = OlivePush(self.gladefile, self.comm)
127
162
def on_menuitem_branch_status_activate(self, widget):
128
163
""" Branch/Status... menu handler. """
129
164
from status import OliveStatus
130
status = OliveStatus(self.gladefile, self.comm, self.dialog)
165
wt, wtpath = WorkingTree.open_containing(self.comm.get_path())
166
status = OliveStatus(self.gladefile, wt, wtpath)
133
169
def on_menuitem_branch_initialize_activate(self, widget):
134
170
""" Initialize current directory. """
135
import olive.backend.init as init
138
init.init(self.comm.get_path())
172
location = self.comm.get_path()
173
from bzrlib.builtins import get_format_type
175
format = get_format_type('default')
177
if not os.path.exists(location):
181
existing_bzrdir = bzrdir.BzrDir.open(location)
182
except NotBranchError:
183
bzrdir.BzrDir.create_branch_convenience(location, format=format)
185
if existing_bzrdir.has_branch():
186
if existing_bzrdir.has_workingtree():
187
raise AlreadyBranchError(location)
189
raise BranchExistsWithoutWorkingTree(location)
191
existing_bzrdir.create_branch()
192
existing_bzrdir.create_workingtree()
139
193
except errors.AlreadyBranchError, errmsg:
140
self.dialog.error_dialog(_('Directory is already a branch'),
194
error_dialog(_('Directory is already a branch'),
141
195
_('The current directory (%s) is already a branch.\nYou can start using it, or initialize another directory.') % errmsg)
142
196
except errors.BranchExistsWithoutWorkingTree, errmsg:
143
self.dialog.error_dialog(_('Branch without a working tree'),
197
error_dialog(_('Branch without a working tree'),
144
198
_('The current directory (%s)\nis a branch without a working tree.') % errmsg)
148
self.dialog.info_dialog(_('Ininialize successful'),
200
info_dialog(_('Initialize successful'),
149
201
_('Directory successfully initialized.'))
150
202
self.comm.refresh_right()
152
204
def on_menuitem_file_make_directory_activate(self, widget):
153
205
""" File/Make directory... menu handler. """
154
206
from mkdir import OliveMkdir
155
mkdir = OliveMkdir(self.gladefile, self.comm, self.dialog)
207
mkdir = OliveMkdir(self.gladefile, self.comm)
158
210
def on_menuitem_file_move_activate(self, widget):
159
211
""" File/Move... menu handler. """
160
212
from move import OliveMove
161
move = OliveMove(self.gladefile, self.comm, self.dialog)
213
move = OliveMove(self.gladefile, self.comm)
164
216
def on_menuitem_file_rename_activate(self, widget):
165
217
""" File/Rename... menu handler. """
166
218
from rename import OliveRename
167
rename = OliveRename(self.gladefile, self.comm, self.dialog)
219
rename = OliveRename(self.gladefile, self.comm)
170
222
def on_menuitem_remove_file_activate(self, widget):
171
223
""" Remove (unversion) selected file. """
172
224
from remove import OliveRemove
173
remove = OliveRemove(self.gladefile, self.comm, self.dialog)
225
remove = OliveRemove(self.gladefile, self.comm)
176
228
def on_menuitem_stats_diff_activate(self, widget):
177
229
""" Statistics/Differences... menu handler. """
178
230
from diff import OliveDiff
179
diff = OliveDiff(self.gladefile, self.comm, self.dialog)
231
diff = OliveDiff(self.gladefile, self.comm)
182
234
def on_menuitem_stats_infos_activate(self, widget):
183
235
""" Statistics/Informations... menu handler. """
184
236
from info import OliveInfo
185
info = OliveInfo(self.gladefile, self.comm, self.dialog)
237
info = OliveInfo(self.gladefile, self.comm)
188
240
def on_menuitem_stats_log_activate(self, widget):
189
241
""" Statistics/Log... menu handler. """
190
242
from log import OliveLog
191
log = OliveLog(self.gladefile, self.comm, self.dialog)
243
log = OliveLog(self.gladefile, self.comm)
194
246
def on_menuitem_view_refresh_activate(self, widget):