Merge lp:~jelmer/brz/git-drop-roundtrip into lp:brz
- git-drop-roundtrip
- Merge into trunk
Proposed by
Jelmer Vernooij
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Jelmer Vernooij | ||||
Approved revision: | no longer in the source branch. | ||||
Merge reported by: | The Breezy Bot | ||||
Merged at revision: | not available | ||||
Proposed branch: | lp:~jelmer/brz/git-drop-roundtrip | ||||
Merge into: | lp:brz | ||||
Diff against target: |
606 lines (+32/-230) 10 files modified
breezy/git/commit.py (+2/-28) breezy/git/fetch.py (+1/-2) breezy/git/mapping.py (+2/-86) breezy/git/memorytree.py (+0/-5) breezy/git/object_store.py (+0/-23) breezy/git/roundtrip.py (+0/-27) breezy/git/tests/test_roundtrip.py (+0/-13) breezy/git/tests/test_workingtree.py (+3/-8) breezy/git/tree.py (+19/-28) breezy/git/workingtree.py (+5/-10) |
||||
To merge this branch: | bzr merge lp:~jelmer/brz/git-drop-roundtrip | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Martin Packman | Approve | ||
Review via email: mp+369478@code.launchpad.net |
Commit message
Drop file id roundtripping support in Git.
Description of the change
Drop file id roundtripping support in Git.
File ids will soon be an implementation detail of the Bazaar format. Stashing
file ids somewhere in Git repositories is fraught with issues.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'breezy/git/commit.py' |
2 | --- breezy/git/commit.py 2019-06-15 17:53:40 +0000 |
3 | +++ breezy/git/commit.py 2019-06-29 16:01:34 +0000 |
4 | @@ -145,8 +145,6 @@ |
5 | yield change.path[1], (entry.text_sha1, st) |
6 | if self._mapping.generate_file_id(encoded_new_path) != change.file_id: |
7 | self._override_fileids[encoded_new_path] = change.file_id |
8 | - else: |
9 | - self._override_fileids[encoded_new_path] = None |
10 | if not seen_root and len(self.parents) == 0: |
11 | raise RootMissing() |
12 | if getattr(workingtree, "basis_tree", False): |
13 | @@ -163,32 +161,8 @@ |
14 | continue |
15 | self._blobs[entry.path] = (entry.mode, entry.sha) |
16 | if not self._lossy: |
17 | - try: |
18 | - fileid_map = dict(basis_tree._fileid_map.file_ids) |
19 | - except AttributeError: |
20 | - fileid_map = {} |
21 | - for path, file_id in viewitems(self._override_fileids): |
22 | - if not isinstance(path, bytes): |
23 | - raise TypeError(path) |
24 | - if file_id is None: |
25 | - if path in fileid_map: |
26 | - del fileid_map[path] |
27 | - else: |
28 | - if not isinstance(file_id, bytes): |
29 | - raise TypeError(file_id) |
30 | - fileid_map[path] = file_id |
31 | - if fileid_map: |
32 | - fileid_blob = self._mapping.export_fileid_map(fileid_map) |
33 | - else: |
34 | - fileid_blob = None |
35 | - if fileid_blob is not None: |
36 | - if self._mapping.BZR_FILE_IDS_FILE is None: |
37 | - raise SettingCustomFileIdsUnsupported(fileid_map) |
38 | - self.store.add_object(fileid_blob) |
39 | - self._blobs[self._mapping.BZR_FILE_IDS_FILE] = ( |
40 | - stat.S_IFREG | 0o644, fileid_blob.id) |
41 | - else: |
42 | - self._blobs[self._mapping.BZR_FILE_IDS_FILE] = None |
43 | + if self._override_fileids: |
44 | + raise SettingCustomFileIdsUnsupported(self._override_fileids) |
45 | self.new_inventory = None |
46 | |
47 | def update_basis(self, tree): |
48 | |
49 | === modified file 'breezy/git/fetch.py' |
50 | --- breezy/git/fetch.py 2018-11-29 23:42:41 +0000 |
51 | +++ breezy/git/fetch.py 2019-06-29 16:01:34 +0000 |
52 | @@ -402,12 +402,11 @@ |
53 | base_tree = lookup_object(o.parents[0]).tree |
54 | base_mode = stat.S_IFDIR |
55 | store_updater = target_git_object_retriever._get_updater(rev) |
56 | - tree_supplement = mapping.get_fileid_map(lookup_object, o.tree) |
57 | inv_delta, unusual_modes = import_git_tree( |
58 | repo.texts, mapping, b"", b"", (base_tree, o.tree), base_bzr_tree, |
59 | None, rev.revision_id, parent_trees, lookup_object, |
60 | (base_mode, stat.S_IFDIR), store_updater, |
61 | - tree_supplement.lookup_file_id, |
62 | + mapping.generate_file_id, |
63 | allow_submodules=repo._format.supports_tree_reference) |
64 | if unusual_modes != {}: |
65 | for path, mode in unusual_modes.iteritems(): |
66 | |
67 | === modified file 'breezy/git/mapping.py' |
68 | --- breezy/git/mapping.py 2019-06-02 05:34:26 +0000 |
69 | +++ breezy/git/mapping.py 2019-06-29 16:01:34 +0000 |
70 | @@ -57,8 +57,6 @@ |
71 | extract_bzr_metadata, |
72 | inject_bzr_metadata, |
73 | CommitSupplement, |
74 | - deserialize_fileid_map, |
75 | - serialize_fileid_map, |
76 | ) |
77 | |
78 | |
79 | @@ -131,12 +129,10 @@ |
80 | """Class that maps between Git and Bazaar semantics.""" |
81 | experimental = False |
82 | |
83 | - BZR_FILE_IDS_FILE = None |
84 | - |
85 | BZR_DUMMY_FILE = None |
86 | |
87 | def is_special_file(self, filename): |
88 | - return (filename in (self.BZR_FILE_IDS_FILE, self.BZR_DUMMY_FILE)) |
89 | + return (filename in (self.BZR_DUMMY_FILE, )) |
90 | |
91 | def __init__(self): |
92 | super(BzrGitMapping, self).__init__(foreign_vcs_git) |
93 | @@ -257,17 +253,6 @@ |
94 | def _encode_commit_message(self, rev, message, encoding): |
95 | return message.encode(encoding) |
96 | |
97 | - def export_fileid_map(self, fileid_map): |
98 | - """Export a file id map to a fileid map. |
99 | - |
100 | - :param fileid_map: File id map, mapping paths to file ids |
101 | - :return: A Git blob object (or None if there are no entries) |
102 | - """ |
103 | - from dulwich.objects import Blob |
104 | - b = Blob() |
105 | - b.set_raw_chunks(serialize_fileid_map(fileid_map)) |
106 | - return b |
107 | - |
108 | def export_commit(self, rev, tree_sha, parent_lookup, lossy, |
109 | verifiers): |
110 | """Turn a Bazaar revision in to a Git commit |
111 | @@ -370,14 +355,6 @@ |
112 | for l in rev.properties[u'git-extra'].splitlines()]) |
113 | return commit |
114 | |
115 | - def import_fileid_map(self, blob): |
116 | - """Convert a git file id map blob. |
117 | - |
118 | - :param blob: Git blob object with fileid map |
119 | - :return: Dictionary mapping paths to file ids |
120 | - """ |
121 | - return deserialize_fileid_map(blob.data) |
122 | - |
123 | def get_revision_id(self, commit): |
124 | if commit.encoding: |
125 | encoding = commit.encoding.decode('ascii') |
126 | @@ -480,22 +457,6 @@ |
127 | rev.properties[u'git-extra'] = b''.join(extra_lines) |
128 | return rev, roundtrip_revid, verifiers |
129 | |
130 | - def get_fileid_map(self, lookup_object, tree_sha): |
131 | - """Obtain a fileid map for a particular tree. |
132 | - |
133 | - :param lookup_object: Function for looking up an object |
134 | - :param tree_sha: SHA of the root tree |
135 | - :return: GitFileIdMap instance |
136 | - """ |
137 | - try: |
138 | - file_id_map_sha = lookup_object( |
139 | - tree_sha)[self.BZR_FILE_IDS_FILE][1] |
140 | - except KeyError: |
141 | - file_ids = {} |
142 | - else: |
143 | - file_ids = self.import_fileid_map(lookup_object(file_id_map_sha)) |
144 | - return GitFileIdMap(file_ids, self) |
145 | - |
146 | |
147 | class BzrGitMappingv1(BzrGitMapping): |
148 | revid_prefix = b'git-v1' |
149 | @@ -508,9 +469,7 @@ |
150 | class BzrGitMappingExperimental(BzrGitMappingv1): |
151 | revid_prefix = b'git-experimental' |
152 | experimental = True |
153 | - roundtripping = True |
154 | - |
155 | - BZR_FILE_IDS_FILE = '.bzrfileids' |
156 | + roundtripping = False |
157 | |
158 | BZR_DUMMY_FILE = '.bzrdummy' |
159 | |
160 | @@ -674,49 +633,6 @@ |
161 | return (full_url, int(rev), uuid) |
162 | |
163 | |
164 | -class GitFileIdMap(object): |
165 | - |
166 | - def __init__(self, file_ids, mapping): |
167 | - self.file_ids = file_ids |
168 | - self.paths = None |
169 | - self.mapping = mapping |
170 | - |
171 | - def set_file_id(self, path, file_id): |
172 | - if type(path) is not str: |
173 | - raise TypeError(path) |
174 | - if not isinstance(file_id, bytes): |
175 | - raise TypeError(file_id) |
176 | - self.file_ids[path] = file_id |
177 | - |
178 | - def lookup_file_id(self, path): |
179 | - if not isinstance(path, text_type): |
180 | - raise TypeError(path) |
181 | - try: |
182 | - file_id = self.file_ids[path] |
183 | - except KeyError: |
184 | - file_id = self.mapping.generate_file_id(path) |
185 | - if not isinstance(file_id, bytes): |
186 | - raise TypeError(file_id) |
187 | - return file_id |
188 | - |
189 | - def lookup_path(self, file_id): |
190 | - if self.paths is None: |
191 | - self.paths = {} |
192 | - for k, v in viewitems(self.file_ids): |
193 | - self.paths[v] = k |
194 | - try: |
195 | - path = self.paths[file_id] |
196 | - except KeyError: |
197 | - return self.mapping.parse_file_id(file_id) |
198 | - else: |
199 | - if not isinstance(path, text_type): |
200 | - raise TypeError(path) |
201 | - return path |
202 | - |
203 | - def copy(self): |
204 | - return self.__class__(dict(self.file_ids), self.mapping) |
205 | - |
206 | - |
207 | def needs_roundtripping(repo, revid): |
208 | try: |
209 | mapping_registry.parse_revision_id(revid) |
210 | |
211 | === modified file 'breezy/git/memorytree.py' |
212 | --- breezy/git/memorytree.py 2019-03-04 01:31:43 +0000 |
213 | +++ breezy/git/memorytree.py 2019-06-29 16:01:34 +0000 |
214 | @@ -41,7 +41,6 @@ |
215 | ) |
216 | from breezy.transport.memory import MemoryTransport |
217 | |
218 | -from .mapping import GitFileIdMap |
219 | from .tree import MutableGitIndexTree |
220 | |
221 | |
222 | @@ -89,13 +88,9 @@ |
223 | self._file_transport = MemoryTransport() |
224 | if self.branch.head is None: |
225 | tree = Tree() |
226 | - self._basis_fileid_map = GitFileIdMap({}, self.mapping) |
227 | else: |
228 | tree_id = self.store[self.branch.head].tree |
229 | - self._basis_fileid_map = self.mapping.get_fileid_map( |
230 | - self.store.__getitem__, tree_id) |
231 | tree = self.store[tree_id] |
232 | - self._fileid_map = self._basis_fileid_map.copy() |
233 | |
234 | trees = [("", tree)] |
235 | while trees: |
236 | |
237 | === modified file 'breezy/git/object_store.py' |
238 | --- breezy/git/object_store.py 2019-06-16 16:12:56 +0000 |
239 | +++ breezy/git/object_store.py 2019-06-29 16:01:34 +0000 |
240 | @@ -492,15 +492,6 @@ |
241 | return self.mapping.export_commit(rev, tree_sha, parent_lookup, |
242 | lossy, verifiers) |
243 | |
244 | - def _create_fileid_map_blob(self, tree): |
245 | - # FIXME: This can probably be a lot more efficient, |
246 | - # not all files necessarily have to be processed. |
247 | - file_ids = {} |
248 | - for (path, ie) in tree.iter_entries_by_dir(): |
249 | - if self.mapping.generate_file_id(path) != ie.file_id: |
250 | - file_ids[path] = ie.file_id |
251 | - return self.mapping.export_fileid_map(file_ids) |
252 | - |
253 | def _revision_to_objects(self, rev, tree, lossy, add_cache_entry=None): |
254 | """Convert a revision to a set of git objects. |
255 | |
256 | @@ -530,12 +521,6 @@ |
257 | base_sha1 = self._lookup_revision_sha1(rev.parent_ids[0]) |
258 | root_tree = self[self[base_sha1].tree] |
259 | root_key_data = (tree.get_root_id(), tree.get_revision_id()) |
260 | - if not lossy and self.mapping.BZR_FILE_IDS_FILE is not None: |
261 | - b = self._create_fileid_map_blob(tree) |
262 | - if b is not None: |
263 | - root_tree[self.mapping.BZR_FILE_IDS_FILE] = ( |
264 | - (stat.S_IFREG | 0o644), b.id) |
265 | - yield self.mapping.BZR_FILE_IDS_FILE, b |
266 | if add_cache_entry is not None: |
267 | add_cache_entry(root_tree, root_key_data, "") |
268 | yield "", root_tree |
269 | @@ -632,14 +617,6 @@ |
270 | bzr_tree.iter_child_entries(path), |
271 | get_ie_sha1, unusual_modes, self.mapping.BZR_DUMMY_FILE, |
272 | bzr_tree.get_root_id() == fileid) |
273 | - if (bzr_tree.get_root_id() == fileid and |
274 | - self.mapping.BZR_FILE_IDS_FILE is not None): |
275 | - if tree is None: |
276 | - tree = Tree() |
277 | - b = self._create_fileid_map_blob(bzr_tree) |
278 | - # If this is the root tree, add the file ids |
279 | - tree[self.mapping.BZR_FILE_IDS_FILE] = ( |
280 | - (stat.S_IFREG | 0o644), b.id) |
281 | if tree is not None: |
282 | _check_expected_sha(expected_sha, tree) |
283 | return tree |
284 | |
285 | === modified file 'breezy/git/roundtrip.py' |
286 | --- breezy/git/roundtrip.py 2018-11-11 14:23:06 +0000 |
287 | +++ breezy/git/roundtrip.py 2019-06-29 16:01:34 +0000 |
288 | @@ -147,30 +147,3 @@ |
289 | if not isinstance(rt_data, bytes): |
290 | raise TypeError(rt_data) |
291 | return message + b"\n--BZR--\n" + rt_data |
292 | - |
293 | - |
294 | -def serialize_fileid_map(file_ids): |
295 | - """Serialize a fileid map. |
296 | - |
297 | - :param file_ids: Path -> fileid map |
298 | - :return: Serialized fileid map, as sequence of chunks |
299 | - """ |
300 | - lines = [] |
301 | - for path in sorted(file_ids.keys()): |
302 | - lines.append(b"%s\0%s\n" % (path.encode('utf-8'), file_ids[path])) |
303 | - return lines |
304 | - |
305 | - |
306 | -def deserialize_fileid_map(filetext): |
307 | - """Deserialize a file id map. |
308 | - |
309 | - :param file: File |
310 | - :return: Fileid map (path -> fileid) |
311 | - """ |
312 | - ret = {} |
313 | - f = BytesIO(filetext) |
314 | - lines = f.readlines() |
315 | - for l in lines: |
316 | - (path, file_id) = l.rstrip(b"\n").split(b"\0") |
317 | - ret[path.decode('utf-8')] = file_id |
318 | - return ret |
319 | |
320 | === modified file 'breezy/git/tests/test_roundtrip.py' |
321 | --- breezy/git/tests/test_roundtrip.py 2018-11-11 04:08:32 +0000 |
322 | +++ breezy/git/tests/test_roundtrip.py 2019-06-29 16:01:34 +0000 |
323 | @@ -24,12 +24,10 @@ |
324 | |
325 | from ..roundtrip import ( |
326 | CommitSupplement, |
327 | - deserialize_fileid_map, |
328 | extract_bzr_metadata, |
329 | generate_roundtripping_metadata, |
330 | inject_bzr_metadata, |
331 | parse_roundtripping_metadata, |
332 | - serialize_fileid_map, |
333 | ) |
334 | |
335 | |
336 | @@ -100,14 +98,3 @@ |
337 | metadata = CommitSupplement() |
338 | msg = inject_bzr_metadata(b"Foo", metadata, "utf-8") |
339 | self.assertEqual(b"Foo", msg) |
340 | - |
341 | - |
342 | -class FileIdRoundTripTests(TestCase): |
343 | - |
344 | - def test_deserialize(self): |
345 | - self.assertEqual({"bar/bla": b"fid"}, |
346 | - deserialize_fileid_map(b"bar/bla\0fid\n")) |
347 | - |
348 | - def test_serialize(self): |
349 | - self.assertEqual([b"bar/bla\0fid\n"], |
350 | - serialize_fileid_map({"bar/bla": b"fid"})) |
351 | |
352 | === modified file 'breezy/git/tests/test_workingtree.py' |
353 | --- breezy/git/tests/test_workingtree.py 2019-06-02 05:13:10 +0000 |
354 | +++ breezy/git/tests/test_workingtree.py 2019-06-29 16:01:34 +0000 |
355 | @@ -37,7 +37,6 @@ |
356 | from ...delta import TreeDelta |
357 | from ..mapping import ( |
358 | default_mapping, |
359 | - GitFileIdMap, |
360 | ) |
361 | from ..tree import ( |
362 | changes_between_git_tree_and_working_copy, |
363 | @@ -137,20 +136,16 @@ |
364 | changes = [] |
365 | self.assertEqual( |
366 | delta, |
367 | - tree_delta_from_git_changes(changes, default_mapping, |
368 | - (GitFileIdMap({}, default_mapping), |
369 | - GitFileIdMap({}, default_mapping)))) |
370 | + tree_delta_from_git_changes(changes, (default_mapping, default_mapping))) |
371 | |
372 | def test_missing(self): |
373 | delta = TreeDelta() |
374 | - delta.removed.append(('a', b'a-id', 'file')) |
375 | + delta.removed.append(('a', b'git:a', 'file')) |
376 | changes = [((b'a', b'a'), (stat.S_IFREG | 0o755, 0), |
377 | (b'a' * 40, b'a' * 40))] |
378 | self.assertEqual( |
379 | delta, |
380 | - tree_delta_from_git_changes(changes, default_mapping, |
381 | - (GitFileIdMap({u'a': b'a-id'}, default_mapping), |
382 | - GitFileIdMap({u'a': b'a-id'}, default_mapping)))) |
383 | + tree_delta_from_git_changes(changes, (default_mapping, default_mapping))) |
384 | |
385 | |
386 | class ChangesBetweenGitTreeAndWorkingCopyTests(TestCaseWithTransport): |
387 | |
388 | === modified file 'breezy/git/tree.py' |
389 | --- breezy/git/tree.py 2019-06-21 17:49:36 +0000 |
390 | +++ breezy/git/tree.py 2019-06-29 16:01:34 +0000 |
391 | @@ -67,7 +67,6 @@ |
392 | from .mapping import ( |
393 | mode_is_executable, |
394 | mode_kind, |
395 | - GitFileIdMap, |
396 | default_mapping, |
397 | ) |
398 | |
399 | @@ -261,17 +260,12 @@ |
400 | if revision_id == NULL_REVISION: |
401 | self.tree = None |
402 | self.mapping = default_mapping |
403 | - self._fileid_map = GitFileIdMap( |
404 | - {}, |
405 | - default_mapping) |
406 | else: |
407 | try: |
408 | commit = self.store[self.commit_id] |
409 | except KeyError: |
410 | raise errors.NoSuchRevision(repository, revision_id) |
411 | self.tree = commit.tree |
412 | - self._fileid_map = self.mapping.get_fileid_map( |
413 | - self.store.__getitem__, self.tree) |
414 | |
415 | def _get_nested_repository(self, path): |
416 | nested_repo_transport = self._repository.user_transport.clone(path) |
417 | @@ -304,7 +298,7 @@ |
418 | |
419 | def id2path(self, file_id): |
420 | try: |
421 | - path = self._fileid_map.lookup_path(file_id) |
422 | + path = self.mapping.parse_file_id(file_id) |
423 | except ValueError: |
424 | raise errors.NoSuchId(self, file_id) |
425 | if self.is_versioned(path): |
426 | @@ -319,7 +313,7 @@ |
427 | return None |
428 | if not self.is_versioned(path): |
429 | return None |
430 | - return self._fileid_map.lookup_file_id(osutils.safe_unicode(path)) |
431 | + return self.mapping.generate_file_id(osutils.safe_unicode(path)) |
432 | |
433 | def all_file_ids(self): |
434 | raise errors.UnsupportedOperation(self.all_file_ids, self) |
435 | @@ -401,7 +395,7 @@ |
436 | root_ie = self._get_dir_ie(b"", None) |
437 | else: |
438 | parent_path = posixpath.dirname(from_dir) |
439 | - parent_id = self._fileid_map.lookup_file_id(parent_path) |
440 | + parent_id = self.mapping.generate_file_id(parent_path) |
441 | if mode_kind(mode) == 'directory': |
442 | root_ie = self._get_dir_ie(from_dir.encode("utf-8"), parent_id) |
443 | else: |
444 | @@ -441,7 +435,7 @@ |
445 | kind = mode_kind(mode) |
446 | path = path.decode('utf-8') |
447 | name = name.decode("utf-8") |
448 | - file_id = self._fileid_map.lookup_file_id(path) |
449 | + file_id = self.mapping.generate_file_id(path) |
450 | ie = entry_factory[kind](file_id, name, parent_id) |
451 | if kind == 'symlink': |
452 | ie.symlink_target = store[hexsha].data.decode('utf-8') |
453 | @@ -457,7 +451,7 @@ |
454 | |
455 | def _get_dir_ie(self, path, parent_id): |
456 | path = path.decode('utf-8') |
457 | - file_id = self._fileid_map.lookup_file_id(path) |
458 | + file_id = self.mapping.generate_file_id(path) |
459 | return GitTreeDirectory(file_id, posixpath.basename(path), parent_id) |
460 | |
461 | def iter_child_entries(self, path): |
462 | @@ -666,8 +660,8 @@ |
463 | yield (path_decoded, parent_id), children |
464 | |
465 | |
466 | -def tree_delta_from_git_changes(changes, mapping, |
467 | - fileid_maps, specific_files=None, |
468 | +def tree_delta_from_git_changes(changes, mappings, |
469 | + specific_files=None, |
470 | require_versioned=False, include_root=False, |
471 | target_extras=None): |
472 | """Create a TreeDelta from two git trees. |
473 | @@ -675,7 +669,7 @@ |
474 | source and target are iterators over tuples with: |
475 | (filename, sha, mode) |
476 | """ |
477 | - (old_fileid_map, new_fileid_map) = fileid_maps |
478 | + (old_mapping, new_mapping) = mappings |
479 | if target_extras is None: |
480 | target_extras = set() |
481 | ret = delta.TreeDelta() |
482 | @@ -699,37 +693,37 @@ |
483 | osutils.is_inside_or_parent_of_any( |
484 | specific_files, newpath_decoded))): |
485 | continue |
486 | - if mapping.is_special_file(oldpath): |
487 | + if old_mapping.is_special_file(oldpath): |
488 | oldpath = None |
489 | - if mapping.is_special_file(newpath): |
490 | + if new_mapping.is_special_file(newpath): |
491 | newpath = None |
492 | if oldpath is None and newpath is None: |
493 | continue |
494 | if oldpath is None: |
495 | added.append((newpath, mode_kind(newmode))) |
496 | elif newpath is None or newmode == 0: |
497 | - file_id = old_fileid_map.lookup_file_id(oldpath_decoded) |
498 | + file_id = old_mapping.generate_file_id(oldpath_decoded) |
499 | ret.removed.append((oldpath_decoded, file_id, mode_kind(oldmode))) |
500 | elif oldpath != newpath: |
501 | - file_id = old_fileid_map.lookup_file_id(oldpath_decoded) |
502 | + file_id = old_mapping.generate_file_id(oldpath_decoded) |
503 | ret.renamed.append( |
504 | (oldpath_decoded, newpath.decode('utf-8'), file_id, |
505 | mode_kind(newmode), (oldsha != newsha), |
506 | (oldmode != newmode))) |
507 | elif mode_kind(oldmode) != mode_kind(newmode): |
508 | - file_id = new_fileid_map.lookup_file_id(newpath_decoded) |
509 | + file_id = new_mapping.generate_file_id(newpath_decoded) |
510 | ret.kind_changed.append( |
511 | (newpath_decoded, file_id, mode_kind(oldmode), |
512 | mode_kind(newmode))) |
513 | elif oldsha != newsha or oldmode != newmode: |
514 | if stat.S_ISDIR(oldmode) and stat.S_ISDIR(newmode): |
515 | continue |
516 | - file_id = new_fileid_map.lookup_file_id(newpath_decoded) |
517 | + file_id = new_mapping.generate_file_id(newpath_decoded) |
518 | ret.modified.append( |
519 | (newpath_decoded, file_id, mode_kind(newmode), |
520 | (oldsha != newsha), (oldmode != newmode))) |
521 | else: |
522 | - file_id = new_fileid_map.lookup_file_id(newpath_decoded) |
523 | + file_id = new_mapping.generate_file_id(newpath_decoded) |
524 | ret.unchanged.append( |
525 | (newpath_decoded, file_id, mode_kind(newmode))) |
526 | |
527 | @@ -746,7 +740,7 @@ |
528 | if path in target_extras: |
529 | ret.unversioned.append((path_decoded, None, kind)) |
530 | else: |
531 | - file_id = new_fileid_map.lookup_file_id(path_decoded) |
532 | + file_id = new_mapping.generate_file_id(path_decoded) |
533 | ret.added.append((path_decoded, file_id, kind)) |
534 | |
535 | return ret |
536 | @@ -857,11 +851,8 @@ |
537 | specific_files=specific_files, |
538 | extra_trees=extra_trees, |
539 | want_unversioned=want_unversioned) |
540 | - source_fileid_map = self.source._fileid_map |
541 | - target_fileid_map = self.target._fileid_map |
542 | return tree_delta_from_git_changes( |
543 | - changes, self.target.mapping, |
544 | - (source_fileid_map, target_fileid_map), |
545 | + changes, (self.source.mapping, self.target.mapping), |
546 | specific_files=specific_files, |
547 | include_root=include_root, target_extras=target_extras) |
548 | |
549 | @@ -969,7 +960,7 @@ |
550 | with self.lock_read(): |
551 | path = path.rstrip('/') |
552 | if self.is_versioned(path.rstrip('/')): |
553 | - return self._fileid_map.lookup_file_id( |
554 | + return self.mapping.generate_file_id( |
555 | osutils.safe_unicode(path)) |
556 | return None |
557 | |
558 | @@ -988,7 +979,7 @@ |
559 | raise TypeError(file_id) |
560 | with self.lock_read(): |
561 | try: |
562 | - path = self._fileid_map.lookup_path(file_id) |
563 | + path = self.mapping.parse_file_id(file_id) |
564 | except ValueError: |
565 | raise errors.NoSuchId(self, file_id) |
566 | if self.is_versioned(path): |
567 | |
568 | === modified file 'breezy/git/workingtree.py' |
569 | --- breezy/git/workingtree.py 2019-06-21 17:49:36 +0000 |
570 | +++ breezy/git/workingtree.py 2019-06-29 16:01:34 +0000 |
571 | @@ -79,7 +79,6 @@ |
572 | MutableGitIndexTree, |
573 | ) |
574 | from .mapping import ( |
575 | - GitFileIdMap, |
576 | mode_kind, |
577 | ) |
578 | |
579 | @@ -603,7 +602,10 @@ |
580 | return False |
581 | |
582 | def had_id(self, file_id): |
583 | - path = self._basis_fileid_map.lookup_path(file_id) |
584 | + try: |
585 | + path = self.mapping.parse_file_id(file_id) |
586 | + except ValueError: |
587 | + return False |
588 | try: |
589 | head = self.repository._git.head() |
590 | except KeyError: |
591 | @@ -682,14 +684,7 @@ |
592 | raise errors.GhostRevisionUnusableHere(revid) |
593 | |
594 | def _reset_data(self): |
595 | - try: |
596 | - head = self.repository._git.head() |
597 | - except KeyError: |
598 | - self._basis_fileid_map = GitFileIdMap({}, self.mapping) |
599 | - else: |
600 | - self._basis_fileid_map = self.mapping.get_fileid_map( |
601 | - self.store.__getitem__, self.store[head].tree) |
602 | - self._fileid_map = self._basis_fileid_map.copy() |
603 | + pass |
604 | |
605 | def get_file_verifier(self, path, stat_value=None): |
606 | with self.lock_read(): |
I agree it makes sense to drop this.