/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

  • Committer: Ian Clatworthy
  • Date: 2009-02-18 01:00:32 UTC
  • mto: (0.64.117 trunk)
  • mto: This revision was merged to the branch mainline in revision 6631.
  • Revision ID: ian.clatworthy@canonical.com-20090218010032-isfpmgqovf3s4lt6
move note/message/debug into higher level classes

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
"""
22
22
 
23
23
import sys
 
24
import time
 
25
 
 
26
from bzrlib import debug
24
27
from bzrlib.errors import NotBranchError
 
28
from bzrlib.trace import (
 
29
    mutter,
 
30
    note,
 
31
    warning,
 
32
    )
25
33
import errors
26
34
 
27
35
 
109
117
                break
110
118
        self.post_process()
111
119
 
 
120
    def note(self, msg, *args):
 
121
        """Output a note but timestamp it."""
 
122
        msg = "%s %s" % (self._time_of_day(), msg)
 
123
        note(msg, *args)
 
124
 
 
125
    def warning(self, msg, *args):
 
126
        """Output a warning but timestamp it."""
 
127
        msg = "%s WARNING: %s" % (self._time_of_day(), msg)
 
128
        warning(msg, *args)
 
129
 
 
130
    def debug(self, mgs, *args):
 
131
        """Output a debug message if the appropriate -D option was given."""
 
132
        if "fast-import" in debug.debug_flags:
 
133
            msg = "%s DEBUG: %s" % (self._time_of_day(), msg)
 
134
            mutter(msg, *args)
 
135
 
 
136
    def _time_of_day(self):
 
137
        """Time of day as a string."""
 
138
        # Note: this is a separate method so tests can patch in a fixed value
 
139
        return time.strftime("%H:%M:%S")
 
140
 
112
141
    def pre_process(self):
113
142
        """Hook for logic at start of processing."""
114
143
        pass
171
200
                handler(self, fc)
172
201
        self.post_process_files()
173
202
 
 
203
    def note(self, msg, *args):
 
204
        """Output a note but add context."""
 
205
        msg = "%s (%s)" % (msg, self.command.id)
 
206
        note(msg, *args)
 
207
 
 
208
    def warning(self, msg, *args):
 
209
        """Output a warning but add context."""
 
210
        msg = "WARNING: %s (%s)" % (msg, self.command.id)
 
211
        warning(msg, *args)
 
212
 
 
213
    def debug(self, msg, *args):
 
214
        """Output a mutter if the appropriate -D option was given."""
 
215
        if "fast-import" in debug.debug_flags:
 
216
            msg = "%s (%s)" % (msg, self.command.id)
 
217
            mutter(msg, *args)
 
218
 
174
219
    def pre_process_files(self):
175
220
        """Prepare for committing."""
176
221
        pass