Merge lp:~jelmer/brz/cf-size 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/cf-size
Merge into: lp:brz
Prerequisite: lp:~jelmer/brz/compress
Diff against target: 160 lines (+21/-7)
5 files modified
breezy/bzr/_groupcompress_py.py (+1/-2)
breezy/bzr/groupcompress.py (+10/-5)
breezy/bzr/knit.py (+1/-0)
breezy/bzr/versionedfile.py (+7/-0)
breezy/git/annotate.py (+2/-0)
To merge this branch: bzr merge lp:~jelmer/brz/cf-size
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+378080@code.launchpad.net

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

Commit message

Add a size attribute to ContentFactory.

Description of the change

Add a size attribute to ContentFactory.

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
Jelmer Vernooij (jelmer) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/bzr/_groupcompress_py.py'
--- breezy/bzr/_groupcompress_py.py 2020-01-25 22:05:40 +0000
+++ breezy/bzr/_groupcompress_py.py 2020-01-26 04:33:55 +0000
@@ -228,8 +228,7 @@
228 if block[-1] < min_match_bytes:228 if block[-1] < min_match_bytes:
229 # This block may be a 'short' block, check229 # This block may be a 'short' block, check
230 old_start, new_start, range_len = block230 old_start, new_start, range_len = block
231 matched_bytes = sum(map(len,231 matched_bytes = sum(map(len, lines[new_start:new_start + range_len]))
232 lines[new_start:new_start + range_len]))
233 if matched_bytes < min_match_bytes:232 if matched_bytes < min_match_bytes:
234 block = None233 block = None
235 if block is not None:234 if block is not None:
236235
=== modified file 'breezy/bzr/groupcompress.py'
--- breezy/bzr/groupcompress.py 2020-01-26 04:33:55 +0000
+++ breezy/bzr/groupcompress.py 2020-01-26 04:33:55 +0000
@@ -441,6 +441,7 @@
441 self.key = key441 self.key = key
442 self.parents = parents442 self.parents = parents
443 self.sha1 = None443 self.sha1 = None
444 self.size = None
444 # Note: This attribute coupled with Manager._factories creates a445 # Note: This attribute coupled with Manager._factories creates a
445 # reference cycle. Perhaps we would rather use a weakref(), or446 # reference cycle. Perhaps we would rather use a weakref(), or
446 # find an appropriate time to release the ref. After the first447 # find an appropriate time to release the ref. After the first
@@ -569,7 +570,9 @@
569 end_point = 0570 end_point = 0
570 for factory in self._factories:571 for factory in self._factories:
571 chunks = factory.get_bytes_as('chunked')572 chunks = factory.get_bytes_as('chunked')
572 chunks_len = sum(map(len, chunks))573 chunks_len = factory.size
574 if chunks_len is None:
575 chunks_len = sum(map(len, chunks))
573 (found_sha1, start_point, end_point,576 (found_sha1, start_point, end_point,
574 type) = compressor.compress(577 type) = compressor.compress(
575 factory.key, chunks, chunks_len, factory.sha1)578 factory.key, chunks, chunks_len, factory.sha1)
@@ -1349,9 +1352,9 @@
1349 # chunks in memory.1352 # chunks in memory.
1350 chunks = list(chunk_iter)1353 chunks = list(chunk_iter)
1351 record = ChunkedContentFactory(key, parents, None, chunks)1354 record = ChunkedContentFactory(key, parents, None, chunks)
1352 sha1 = list(self._insert_record_stream(1355 sha1, size = list(self._insert_record_stream(
1353 [record], random_id=random_id, nostore_sha=nostore_sha))[0]1356 [record], random_id=random_id, nostore_sha=nostore_sha))[0]
1354 return sha1, sum(map(len, chunks)), None1357 return sha1, size, None
13551358
1356 def add_fallback_versioned_files(self, a_versioned_files):1359 def add_fallback_versioned_files(self, a_versioned_files):
1357 """Add a source of texts for texts not present in this knit.1360 """Add a source of texts for texts not present in this knit.
@@ -1832,7 +1835,9 @@
1832 adapter_key = record.storage_kind, 'chunked'1835 adapter_key = record.storage_kind, 'chunked'
1833 adapter = get_adapter(adapter_key)1836 adapter = get_adapter(adapter_key)
1834 chunks = adapter.get_bytes(record, 'chunked')1837 chunks = adapter.get_bytes(record, 'chunked')
1835 chunks_len = sum(map(len, chunks))1838 chunks_len = record.size
1839 if chunks_len is None:
1840 chunks_len = sum(map(len, chunks))
1836 if len(record.key) > 1:1841 if len(record.key) > 1:
1837 prefix = record.key[0]1842 prefix = record.key[0]
1838 soft = (prefix == last_prefix)1843 soft = (prefix == last_prefix)
@@ -1873,7 +1878,7 @@
1873 else:1878 else:
1874 key = record.key1879 key = record.key
1875 self._unadded_refs[key] = record.parents1880 self._unadded_refs[key] = record.parents
1876 yield found_sha11881 yield found_sha1, chunks_len
1877 as_st = static_tuple.StaticTuple.from_sequence1882 as_st = static_tuple.StaticTuple.from_sequence
1878 if record.parents is not None:1883 if record.parents is not None:
1879 parents = as_st([as_st(p) for p in record.parents])1884 parents = as_st([as_st(p) for p in record.parents])
18801885
=== modified file 'breezy/bzr/knit.py'
--- breezy/bzr/knit.py 2020-01-25 14:39:08 +0000
+++ breezy/bzr/knit.py 2020-01-26 04:33:55 +0000
@@ -442,6 +442,7 @@
442 self.key = key442 self.key = key
443 self.parents = parents443 self.parents = parents
444 self.sha1 = None444 self.sha1 = None
445 self.size = None
445 self._generator = generator446 self._generator = generator
446 self.storage_kind = "knit-delta-closure"447 self.storage_kind = "knit-delta-closure"
447 if not first:448 if not first:
448449
=== modified file 'breezy/bzr/versionedfile.py'
--- breezy/bzr/versionedfile.py 2020-01-25 15:55:41 +0000
+++ breezy/bzr/versionedfile.py 2020-01-26 04:33:55 +0000
@@ -75,6 +75,7 @@
75 """Abstract interface for insertion and retrieval from a VersionedFile.75 """Abstract interface for insertion and retrieval from a VersionedFile.
7676
77 :ivar sha1: None, or the sha1 of the content fulltext.77 :ivar sha1: None, or the sha1 of the content fulltext.
78 :ivar size: None, or the size of the content fulltext.
78 :ivar storage_kind: The native storage kind of this factory. One of79 :ivar storage_kind: The native storage kind of this factory. One of
79 'mpdiff', 'knit-annotated-ft', 'knit-annotated-delta', 'knit-ft',80 'mpdiff', 'knit-annotated-ft', 'knit-annotated-delta', 'knit-ft',
80 'knit-delta', 'fulltext', 'knit-annotated-ft-gz',81 'knit-delta', 'fulltext', 'knit-annotated-ft-gz',
@@ -89,6 +90,7 @@
89 def __init__(self):90 def __init__(self):
90 """Create a ContentFactory."""91 """Create a ContentFactory."""
91 self.sha1 = None92 self.sha1 = None
93 self.size = None
92 self.storage_kind = None94 self.storage_kind = None
93 self.key = None95 self.key = None
94 self.parents = None96 self.parents = None
@@ -102,6 +104,7 @@
102 satisfies this, as does a list of lines.104 satisfies this, as does a list of lines.
103105
104 :ivar sha1: None, or the sha1 of the content fulltext.106 :ivar sha1: None, or the sha1 of the content fulltext.
107 :ivar size: None, or the size of the content fulltext.
105 :ivar storage_kind: The native storage kind of this factory. Always108 :ivar storage_kind: The native storage kind of this factory. Always
106 'chunked'109 'chunked'
107 :ivar key: The key of this content. Each key is a tuple with a single110 :ivar key: The key of this content. Each key is a tuple with a single
@@ -115,6 +118,7 @@
115 def __init__(self, key, parents, sha1, chunks, chunks_are_lines=None):118 def __init__(self, key, parents, sha1, chunks, chunks_are_lines=None):
116 """Create a ContentFactory."""119 """Create a ContentFactory."""
117 self.sha1 = sha1120 self.sha1 = sha1
121 self.size = sum(map(len, chunks))
118 self.storage_kind = 'chunked'122 self.storage_kind = 'chunked'
119 self.key = key123 self.key = key
120 self.parents = parents124 self.parents = parents
@@ -153,6 +157,7 @@
153 def __init__(self, key, parents, sha1, text):157 def __init__(self, key, parents, sha1, text):
154 """Create a ContentFactory."""158 """Create a ContentFactory."""
155 self.sha1 = sha1159 self.sha1 = sha1
160 self.size = len(text)
156 self.storage_kind = 'fulltext'161 self.storage_kind = 'fulltext'
157 self.key = key162 self.key = key
158 self.parents = parents163 self.parents = parents
@@ -181,6 +186,7 @@
181 self.file = fileobj186 self.file = fileobj
182 self.storage_kind = 'file'187 self.storage_kind = 'file'
183 self._sha1 = None188 self._sha1 = None
189 self._size = None
184190
185 @property191 @property
186 def sha1(self):192 def sha1(self):
@@ -214,6 +220,7 @@
214 def __init__(self, key):220 def __init__(self, key):
215 """Create a ContentFactory."""221 """Create a ContentFactory."""
216 self.sha1 = None222 self.sha1 = None
223 self.size = None
217 self.storage_kind = 'absent'224 self.storage_kind = 'absent'
218 self.key = key225 self.key = key
219 self.parents = None226 self.parents = None
220227
=== modified file 'breezy/git/annotate.py'
--- breezy/git/annotate.py 2020-01-25 14:07:41 +0000
+++ breezy/git/annotate.py 2020-01-26 04:33:55 +0000
@@ -56,6 +56,7 @@
56 self.storage_kind = 'git-blob'56 self.storage_kind = 'git-blob'
57 self.parents = None57 self.parents = None
58 self.blob_id = blob_id58 self.blob_id = blob_id
59 self.size = None
5960
60 def get_bytes_as(self, storage_kind):61 def get_bytes_as(self, storage_kind):
61 if storage_kind == 'fulltext':62 if storage_kind == 'fulltext':
@@ -87,6 +88,7 @@
87 self.key = (path, revision)88 self.key = (path, revision)
88 self.storage_kind = 'absent'89 self.storage_kind = 'absent'
89 self.parents = None90 self.parents = None
91 self.size = None
9092
91 def get_bytes_as(self, storage_kind):93 def get_bytes_as(self, storage_kind):
92 raise ValueError94 raise ValueError

Subscribers

People subscribed via source and target branches