~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/shelf_ui.py

  • Committer: Aaron Bentley
  • Date: 2008-11-15 20:37:36 UTC
  • mto: This revision was merged to the branch mainline in revision 3838.
  • Revision ID: aaron@aaronbentley.com-20081115203736-6ikutv274y59s0jo
Shelf supports multiple diff writers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    ui,
34
34
    workingtree,
35
35
)
36
 
try:
37
 
    from bzrlib.plugins.bzrtools import colordiff
38
 
except ImportError:
39
 
    colordiff = None
40
36
 
41
37
 
42
38
class Shelver(object):
43
39
    """Interactively shelve the changes in a working tree."""
44
40
 
45
 
    def __init__(self, work_tree, target_tree, auto=False,
 
41
    def __init__(self, work_tree, target_tree, diff_writer=None, auto=False,
46
42
                 auto_apply=False, file_list=None, message=None):
47
43
        """Constructor.
48
44
 
56
52
        """
57
53
        self.work_tree = work_tree
58
54
        self.target_tree = target_tree
59
 
        if colordiff is not None:
60
 
            self.diff_writer = colordiff.DiffWriter(sys.stdout, False)
61
 
        else:
 
55
        self.diff_writer = diff_writer
 
56
        if self.diff_writer is None:
62
57
            self.diff_writer = sys.stdout
63
58
        self.manager = work_tree.get_shelf_manager()
64
59
        self.auto = auto
67
62
        self.message = message
68
63
 
69
64
    @classmethod
70
 
    def from_args(klass, revision=None, all=False, file_list=None,
 
65
    def from_args(klass, diff_writer, revision=None, all=False, file_list=None,
71
66
                  message=None, directory='.'):
72
67
        """Create a shelver from commandline arguments.
73
68
 
80
75
        tree, path = workingtree.WorkingTree.open_containing(directory)
81
76
        target_tree = builtins._get_one_revision_tree('shelf2', revision,
82
77
            tree.branch, tree)
83
 
        return klass(tree, target_tree, all, all, file_list, message)
 
78
        return klass(tree, target_tree, diff_writer, all, all, file_list,
 
79
                     message)
84
80
 
85
81
    def run(self):
86
82
        """Interactively shelve the changes."""