/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/shelf_ui.py

merge bzr.dev r4164

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
    """Interactively shelve the changes in a working tree."""
40
40
 
41
41
    def __init__(self, work_tree, target_tree, diff_writer=None, auto=False,
42
 
                 auto_apply=False, file_list=None, message=None):
 
42
                 auto_apply=False, file_list=None, message=None,
 
43
                 destroy=False):
43
44
        """Constructor.
44
45
 
45
46
        :param work_tree: The working tree to shelve changes from.
49
50
        :param auto_apply: If True, shelve changes with no final prompt.
50
51
        :param file_list: If supplied, only files in this list may be shelved.
51
52
        :param message: The message to associate with the shelved changes.
 
53
        :param destroy: Change the working tree without storing the shelved
 
54
            changes.
52
55
        """
53
56
        self.work_tree = work_tree
54
57
        self.target_tree = target_tree
60
63
        self.auto_apply = auto_apply
61
64
        self.file_list = file_list
62
65
        self.message = message
 
66
        self.destroy = destroy
63
67
 
64
68
    @classmethod
65
69
    def from_args(klass, diff_writer, revision=None, all=False, file_list=None,
66
 
                  message=None, directory='.'):
 
70
                  message=None, directory='.', destroy=False):
67
71
        """Create a shelver from commandline arguments.
68
72
 
69
73
        :param revision: RevisionSpec of the revision to compare to.
71
75
        :param file_list: If supplied, only files in this list may be  shelved.
72
76
        :param message: The message to associate with the shelved changes.
73
77
        :param directory: The directory containing the working tree.
 
78
        :param destroy: Change the working tree without storing the shelved
 
79
            changes.
74
80
        """
75
81
        tree, path = workingtree.WorkingTree.open_containing(directory)
76
82
        target_tree = builtins._get_one_revision_tree('shelf2', revision,
77
83
            tree.branch, tree)
78
84
        files = builtins.safe_relpath_files(tree, file_list)
79
 
        return klass(tree, target_tree, diff_writer, all, all, files, message)
 
85
        return klass(tree, target_tree, diff_writer, all, all, files, message,
 
86
                     destroy)
80
87
 
81
88
    def run(self):
82
89
        """Interactively shelve the changes."""
114
121
                                   change[2:]):
115
122
                        creator.shelve_rename(change[1])
116
123
                        changes_shelved += 1
 
124
                if change[0] == 'modify target':
 
125
                    if self.prompt_bool('Shelve changing target of "%s" '
 
126
                            'from "%s" to "%s"?' % change[2:]):
 
127
                        creator.shelve_modify_target(change[1])
 
128
                        changes_shelved += 1
117
129
            if changes_shelved > 0:
118
130
                trace.note("Selected changes:")
119
131
                changes = creator.work_transform.iter_changes()
121
133
                delta.report_changes(changes, reporter)
122
134
                if (self.auto_apply or self.prompt_bool(
123
135
                    'Shelve %d change(s)?' % changes_shelved)):
124
 
                    shelf_id = self.manager.shelve_changes(creator,
125
 
                                                           self.message)
126
 
                    trace.note('Changes shelved with id "%d".' % shelf_id)
 
136
                    if self.destroy:
 
137
                        creator.transform()
 
138
                        trace.note('Selected changes destroyed.')
 
139
                    else:
 
140
                        shelf_id = self.manager.shelve_changes(creator,
 
141
                                                               self.message)
 
142
                        trace.note('Changes shelved with id "%d".' % shelf_id)
127
143
            else:
128
144
                trace.warning('No changes to shelve.')
129
145
        finally: