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

  • Committer: Jelmer Vernooij
  • Date: 2019-08-11 13:21:03 UTC
  • mfrom: (7379 work)
  • mto: This revision was merged to the branch mainline in revision 7388.
  • Revision ID: jelmer@jelmer.uk-20190811132103-u3ne03yf37c1h57n
merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
from breezy import (
34
34
    annotate,
35
35
    bencode,
 
36
    cleanup,
36
37
    controldir,
37
38
    commit,
38
39
    conflicts,
455
456
            return None
456
457
        # the file is old; the old id is still valid
457
458
        if self._new_root == trans_id:
458
 
            return self._tree.get_root_id()
 
459
            return self._tree.path2id('')
459
460
        return self._tree.path2id(path)
460
461
 
461
462
    def final_file_id(self, trans_id):
1823
1824
                    child_pb.update(gettext('removing file'),
1824
1825
                                    num, total_entries)
1825
1826
                if trans_id == self._new_root:
1826
 
                    file_id = self._tree.get_root_id()
 
1827
                    file_id = self._tree.path2id('')
1827
1828
                else:
1828
1829
                    file_id = self.tree_file_id(trans_id)
1829
1830
                # File-id isn't really being deleted, just moved
2102
2103
        """This Tree does not use inventory as its backing data."""
2103
2104
        raise NotImplementedError(_PreviewTree.root_inventory)
2104
2105
 
2105
 
    def get_root_id(self):
2106
 
        return self._transform.final_file_id(self._transform.root)
2107
 
 
2108
2106
    def all_file_ids(self):
2109
2107
        tree_ids = set(self._transform._tree.all_file_ids())
2110
2108
        tree_ids.difference_update(self._transform.tree_file_id(t)
2288
2286
        else:
2289
2287
            if from_dir is None and include_root is True:
2290
2288
                root_entry = inventory.make_entry(
2291
 
                    'directory', '', ROOT_PARENT, self.get_root_id())
 
2289
                    'directory', '', ROOT_PARENT, self.path2id(''))
2292
2290
                yield '', 'V', 'directory', root_entry
2293
2291
            entries = self._iter_entries_for_dir(from_dir or '')
2294
2292
            for path, entry in entries:
2601
2599
    :param delta_from_tree: If true, build_tree may use the input Tree to
2602
2600
        generate the inventory delta.
2603
2601
    """
2604
 
    with wt.lock_tree_write(), tree.lock_read():
 
2602
    with cleanup.ExitStack() as exit_stack:
 
2603
        exit_stack.enter_context(wt.lock_tree_write())
 
2604
        exit_stack.enter_context(tree.lock_read())
2605
2605
        if accelerator_tree is not None:
2606
 
            accelerator_tree.lock_read()
2607
 
        try:
2608
 
            return _build_tree(tree, wt, accelerator_tree, hardlink,
2609
 
                               delta_from_tree)
2610
 
        finally:
2611
 
            if accelerator_tree is not None:
2612
 
                accelerator_tree.unlock()
 
2606
            exit_stack.enter_context(accelerator_tree.lock_read())
 
2607
        return _build_tree(tree, wt, accelerator_tree, hardlink,
 
2608
                           delta_from_tree)
2613
2609
 
2614
2610
 
2615
2611
def _build_tree(tree, wt, accelerator_tree, hardlink, delta_from_tree):
2620
2616
    file_trans_id = {}
2621
2617
    top_pb = ui.ui_factory.nested_progress_bar()
2622
2618
    pp = ProgressPhase("Build phase", 2, top_pb)
2623
 
    if tree.get_root_id() is not None:
 
2619
    if tree.path2id('') is not None:
2624
2620
        # This is kind of a hack: we should be altering the root
2625
2621
        # as part of the regular tree shape diff logic.
2626
2622
        # The conditional test here is to avoid doing an
2628
2624
        # is set within the tree, nor setting the root and thus
2629
2625
        # marking the tree as dirty, because we use two different
2630
2626
        # idioms here: tree interfaces and inventory interfaces.
2631
 
        if wt.get_root_id() != tree.get_root_id():
2632
 
            wt.set_root_id(tree.get_root_id())
 
2627
        if wt.path2id('') != tree.path2id(''):
 
2628
            wt.set_root_id(tree.path2id(''))
2633
2629
            wt.flush()
2634
2630
    tt = wt.get_transform()
2635
2631
    divert = set()
2636
2632
    try:
2637
2633
        pp.next_phase()
2638
 
        file_trans_id[wt.get_root_id()] = tt.trans_id_tree_path('')
 
2634
        file_trans_id[wt.path2id('')] = tt.trans_id_tree_path('')
2639
2635
        with ui.ui_factory.nested_progress_bar() as pb:
2640
2636
            deferred_contents = []
2641
2637
            num = 0