~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Vincent Ladeuil
  • Date: 2012-02-14 17:22:37 UTC
  • mfrom: (6466 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6468.
  • Revision ID: v.ladeuil+lp@free.fr-20120214172237-7dv7er3n4uy8d5m4
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import time
23
23
 
24
24
from bzrlib import (
 
25
    config as _mod_config,
25
26
    errors,
26
27
    lazy_import,
27
28
    registry,
47
48
""")
48
49
from bzrlib.errors import (DuplicateKey, MalformedTransform,
49
50
                           ReusingTransform, CantMoveRoot,
50
 
                           ExistingLimbo, ImmortalLimbo, NoFinalPath,
 
51
                           ImmortalLimbo, NoFinalPath,
51
52
                           UnableCreateSymlink)
52
53
from bzrlib.filters import filtered_output_bytes, ContentFilterContext
 
54
from bzrlib.mutabletree import MutableTree
53
55
from bzrlib.osutils import (
54
56
    delete_any,
55
57
    file_kind,
57
59
    pathjoin,
58
60
    sha_file,
59
61
    splitpath,
60
 
    supports_executable,
61
62
    )
62
63
from bzrlib.progress import ProgressPhase
63
64
from bzrlib.symbol_versioning import (
156
157
        """
157
158
        if self._tree is None:
158
159
            return
 
160
        for hook in MutableTree.hooks['post_transform']:
 
161
            hook(self._tree, self)
159
162
        self._tree.unlock()
160
163
        self._tree = None
161
164
 
230
233
        irrelevant.
231
234
 
232
235
        """
233
 
        new_roots = [k for k, v in self._new_parent.iteritems() if v is
 
236
        new_roots = [k for k, v in self._new_parent.iteritems() if v ==
234
237
                     ROOT_PARENT]
235
238
        if len(new_roots) < 1:
236
239
            return
626
629
        for trans_id in self._new_parent:
627
630
            seen = set()
628
631
            parent_id = trans_id
629
 
            while parent_id is not ROOT_PARENT:
 
632
            while parent_id != ROOT_PARENT:
630
633
                seen.add(parent_id)
631
634
                try:
632
635
                    parent_id = self.final_parent(parent_id)
642
645
        """If parent directories are versioned, children must be versioned."""
643
646
        conflicts = []
644
647
        for parent_id, children in by_parent.iteritems():
645
 
            if parent_id is ROOT_PARENT:
 
648
            if parent_id == ROOT_PARENT:
646
649
                continue
647
650
            if self.final_file_id(parent_id) is not None:
648
651
                continue
741
744
        """Children must have a directory parent"""
742
745
        conflicts = []
743
746
        for parent_id, children in by_parent.iteritems():
744
 
            if parent_id is ROOT_PARENT:
 
747
            if parent_id == ROOT_PARENT:
745
748
                continue
746
749
            no_children = True
747
750
            for child_id in children:
1403
1406
        delete_any(self._limbo_name(trans_id))
1404
1407
 
1405
1408
    def new_orphan(self, trans_id, parent_id):
1406
 
        # FIXME: There is no tree config, so we use the branch one (it's weird
1407
 
        # to define it this way as orphaning can only occur in a working tree,
1408
 
        # but that's all we have (for now). It will find the option in
1409
 
        # locations.conf or bazaar.conf though) -- vila 20100916
1410
 
        conf = self._tree.branch.get_config()
1411
 
        conf_var_name = 'bzr.transform.orphan_policy'
1412
 
        orphan_policy = conf.get_user_option(conf_var_name)
1413
 
        default_policy = orphaning_registry.default_key
1414
 
        if orphan_policy is None:
1415
 
            orphan_policy = default_policy
1416
 
        if orphan_policy not in orphaning_registry:
1417
 
            trace.warning('%s (from %s) is not a known policy, defaulting '
1418
 
                'to %s' % (orphan_policy, conf_var_name, default_policy))
1419
 
            orphan_policy = default_policy
1420
 
        handle_orphan = orphaning_registry.get(orphan_policy)
 
1409
        conf = self._tree.get_config_stack()
 
1410
        handle_orphan = conf.get('bzr.transform.orphan_policy')
1421
1411
        handle_orphan(self, trans_id, parent_id)
1422
1412
 
1423
1413
 
1486
1476
orphaning_registry._set_default_key('conflict')
1487
1477
 
1488
1478
 
 
1479
opt_transform_orphan = _mod_config.RegistryOption(
 
1480
    'bzr.transform.orphan_policy', orphaning_registry,
 
1481
    help='Policy for orphaned files during transform operations.',
 
1482
    invalid='warning')
 
1483
 
 
1484
 
1489
1485
class TreeTransform(DiskTreeTransform):
1490
1486
    """Represent a tree transformation.
1491
1487
 
1722
1718
            calculating one.
1723
1719
        :param _mover: Supply an alternate FileMover, for testing
1724
1720
        """
 
1721
        for hook in MutableTree.hooks['pre_transform']:
 
1722
            hook(self._tree, self)
1725
1723
        if not no_conflicts:
1726
1724
            self._check_malformed()
1727
1725
        child_pb = ui.ui_factory.nested_progress_bar()
2058
2056
        pass
2059
2057
 
2060
2058
    @property
 
2059
    @deprecated_method(deprecated_in((2, 5, 0)))
2061
2060
    def inventory(self):
2062
2061
        """This Tree does not use inventory as its backing data."""
2063
2062
        raise NotImplementedError(_PreviewTree.inventory)
2064
2063
 
 
2064
    @property
 
2065
    def root_inventory(self):
 
2066
        """This Tree does not use inventory as its backing data."""
 
2067
        raise NotImplementedError(_PreviewTree.root_inventory)
 
2068
 
2065
2069
    def get_root_id(self):
2066
2070
        return self._transform.final_file_id(self._transform.root)
2067
2071