~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/shelf_ui.py

  • Committer: Jonathan Lange
  • Date: 2009-06-26 08:46:52 UTC
  • mto: (4484.1.1 bring-1.16.1-back)
  • mto: This revision was merged to the branch mainline in revision 4485.
  • Revision ID: jml@canonical.com-20090626084652-x7wn8yimd3fj0j0y
Tweak NEWS slightly based on mbp's feedback.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
)
36
36
 
37
37
 
38
 
class ShelfReporter(object):
39
 
 
40
 
    def __init__(self):
41
 
        self.delta_reporter = delta._ChangeReporter()
42
 
 
43
 
    def no_changes(self):
44
 
        trace.warning('No changes to shelve.')
45
 
 
46
 
    def shelved_id(self, shelf_id):
47
 
        trace.note('Changes shelved with id "%d".' % shelf_id)
48
 
 
49
 
    def selected_changes(self, transform):
50
 
        trace.note("Selected changes:")
51
 
        changes = transform.iter_changes()
52
 
        delta.report_changes(changes, self.delta_reporter)
53
 
 
54
 
 
55
38
class Shelver(object):
56
39
    """Interactively shelve the changes in a working tree."""
57
40
 
58
41
    def __init__(self, work_tree, target_tree, diff_writer=None, auto=False,
59
42
                 auto_apply=False, file_list=None, message=None,
60
 
                 destroy=False, manager=None, reporter=None):
 
43
                 destroy=False):
61
44
        """Constructor.
62
45
 
63
46
        :param work_tree: The working tree to shelve changes from.
69
52
        :param message: The message to associate with the shelved changes.
70
53
        :param destroy: Change the working tree without storing the shelved
71
54
            changes.
72
 
        :param manager: The shelf manager to use.
73
55
        """
74
56
        self.work_tree = work_tree
75
57
        self.target_tree = target_tree
76
58
        self.diff_writer = diff_writer
77
59
        if self.diff_writer is None:
78
60
            self.diff_writer = sys.stdout
79
 
        if manager is None:
80
 
            manager = work_tree.get_shelf_manager()
81
 
        self.manager = manager
 
61
        self.manager = work_tree.get_shelf_manager()
82
62
        self.auto = auto
83
63
        self.auto_apply = auto_apply
84
64
        self.file_list = file_list
85
65
        self.message = message
86
66
        self.destroy = destroy
87
 
        if reporter is None:
88
 
            reporter = ShelfReporter()
89
 
        self.reporter = reporter
90
67
 
91
68
    @classmethod
92
69
    def from_args(klass, diff_writer, revision=None, all=False, file_list=None,
150
127
                        creator.shelve_modify_target(change[1])
151
128
                        changes_shelved += 1
152
129
            if changes_shelved > 0:
153
 
                self.reporter.selected_changes(creator.work_transform)
 
130
                trace.note("Selected changes:")
 
131
                changes = creator.work_transform.iter_changes()
 
132
                reporter = delta._ChangeReporter()
 
133
                delta.report_changes(changes, reporter)
154
134
                if (self.auto_apply or self.prompt_bool(
155
135
                    'Shelve %d change(s)?' % changes_shelved)):
156
136
                    if self.destroy:
159
139
                    else:
160
140
                        shelf_id = self.manager.shelve_changes(creator,
161
141
                                                               self.message)
162
 
                        self.reporter.shelved_id(shelf_id)
 
142
                        trace.note('Changes shelved with id "%d".' % shelf_id)
163
143
            else:
164
 
                self.reporter.no_changes()
 
144
                trace.warning('No changes to shelve.')
165
145
        finally:
166
146
            shutil.rmtree(self.tempdir)
167
147
            creator.finalize()