dag: rename `text` to `rev_text`
[git-cola.git] / cola / cmd.py
blob528e8c8d9c6b313e4477a1ffd762bf48dc159e62
1 """Base Command class"""
2 from __future__ import absolute_import, division, print_function, unicode_literals
5 class Command(object):
6 """Mixin interface for commands"""
8 UNDOABLE = False
10 @staticmethod
11 def name():
12 """Return the command's name"""
13 return '(undefined)'
15 @classmethod
16 def is_undoable(cls):
17 """Can this be undone?"""
18 return cls.UNDOABLE
20 def do(self):
21 """Execute the command"""
22 return
24 def undo(self):
25 """Undo the command"""
26 return
29 class ContextCommand(Command):
30 """Base class for commands that operate on a context"""
32 def __init__(self, context):
33 self.context = context
34 self.model = context.model
35 self.cfg = context.cfg
36 self.git = context.git
37 self.selection = context.selection
38 self.fsmonitor = context.fsmonitor