/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/frontend/gtk/handler.py

  • Committer: Jelmer Vernooij
  • Date: 2006-09-05 01:00:51 UTC
  • mto: (0.8.83 merge)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: jelmer@samba.org-20060905010051-773009d61edcc7c9
Eliminate olive.backend.update

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
from olive.backend.info import is_branch
31
31
import bzrlib.errors as errors
 
32
from bzrlib.branch import Branch
32
33
 
33
34
from dialog import OliveDialog
34
35
from menu import OliveMenu
72
73
    
73
74
    def on_menuitem_branch_missing_revisions_activate(self, widget):
74
75
        """ Branch/Missing revisions menu handler. """
75
 
        import olive.backend.update as update
76
76
        
77
77
        self.comm.set_busy(self.comm.window_main)
78
78
        
79
79
        try:
80
 
            ret = update.missing(self.comm.get_path())
81
 
        except errors.NotBranchError:
82
 
            self.dialog.error_dialog(_('Directory is not a branch'),
83
 
                                     _('You can perform this action only in a branch.'))
84
 
        except errors.ConnectionError:
85
 
            self.dialog.error_dialog(_('Connection error'),
86
 
                                     _('Cannot connect to remote location.\nPlease try again later.'))
87
 
        except errors.NoLocationKnown:
88
 
            self.dialog.error_dialog(_('Parent location is unknown'),
89
 
                                     _('Cannot determine missing revisions if no parent location is known.'))
90
 
        else:
 
80
            import bzrlib
 
81
            
 
82
            try:
 
83
                local_branch = Branch.open_containing(self.comm.get_path())[0]
 
84
            except NotBranchError:
 
85
                self.dialog.error_dialog(_('Directory is not a branch'),
 
86
                                         _('You can perform this action only in a branch.'))
 
87
                return
 
88
            
 
89
            other_branch = local_branch.get_parent()
 
90
            if other_branch is None:
 
91
                self.dialog.error_dialog(_('Parent location is unknown'),
 
92
                                         _('Cannot determine missing revisions if no parent location is known.'))
 
93
                return
 
94
            
 
95
            remote_branch = Branch.open(other_branch)
 
96
            
 
97
            if remote_branch.base == local_branch.base:
 
98
                remote_branch = local_branch
 
99
 
 
100
            ret = len(local_branch.missing_revisions(remote_branch))
 
101
 
91
102
            if ret > 0:
92
103
                self.dialog.info_dialog(_('There are missing revisions'),
93
104
                                        _('%d revision(s) missing.') % ret)
94
105
            else:
95
106
                self.dialog.info_dialog(_('Local branch up to date'),
96
107
                                        _('There are no missing revisions.'))
97
 
        
98
 
        self.comm.set_busy(self.comm.window_main, False)
 
108
        finally:
 
109
            self.comm.set_busy(self.comm.window_main, False)
99
110
    
100
111
    def on_menuitem_branch_pull_activate(self, widget):
101
112
        """ Branch/Pull menu handler. """
102
 
        import olive.backend.update as update
103
113
        
104
114
        self.comm.set_busy(self.comm.window_main)
105
 
        
 
115
 
106
116
        try:
107
 
            ret = update.pull(self.comm.get_path())
108
 
        except errors.NotBranchError:
109
 
            self.dialog.error_dialog(_('Directory is not a branch'),
110
 
                                     _('You can perform this action only in a branch.'))
111
 
        except errors.NoLocationKnown:
112
 
            self.dialog.error_dialog(_('Parent location is unknown'),
113
 
                                     _('Pulling is not possible until there is no parent location.'))
114
 
        else:
 
117
            try:
 
118
                tree_to = WorkingTree.open_containing(self.comm.get_path())[0]
 
119
                branch_to = tree_to.branch
 
120
            except NoWorkingTree:
 
121
                tree_to = None
 
122
                branch_to = Branch.open_containing(self.comm.get_path())[0]
 
123
            except NoBranchError:
 
124
                 self.dialog.error_dialog(_('Directory is not a branch'),
 
125
                                         _('You can perform this action only in a branch.'))
 
126
 
 
127
            location = branch_to.get_parent()
 
128
            if location is None:
 
129
                self.dialog.error_dialog(_('Parent location is unknown'),
 
130
                                         _('Pulling is not possible until there is a parent location.'))
 
131
                return
 
132
 
 
133
            try:
 
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.'))
 
138
 
 
139
            if branch_to.get_parent() is None:
 
140
                branch_to.set_parent(branch_from.base)
 
141
 
 
142
            old_rh = branch_to.revision_history()
 
143
            if tree_to is not None:
 
144
                tree_to.pull(branch_from, overwrite)
 
145
            else:
 
146
                branch_to.pull(branch_from, overwrite)
 
147
            
115
148
            self.dialog.info_dialog(_('Pull successful'),
116
149
                                    _('%d revision(s) pulled.') % ret)
117
 
        
118
 
        self.comm.set_busy(self.comm.window_main, False)
 
150
            
 
151
        finally:
 
152
            self.comm.set_busy(self.comm.window_main, False)
119
153
    
120
154
    def on_menuitem_branch_push_activate(self, widget):
121
155
        """ Branch/Push... menu handler. """