Merge lp:~jelmer/brz/revisiontree-chunks into lp:brz/3.2

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/revisiontree-chunks
Merge into: lp:brz/3.2
Diff against target: 58 lines (+11/-6)
2 files modified
breezy/bzr/versionedfile.py (+7/-2)
breezy/revisiontree.py (+4/-4)
To merge this branch: bzr merge lp:~jelmer/brz/revisiontree-chunks
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+426478@code.launchpad.net

This proposal supersedes a proposal from 2020-06-01.

Commit message

Don't keep file in memory in Tree.get_file.

Description of the change

Don't keep file in memory in Tree.get_file.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote : Posted in a previous version of this proposal
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote : Posted in a previous version of this proposal
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote : Posted in a previous version of this proposal
Revision history for this message
Jelmer Vernooij (jelmer) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote : Posted in a previous version of this proposal
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote : Posted in a previous version of this proposal
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote : Posted in a previous version of this proposal
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote : Posted in a previous version of this proposal
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/bzr/versionedfile.py'
2--- breezy/bzr/versionedfile.py 2021-08-19 21:03:45 +0000
3+++ breezy/bzr/versionedfile.py 2022-07-07 14:31:02 +0000
4@@ -216,9 +216,12 @@
5 self.storage_kind = 'file'
6 self.sha1 = sha1
7 self.size = size
8+ self._needs_reset = False
9
10 def get_bytes_as(self, storage_kind):
11- self.file.seek(0)
12+ if self._needs_reset:
13+ self.file.seek(0)
14+ self._needs_reset = True
15 if storage_kind == 'fulltext':
16 return self.file.read()
17 elif storage_kind == 'chunked':
18@@ -229,7 +232,9 @@
19 self.storage_kind)
20
21 def iter_bytes_as(self, storage_kind):
22- self.file.seek(0)
23+ if self._needs_reset:
24+ self.file.seek(0)
25+ self._needs_reset = True
26 if storage_kind == 'chunked':
27 return osutils.file_iterator(self.file)
28 elif storage_kind == 'lines':
29
30=== modified file 'breezy/revisiontree.py'
31--- breezy/revisiontree.py 2020-02-18 01:57:45 +0000
32+++ breezy/revisiontree.py 2022-07-07 14:31:02 +0000
33@@ -16,9 +16,9 @@
34
35 """RevisionTree - a Tree implementation backed by repository data for a revision."""
36
37-from io import BytesIO
38 from . import (
39 lock,
40+ iterablefile,
41 revision,
42 tree,
43 )
44@@ -65,11 +65,11 @@
45
46 def get_file_text(self, path):
47 for (identifier, content) in self.iter_files_bytes([(path, None)]):
48- ret = b"".join(content)
49- return ret
50+ return b"".join(content)
51
52 def get_file(self, path):
53- return BytesIO(self.get_file_text(path))
54+ for (identifier, content) in self.iter_files_bytes([(path, None)]):
55+ return iterablefile.IterableFile(content)
56
57 def is_locked(self):
58 return self._repository.is_locked()

Subscribers

People subscribed via source and target branches