/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to olive/__init__.py

  • Committer: Jelmer Vernooij
  • Date: 2007-01-29 23:27:09 UTC
  • Revision ID: jelmer@samba.org-20070129232709-0yygg83sh9is3xvw
Use decorator for catching and showing bzr-gtk errors graphically. Eventually, this should go away and should be handled by the ui factory.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
import bzrlib.errors as errors
36
36
from bzrlib.workingtree import WorkingTree
37
37
 
38
 
# Olive GTK UI version
39
 
__version__ = '0.14.0'
40
 
 
41
38
from dialog import error_dialog, info_dialog
 
39
from errors import show_bzr_error
42
40
from guifiles import GLADEFILENAME
43
41
 
44
42
# import this classes only once
278
276
            info_dialog(_('Local branch up to date'),
279
277
                        _('There are no missing revisions.'))
280
278
 
 
279
    @show_bzr_error
281
280
    def on_menuitem_branch_pull_activate(self, widget):
282
281
        """ Branch/Pull menu handler. """
283
282
        branch_to = self.wt.branch
288
287
                                     _('Pulling is not possible until there is a parent location.'))
289
288
            return
290
289
 
291
 
        try:
292
 
            branch_from = Branch.open(location)
293
 
        except errors.NotBranchError:
294
 
            error_dialog(_('Directory is not a branch'),
295
 
                                     _('You can perform this action only in a branch.'))
 
290
        branch_from = Branch.open(location)
296
291
 
297
292
        if branch_to.get_parent() is None:
298
293
            branch_to.set_parent(branch_from.base)
318
313
        status = OliveStatus(self.wt, self.wtpath)
319
314
        status.display()
320
315
    
 
316
    @show_bzr_error
321
317
    def on_menuitem_branch_initialize_activate(self, widget):
322
318
        """ Initialize current directory. """
323
319
        import bzrlib.bzrdir as bzrdir
324
320
        
 
321
        if not os.path.exists(self.path):
 
322
            os.mkdir(self.path)
 
323
 
325
324
        try:
326
 
            if not os.path.exists(self.path):
327
 
                os.mkdir(self.path)
328
 
     
329
 
            try:
330
 
                existing_bzrdir = bzrdir.BzrDir.open(self.path)
331
 
            except errors.NotBranchError:
332
 
                bzrdir.BzrDir.create_branch_convenience(self.path)
333
 
            else:
334
 
                if existing_bzrdir.has_branch():
335
 
                    if existing_bzrdir.has_workingtree():
336
 
                        raise errors.AlreadyBranchError(self.path)
337
 
                    else:
338
 
                        raise errors.BranchExistsWithoutWorkingTree(self.path)
 
325
            existing_bzrdir = bzrdir.BzrDir.open(self.path)
 
326
        except errors.NotBranchError:
 
327
            bzrdir.BzrDir.create_branch_convenience(self.path)
 
328
        else:
 
329
            if existing_bzrdir.has_branch():
 
330
                if existing_bzrdir.has_workingtree():
 
331
                    raise errors.AlreadyBranchError(self.path)
339
332
                else:
340
 
                    existing_bzrdir.create_branch()
341
 
                    existing_bzrdir.create_workingtree()
342
 
        except errors.AlreadyBranchError, errmsg:
343
 
            error_dialog(_('Directory is already a branch'),
344
 
                         _('The current directory (%s) is already a branch.\nYou can start using it, or initialize another directory.') % errmsg)
345
 
        except errors.BranchExistsWithoutWorkingTree, errmsg:
346
 
            error_dialog(_('Branch without a working tree'),
347
 
                         _('The current directory (%s)\nis a branch without a working tree.') % errmsg)
348
 
        else:
349
 
            info_dialog(_('Initialize successful'),
350
 
                        _('Directory successfully initialized.'))
351
 
            self.refresh_right()
 
333
                    raise errors.BranchExistsWithoutWorkingTree(self.path)
 
334
            else:
 
335
                existing_bzrdir.create_branch()
 
336
                existing_bzrdir.create_workingtree()
 
337
        info_dialog(_('Initialize successful'),
 
338
                    _('Directory successfully initialized.'))
 
339
        self.refresh_right()
352
340
        
353
341
    def on_menuitem_file_annotate_activate(self, widget):
354
342
        """ File/Annotate... menu handler. """
796
784
            tree1 = WorkingTree.open_containing(path)[0]
797
785
        except (errors.NotBranchError, errors.NoWorkingTree):
798
786
            notbranch = True
799
 
        except errors.PermissionDenied:
800
 
            print "DEBUG: permission denied."
801
787
        
802
788
        if not notbranch:
803
789
            branch = tree1.branch