Merge lp:~jelmer/brz/fastimport-no-id2path into lp:brz

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/fastimport-no-id2path
Merge into: lp:brz
Diff against target: 58 lines (+5/-19)
2 files modified
breezy/plugins/fastimport/bzr_commit_handler.py (+3/-3)
breezy/plugins/fastimport/revision_store.py (+2/-16)
To merge this branch: bzr merge lp:~jelmer/brz/fastimport-no-id2path
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+373062@code.launchpad.net

Commit message

Avoid use of id2path in the fastimport plugin.

Description of the change

Avoid use of id2path in the fastimport plugin.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/plugins/fastimport/bzr_commit_handler.py'
2--- breezy/plugins/fastimport/bzr_commit_handler.py 2019-02-14 19:34:17 +0000
3+++ breezy/plugins/fastimport/bzr_commit_handler.py 2019-09-22 13:13:44 +0000
4@@ -505,8 +505,8 @@
5 if newly_changed:
6 content = self.data_for_commit[file_id]
7 else:
8- content = self.rev_store.get_file_text(
9- self.parents[0], file_id)
10+ revtree = self.rev_store.repo.revision_tree(self.parents[0])
11+ content = revtree.get_file_text(src_path)
12 self._modify_item(dest_path, kind, ie.executable, content, inv)
13 elif kind == 'symlink':
14 self._modify_item(dest_path, kind, False,
15@@ -540,7 +540,7 @@
16 # The revision-id for this entry will be/has been updated and
17 # that means the loader then needs to know what the "new" text is.
18 # We therefore must go back to the revision store to get it.
19- lines = self.rev_store.get_file_lines(rev_id, file_id)
20+ lines = self.rev_store.get_file_lines(rev_id, old_path)
21 self.data_for_commit[file_id] = b''.join(lines)
22
23 def _delete_all_items(self, inv):
24
25=== modified file 'breezy/plugins/fastimport/revision_store.py'
26--- breezy/plugins/fastimport/revision_store.py 2019-06-15 12:04:34 +0000
27+++ breezy/plugins/fastimport/revision_store.py 2019-09-22 13:13:44 +0000
28@@ -227,17 +227,10 @@
29 """Get a stored inventory."""
30 return self.repo.get_inventory(revision_id)
31
32- def get_file_text(self, revision_id, file_id):
33- """Get the text stored for a file in a given revision."""
34- revtree = self.repo.revision_tree(revision_id)
35- path = revtree.id2path(file_id)
36- return revtree.get_file_text(path)
37-
38- def get_file_lines(self, revision_id, file_id):
39+ def get_file_lines(self, revision_id, path):
40 """Get the lines stored for a file in a given revision."""
41 revtree = self.repo.revision_tree(revision_id)
42- path = revtree.id2path(file_id)
43- return osutils.split_lines(revtree.get_file_text(path))
44+ return revtree.get_file_lines(path)
45
46 def start_new_revision(self, revision, parents, parent_invs):
47 """Init the metadata needed for get_parents_and_revision_for_entry().
48@@ -398,10 +391,3 @@
49 raise AssertionError('signatures not guaranteed yet')
50 self.repo.add_signature_text(rev.revision_id, signature)
51 return builder.revision_tree().root_inventory
52-
53- def get_file_lines(self, revision_id, file_id):
54- record = next(self.repo.texts.get_record_stream([(file_id, revision_id)],
55- 'unordered', True))
56- if record.storage_kind == 'absent':
57- raise errors.RevisionNotPresent(record.key, self.repo)
58- return osutils.split_lines(record.get_bytes_as('fulltext'))

Subscribers

People subscribed via source and target branches