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

  • Committer: Gustav Hartvigsson
  • Date: 2021-01-09 21:36:27 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20210109213627-h1xwcutzy9m7a99b
Added 'Case Preserving Working Tree Use Cases' from Canonical Wiki

* Addod a page from the Canonical Bazaar wiki
  with information on the scmeatics of case
  perserving filesystems an a case insensitive
  filesystem works.
  
  * Needs re-work, but this will do as it is the
    same inforamoton as what was on the linked
    page in the currint documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
from __future__ import absolute_import
18
 
 
 
17
import contextlib
 
18
import patiencediff
19
19
import shutil
20
20
import sys
21
21
import tempfile
29
29
    errors,
30
30
    osutils,
31
31
    patches,
32
 
    patiencediff,
33
32
    shelf,
34
33
    textfile,
35
34
    trace,
178
177
        tree, path = workingtree.WorkingTree.open_containing(directory)
179
178
        # Ensure that tree is locked for the lifetime of target_tree, as
180
179
        # target tree may be reading from the same dirstate.
181
 
        tree.lock_tree_write()
182
 
        try:
 
180
        with tree.lock_tree_write():
183
181
            target_tree = builtins._get_one_revision_tree('shelf2', revision,
184
182
                                                          tree.branch, tree)
185
183
            files = tree.safe_relpath_files(file_list)
186
184
            return klass(tree, target_tree, diff_writer, all, all, files,
187
185
                         message, destroy)
188
 
        finally:
189
 
            tree.unlock()
190
186
 
191
187
    def run(self):
192
188
        """Interactively shelve the changes."""
250
246
        path_encoding = osutils.get_terminal_encoding()
251
247
        text_differ = diff.DiffText(old_tree, new_tree, diff_file,
252
248
                                    path_encoding=path_encoding)
253
 
        patch = text_differ.diff(file_id, old_path, new_path, 'file', 'file')
 
249
        patch = text_differ.diff(old_path, new_path, 'file', 'file')
254
250
        diff_file.seek(0)
255
251
        return patches.parse_patch(diff_file)
256
252
 
365
361
        """
366
362
        lines = osutils.split_lines(self.change_editor.edit_file(
367
363
            self.change_editor.old_tree.id2path(file_id),
368
 
            self.change_editor.new_tree.id2path(file_id),
369
 
            file_id=file_id))
 
364
            self.change_editor.new_tree.id2path(file_id)))
370
365
        return lines, self._count_changed_regions(work_tree_lines, lines)
371
366
 
372
367
    @staticmethod
406
401
            else:
407
402
                shelf_id = manager.last_shelf()
408
403
                if shelf_id is None:
409
 
                    raise errors.BzrCommandError(
 
404
                    raise errors.CommandError(
410
405
                        gettext('No changes are shelved.'))
411
406
            apply_changes = True
412
407
            delete_shelf = True
461
456
 
462
457
    def run(self):
463
458
        """Perform the unshelving operation."""
464
 
        self.tree.lock_tree_write()
465
 
        cleanups = [self.tree.unlock]
466
 
        try:
 
459
        with contextlib.ExitStack() as exit_stack:
 
460
            exit_stack.enter_context(self.tree.lock_tree_write())
467
461
            if self.read_shelf:
468
462
                trace.note(gettext('Using changes with id "%d".') %
469
463
                           self.shelf_id)
470
464
                unshelver = self.manager.get_unshelver(self.shelf_id)
471
 
                cleanups.append(unshelver.finalize)
 
465
                exit_stack.callback(unshelver.finalize)
472
466
                if unshelver.message is not None:
473
467
                    trace.note(gettext('Message: %s') % unshelver.message)
474
468
                change_reporter = delta._ChangeReporter()
484
478
                self.manager.delete_shelf(self.shelf_id)
485
479
                trace.note(gettext('Deleted changes with id "%d".') %
486
480
                           self.shelf_id)
487
 
        finally:
488
 
            for cleanup in reversed(cleanups):
489
 
                cleanup()
490
481
 
491
482
    def write_diff(self, merger):
492
483
        """Write this operation's diff to self.write_diff_to."""