/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 bzrlib/diff.py

  • Committer: Andrew Bennetts
  • Date: 2010-04-08 07:01:10 UTC
  • mfrom: (5138 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5141.
  • Revision ID: andrew.bennetts@canonical.com-20100408070110-mnvv0kbbyaj6cqdg
MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
from bzrlib.workingtree import WorkingTree
44
44
""")
45
45
 
 
46
from bzrlib.registry import (
 
47
    Registry,
 
48
    )
46
49
from bzrlib.symbol_versioning import (
47
50
    deprecated_function,
48
51
    )
411
414
                    old_label='a/', new_label='b/',
412
415
                    extra_trees=None,
413
416
                    path_encoding='utf8',
414
 
                    using=None):
 
417
                    using=None,
 
418
                    format_cls=None):
415
419
    """Show in text form the changes from one tree to another.
416
420
 
417
 
    to_file
418
 
        The output stream.
419
 
 
420
 
    specific_files
421
 
        Include only changes to these files - None for all changes.
422
 
 
423
 
    external_diff_options
424
 
        If set, use an external GNU diff and pass these options.
425
 
 
426
 
    extra_trees
427
 
        If set, more Trees to use for looking up file ids
428
 
 
429
 
    path_encoding
430
 
        If set, the path will be encoded as specified, otherwise is supposed
431
 
        to be utf8
 
421
    :param to_file: The output stream.
 
422
    :param specific_files:Include only changes to these files - None for all
 
423
        changes.
 
424
    :param external_diff_options: If set, use an external GNU diff and pass 
 
425
        these options.
 
426
    :param extra_trees: If set, more Trees to use for looking up file ids
 
427
    :param path_encoding: If set, the path will be encoded as specified, 
 
428
        otherwise is supposed to be utf8
 
429
    :param format_cls: Formatter class (DiffTree subclass)
432
430
    """
 
431
    if format_cls is None:
 
432
        format_cls = DiffTree
433
433
    old_tree.lock_read()
434
434
    try:
435
435
        if extra_trees is not None:
437
437
                tree.lock_read()
438
438
        new_tree.lock_read()
439
439
        try:
440
 
            differ = DiffTree.from_trees_options(old_tree, new_tree, to_file,
441
 
                                                 path_encoding,
442
 
                                                 external_diff_options,
443
 
                                                 old_label, new_label, using)
 
440
            differ = format_cls.from_trees_options(old_tree, new_tree, to_file,
 
441
                                                   path_encoding,
 
442
                                                   external_diff_options,
 
443
                                                   old_label, new_label, using)
444
444
            return differ.show_diff(specific_files, extra_trees)
445
445
        finally:
446
446
            new_tree.unlock()
882
882
    def show_diff(self, specific_files, extra_trees=None):
883
883
        """Write tree diff to self.to_file
884
884
 
885
 
        :param sepecific_files: the specific files to compare (recursive)
 
885
        :param specific_files: the specific files to compare (recursive)
886
886
        :param extra_trees: extra trees to use for mapping paths to file_ids
887
887
        """
888
888
        try:
978
978
            if error_path is None:
979
979
                error_path = old_path
980
980
            raise errors.NoDiffFound(error_path)
 
981
 
 
982
 
 
983
format_registry = Registry()
 
984
format_registry.register('default', DiffTree)