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

  • Committer: Jelmer Vernooij
  • Date: 2007-02-01 15:50:40 UTC
  • Revision ID: jelmer@samba.org-20070201155040-3hq4mfbxs99kzazy
add framework for tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
from bzrlib.workingtree import WorkingTree
30
30
 
31
31
from dialog import error_dialog, info_dialog, warning_dialog
 
32
from errors import show_bzr_error
32
33
from launch import launch
33
34
from olive import OlivePreferences, DiffWindow
34
35
 
68
69
                                       _('Open'), None,
69
70
                                       _('Open the selected file'),
70
71
                                       self.open_file),
 
72
                                      ('revert', None,
 
73
                                       _('Revert'), None,
 
74
                                       _('Revert the changes'),
 
75
                                       self.revert),
71
76
                                      ('commit', None,
72
77
                                       _('Commit'), None,
73
78
                                       _('Commit the changes'),
130
135
    def left_context_menu(self):
131
136
        return self.cmenu_left
132
137
    
 
138
    @show_bzr_error
133
139
    def add_file(self, action):
134
140
        """ Right context menu -> Add """
135
141
        import bzrlib.add
143
149
                         _('Please select a file from the list,\nor choose the other option.'))
144
150
            return
145
151
        
146
 
        try:
147
 
            bzrlib.add.smart_add([os.path.join(directory, filename)])
148
 
        except errors.NotBranchError:
149
 
            error_dialog(_('Directory is not a branch'),
150
 
                         _('You can perform this action only in a branch.'))
151
 
            return
 
152
        bzrlib.add.smart_add([os.path.join(directory, filename)])
152
153
    
 
154
    @show_bzr_error
153
155
    def remove_file(self, action):
154
156
        """ Right context menu -> Remove """
155
157
        # Remove only the selected file
161
163
                         _('Please select a file from the list,\nor choose the other option.'))
162
164
            return
163
165
        
164
 
        try:
165
 
            wt, path = WorkingTree.open_containing(os.path.join(directory, filename))
166
 
            wt.remove(path)
167
 
 
168
 
        except errors.NotBranchError:
169
 
            error_dialog(_('Directory is not a branch'),
170
 
                         _('You can perform this action only in a branch.'))
171
 
            return
172
 
        except errors.NotVersionedError:
173
 
            error_dialog(_('File not versioned'),
174
 
                         _('The selected file is not versioned.'))
175
 
            return
176
 
 
 
166
        wt, path = WorkingTree.open_containing(os.path.join(directory, filename))
 
167
        wt.remove(path)
177
168
        self.app.set_path(self.path)
178
169
        self.app.refresh_right()
179
170
 
206
197
            else:
207
198
                launch(fullpath) 
208
199
 
 
200
    def revert(self, action):
 
201
        """ Right context menu -> Revert """
 
202
        wt, path = WorkingTree.open_containing(self.path)
 
203
        ret = wt.revert([os.path.join(path, self.selected)])
 
204
        if ret:
 
205
            warning_dialog(_('Conflicts detected'),
 
206
                           _('Please have a look at the working tree before continuing.'))
 
207
        else:
 
208
            info_dialog(_('Revert successful'),
 
209
                        _('All files reverted to last revision.'))
 
210
        self.app.refresh_right()       
 
211
    
209
212
    def commit(self, action):
210
213
        """ Right context menu -> Commit """
211
214
        from commit import CommitDialog
215
218
            branch = wt.branch
216
219
        except NotBranchError, e:
217
220
            path = e.path
218
 
        commit = CommitDialog(wt, path, not branch)
219
 
        commit.display()
 
221
        
 
222
        commit = CommitDialog(wt, path, not branch, self.selected)
 
223
        response = commit.run()
 
224
        if response != gtk.RESPONSE_NONE:
 
225
            commit.hide()
 
226
        
 
227
            if response == gtk.RESPONSE_OK:
 
228
                self.app.refresh_right()
 
229
            
 
230
            commit.destroy()
220
231
    
 
232
    @show_bzr_error
221
233
    def diff(self, action):
222
234
        """ Right context menu -> Diff """
223
 
        try:
224
 
            wt = WorkingTree.open_containing(self.path)[0]
225
 
        except errors.NotBranchError:
226
 
            error_dialog(_('File is not in a branch'),
227
 
                         _('The selected file is not in a branch.'))
228
 
            return
229
 
        
 
235
        wt = WorkingTree.open_containing(self.path)[0]
230
236
        window = DiffWindow()
231
237
        parent_tree = wt.branch.repository.revision_tree(wt.branch.last_revision())
232
238
        window.set_diff(wt.branch.nick, wt, parent_tree)
233
 
        try:
234
 
            window.set_file(wt.relpath(self.path + os.sep + self.selected))
235
 
        except errors.NoSuchFile:
236
 
            pass
 
239
        window.set_file(wt.relpath(self.path + os.sep + self.selected))
237
240
        window.show()
238
241
    
239
242
    def bookmark(self, action):