~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/shelf_ui.py

  • Committer: Martin Pool
  • Date: 2010-01-15 04:17:57 UTC
  • mto: This revision was merged to the branch mainline in revision 5019.
  • Revision ID: mbp@sourcefrog.net-20100115041757-cd8pu9o5a511jc8q
Rip out most remaining uses of DummyProgressBar

Show diffs side-by-side

added added

removed removed

Lines of Context:
154
154
 
155
155
    @classmethod
156
156
    def from_args(klass, diff_writer, revision=None, all=False, file_list=None,
157
 
                  message=None, directory=None, destroy=False):
 
157
                  message=None, directory='.', destroy=False):
158
158
        """Create a shelver from commandline arguments.
159
159
 
160
160
        The returned shelver wil have a work_tree that is locked and should
168
168
        :param destroy: Change the working tree without storing the shelved
169
169
            changes.
170
170
        """
171
 
        if directory is None:
172
 
            directory = u'.'
173
 
        elif file_list:
174
 
            file_list = [osutils.pathjoin(directory, f) for f in file_list]
175
171
        tree, path = workingtree.WorkingTree.open_containing(directory)
176
172
        # Ensure that tree is locked for the lifetime of target_tree, as
177
173
        # target tree may be reading from the same dirstate.
179
175
        try:
180
176
            target_tree = builtins._get_one_revision_tree('shelf2', revision,
181
177
                tree.branch, tree)
182
 
            files = tree.safe_relpath_files(file_list)
 
178
            files = builtins.safe_relpath_files(tree, file_list)
183
179
            return klass(tree, target_tree, diff_writer, all, all, files,
184
180
                         message, destroy)
185
181
        finally:
245
241
            new_tree = self.work_tree
246
242
        old_path = old_tree.id2path(file_id)
247
243
        new_path = new_tree.id2path(file_id)
248
 
        text_differ = diff.DiffText(old_tree, new_tree, diff_file,
249
 
            path_encoding=osutils.get_terminal_encoding())
 
244
        text_differ = diff.DiffText(old_tree, new_tree, diff_file)
250
245
        patch = text_differ.diff(file_id, old_path, new_path, 'file', 'file')
251
246
        diff_file.seek(0)
252
247
        return patches.parse_patch(diff_file)
476
471
                if unshelver.message is not None:
477
472
                    trace.note('Message: %s' % unshelver.message)
478
473
                change_reporter = delta._ChangeReporter()
479
 
                merger = unshelver.make_merger(None)
480
 
                merger.change_reporter = change_reporter
481
 
                if self.apply_changes:
482
 
                    merger.do_merge()
483
 
                elif self.show_diff:
484
 
                    self.write_diff(merger)
485
 
                else:
486
 
                    self.show_changes(merger)
 
474
                task = ui.ui_factory.nested_progress_bar()
 
475
                try:
 
476
                    merger = unshelver.make_merger(task)
 
477
                    merger.change_reporter = change_reporter
 
478
                    if self.apply_changes:
 
479
                        merger.do_merge()
 
480
                    elif self.show_diff:
 
481
                        self.write_diff(merger)
 
482
                    else:
 
483
                        self.show_changes(merger)
 
484
                finally:
 
485
                    task.finished()
487
486
            if self.delete_shelf:
488
487
                self.manager.delete_shelf(self.shelf_id)
489
488
                trace.note('Deleted changes with id "%d".' % self.shelf_id)
497
496
        tt = tree_merger.make_preview_transform()
498
497
        new_tree = tt.get_preview_tree()
499
498
        if self.write_diff_to is None:
500
 
            self.write_diff_to = ui.ui_factory.make_output_stream(encoding_type='exact')
501
 
        path_encoding = osutils.get_diff_header_encoding()
502
 
        diff.show_diff_trees(merger.this_tree, new_tree, self.write_diff_to,
503
 
            path_encoding=path_encoding)
 
499
            self.write_diff_to = ui.ui_factory.make_output_stream()
 
500
        diff.show_diff_trees(merger.this_tree, new_tree, self.write_diff_to)
504
501
        tt.finalize()
505
502
 
506
503
    def show_changes(self, merger):