~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Aaron Bentley
  • Date: 2007-06-03 16:33:08 UTC
  • mto: (2502.1.10 fast-checkout)
  • mto: This revision was merged to the branch mainline in revision 2507.
  • Revision ID: aaron.bentley@utoronto.ca-20070603163308-r6el1wy9cvj9h6h2
Cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
 
52
52
 
53
53
class _TransformResults(object):
54
 
    def __init__(self, modified_paths):
 
54
    def __init__(self, modified_paths, rename_count):
55
55
        object.__init__(self)
56
56
        self.modified_paths = modified_paths
 
57
        self.rename_count = rename_count
57
58
 
58
59
 
59
60
class TreeTransform(object):
60
61
    """Represent a tree transformation.
61
62
    
62
63
    This object is designed to support incremental generation of the transform,
63
 
    in any order.  
 
64
    in any order.
 
65
 
 
66
    However, it gives optimum performance when parent directories are created
 
67
    before their contents.  The transform is then able to put child files
 
68
    directly in their parent directory, avoiding later renames.
64
69
    
65
70
    It is easy to produce malformed transforms, but they are generally
66
71
    harmless.  Attempting to apply a malformed transform will cause an
106
111
        self._new_name = {}
107
112
        self._new_parent = {}
108
113
        self._new_contents = {}
 
114
        # A mapping of transform ids to their limbo filename
109
115
        self._limbo_files = {}
 
116
        # A mapping of transform ids to a set of the transform ids of children
 
117
        # their limbo directory has
110
118
        self._limbo_children = {}
 
119
        # Map transform ids to maps of child filename to child transform id
111
120
        self._limbo_children_names = {}
 
121
        # List of transform ids that need to be renamed from limbo into place
112
122
        self._needs_rename = set()
113
123
        self._removed_contents = set()
114
124
        self._new_executability = {}
119
129
        self._removed_id = set()
120
130
        self._tree_path_ids = {}
121
131
        self._tree_id_paths = {}
 
132
        # Cache of realpath results, to speed up canonical_path
122
133
        self._realpaths = {}
123
 
        # Cache of realpath results, to speed up canonical_path
 
134
        # Cache of relpath results, to speed up canonical_path
124
135
        self._relpaths = {}
125
 
        # Cache of relpath results, to speed up canonical_path
126
136
        self._new_root = self.trans_id_tree_file_id(tree.get_root_id())
127
137
        self.__done = False
128
138
        self._pb = pb
783
793
        self._tree.apply_inventory_delta(inventory_delta)
784
794
        self.__done = True
785
795
        self.finalize()
786
 
        return _TransformResults(modified_paths)
 
796
        return _TransformResults(modified_paths, self.rename_count)
787
797
 
788
798
    def _limbo_name(self, trans_id, from_scratch=False):
789
799
        """Generate the limbo name of a file"""
1281
1291
            wt.add_conflicts(conflicts)
1282
1292
        except errors.UnsupportedOperation:
1283
1293
            pass
1284
 
        tt.apply()
 
1294
        result = tt.apply()
1285
1295
    finally:
1286
1296
        tt.finalize()
1287
1297
        top_pb.finished()
1288
 
    return tt
 
1298
    return result
1289
1299
 
1290
1300
 
1291
1301
def _reparent_children(tt, old_parent, new_parent):