~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/delta.py

Make ChangeReporter interface nicer

Show diffs side-by-side

added added

removed removed

Lines of Context:
255
255
class ChangeReporter(object):
256
256
    """Report changes between two trees"""
257
257
 
258
 
    def __init__(self, old_inventory, output=None, suppress_root_add=True):
 
258
    def __init__(self, old_inventory, output=None, suppress_root_add=True,
 
259
                 output_file=None):
259
260
        """Constructor
260
261
 
261
262
        :param old_inventory: The inventory of the old tree
263
264
            accepts a format and parameters.
264
265
        :param supress_root_add: If true, adding the root will be ignored
265
266
            (i.e. when a tree has just been initted)
 
267
        :param output_file: If supplied, a file-like object to write to.
 
268
            Only one of output and output_file may be supplied.
266
269
        """
267
270
        self.old_inventory = old_inventory
 
271
        if output_file is not None:
 
272
            if output is not None:
 
273
                raise BzrError('Cannot specify both output and output_file')
 
274
            def output(fmt, *args):
 
275
                output_file.write((fmt % args) + '\n')
268
276
        self.output = output
269
277
        if self.output is None:
270
278
            from bzrlib import trace