/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to processor.py

abstract CommitHandler

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
    def tag_handler(self, cmd):
83
83
        """Process a TagCommand."""
84
84
        raise NotImplementedError(self.tag_handler)
 
85
 
 
86
 
 
87
class CommitHandler(object):
 
88
    """Base class for commit handling.
 
89
    
 
90
    Subclasses should override the pre_*, post_* and *_handler
 
91
    methods as appropriate.
 
92
    """
 
93
 
 
94
    def __init__(self, command):
 
95
        self.command = command
 
96
 
 
97
    def process(self):
 
98
        self.pre_process_files()
 
99
        for fc in self.command.file_iter():
 
100
            try:
 
101
                handler = self.__class__.__dict__[fc.name + "_handler"]
 
102
            except KeyError:
 
103
                raise errors.MissingHandler(fc.name)
 
104
            else:
 
105
                handler(self, fc)
 
106
        self.post_process_files()
 
107
 
 
108
    def pre_process_files(self):
 
109
        """Prepare for committing."""
 
110
        pass
 
111
 
 
112
    def post_process_files(self):
 
113
        """Save the revision."""
 
114
        pass
 
115
 
 
116
    def modify_handler(self, filecmd):
 
117
        """Handle a filemodify command."""
 
118
        raise NotImplementedError(self.modify_handler)
 
119
 
 
120
    def delete_handler(self, filecmd):
 
121
        """Handle a filedelete command."""
 
122
        raise NotImplementedError(self.delete_handler)
 
123
 
 
124
    def copy_handler(self, filecmd):
 
125
        """Handle a filecopy command."""
 
126
        raise NotImplementedError(self.copy_handler)
 
127
 
 
128
    def rename_handler(self, filecmd):
 
129
        """Handle a filerename command."""
 
130
        raise NotImplementedError(self.rename_handler)
 
131
 
 
132
    def deleteall_handler(self, filecmd):
 
133
        """Handle a filedeleteall command."""
 
134
        raise NotImplementedError(self.deleteall_handler)