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

  • Committer: Jelmer Vernooij
  • Date: 2006-09-27 20:30:59 UTC
  • mto: (0.12.2 olive)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: jelmer@samba.org-20060927203059-85792ae0a81db524
Bunch of small fixes, cleanups and simplifications.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
from bzrlib.workingtree import WorkingTree
32
32
 
33
33
from dialog import about, error_dialog, info_dialog
34
 
from menu import OliveMenu
35
34
from launch import launch
36
35
 
37
36
class OliveHandler:
38
37
    """ Signal handler class for Olive. """
39
 
    def __init__(self,  comm):
40
 
        self.comm = comm
41
 
        
42
 
        self.menu = OliveMenu(self.comm)
 
38
    def __init__(self, path):
 
39
        self.wt, self.path = WorkingTree.open_containing(path)
43
40
    
44
41
    def on_about_activate(self, widget):
45
42
        about()
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())
53
48
        add.display()
54
49
    
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()
59
54
        branch.display()
60
55
    
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()
65
60
        checkout.display()
66
61
    
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)
72
66
        commit.display()
73
67
    
74
68
    def on_menuitem_branch_missing_revisions_activate(self, widget):
79
73
        try:
80
74
            import bzrlib
81
75
            
82
 
            try:
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.'))
87
 
                return
 
76
            local_branch = self.wt.branch
88
77
            
89
78
            other_branch = local_branch.get_parent()
90
79
            if other_branch is None:
113
102
        
114
103
        self.comm.set_busy(self.comm.window_main)
115
104
 
 
105
        branch_to = self.wt.branch
 
106
 
 
107
        location = branch_to.get_parent()
 
108
        if location is None:
 
109
            error_dialog(_('Parent location is unknown'),
 
110
                                     _('Pulling is not possible until there is a parent location.'))
 
111
            return
 
112
 
116
113
        try:
117
 
            try:
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:
122
 
                tree_to = None
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.'))
127
 
 
128
 
            location = branch_to.get_parent()
129
 
            if location is None:
130
 
                error_dialog(_('Parent location is unknown'),
131
 
                                         _('Pulling is not possible until there is a parent location.'))
132
 
                return
133
 
 
134
 
            try:
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.'))
139
 
 
140
 
            if branch_to.get_parent() is None:
141
 
                branch_to.set_parent(branch_from.base)
142
 
 
143
 
            old_rh = branch_to.revision_history()
144
 
            if tree_to is not None:
145
 
                tree_to.pull(branch_from)
146
 
            else:
147
 
                branch_to.pull(branch_from)
148
 
            
149
 
            info_dialog(_('Pull successful'),
150
 
                                    _('%d revision(s) pulled.') % ret)
151
 
            
152
 
        finally:
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.'))
 
118
 
 
119
        if branch_to.get_parent() is None:
 
120
            branch_to.set_parent(branch_from.base)
 
121
 
 
122
        old_rh = branch_to.revision_history()
 
123
        if tree_to is not None:
 
124
            tree_to.pull(branch_from)
 
125
        else:
 
126
            branch_to.pull(branch_from)
 
127
        
 
128
        info_dialog(_('Pull successful'), _('%d revision(s) pulled.') % ret)
154
129
    
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)
166
140
        status.display()
167
141
    
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)
234
207
        window.show()
235
208
    
236
209
    def on_menuitem_stats_infos_activate(self, widget):