89
89
* create_file or create_directory or create_symlink
91
91
* set_executability
93
Transform/Transaction ids
94
-------------------------
95
trans_ids are temporary ids assigned to all files involved in a transform.
96
It's possible, even common, that not all files in the Tree have trans_ids.
98
trans_ids are used because filenames and file_ids are not good enough
99
identifiers; filenames change, and not all files have file_ids. File-ids
100
are also associated with trans-ids, so that moving a file moves its
103
trans_ids are only valid for the TreeTransform that generated them.
107
Limbo is a temporary directory use to hold new versions of files.
108
Files are added to limbo by new_file, new_directory, new_symlink, and their
109
convenience variants (create_*). Files may be removed from limbo using
110
cancel_creation. Files are renamed from limbo into their final location as
111
part of TreeTransform.apply
113
Limbo must be cleaned up, by either calling TreeTransform.apply or
114
calling TreeTransform.finalize.
116
Files are placed into limbo inside their parent directories, where
117
possible. This reduces subsequent renames, and makes operations involving
118
lots of files faster. This is only possible if the parent directory
119
is created *before* creating any of its children.
123
This temporary directory is used by _FileMover for storing files that are
124
about to be deleted. FileMover does not delete files until it is
125
sure that a rollback will not happen. In case of rollback, the files
93
128
def __init__(self, tree, pb=DummyProgress()):
94
129
"""Note: a tree_write lock is taken on the tree.
120
155
self._tree.unlock()
158
# counter used to generate trans-ids (which are locally unique)
123
159
self._id_number = 0
160
# mapping of trans_id -> new basename
124
161
self._new_name = {}
162
# mapping of trans_id -> new parent trans_id
125
163
self._new_parent = {}
164
# mapping of trans_id with new contents -> new file_kind
126
165
self._new_contents = {}
127
166
# A mapping of transform ids to their limbo filename
128
167
self._limbo_files = {}
133
172
self._limbo_children_names = {}
134
173
# List of transform ids that need to be renamed from limbo into place
135
174
self._needs_rename = set()
175
# Set of trans_ids whose contents will be removed
136
176
self._removed_contents = set()
177
# Mapping of trans_id -> new execute-bit value
137
178
self._new_executability = {}
179
# Mapping of trans_id -> new tree-reference value
138
180
self._new_reference_revision = {}
181
# Mapping of trans_id -> new file_id
139
182
self._new_id = {}
183
# Mapping of old file-id -> trans_id
140
184
self._non_present_ids = {}
185
# Mapping of new file_id -> trans_id
141
186
self._r_new_id = {}
187
# Set of file_ids that will be removed
142
188
self._removed_id = set()
189
# Mapping of path in old tree -> trans_id
143
190
self._tree_path_ids = {}
191
# Mapping trans_id -> path in old tree
144
192
self._tree_id_paths = {}
145
193
# Cache of realpath results, to speed up canonical_path
146
194
self._realpaths = {}
147
195
# Cache of relpath results, to speed up canonical_path
148
196
self._relpaths = {}
197
# The trans_id that will be used as the tree root
149
198
self._new_root = self.trans_id_tree_file_id(tree.get_root_id())
199
# Indictor of whether the transform has been applied
150
200
self.__done = False
203
# A counter of how many files have been renamed
152
204
self.rename_count = 0
154
206
def __get_root(self):