Show More
@@ -34,7 +34,6 b' from mercurial import (' | |||
|
34 | 34 | extensions, |
|
35 | 35 | mdiff, |
|
36 | 36 | merge, |
|
37 | revlog, | |
|
38 | 37 | util, |
|
39 | 38 | ) |
|
40 | 39 | |
@@ -989,7 +988,7 b' def perfrevlogrevision(ui, repo, file_, ' | |||
|
989 | 988 | chunkstart += (rev + 1) * iosize |
|
990 | 989 | chunklength = length(rev) |
|
991 | 990 | b = buffer(data, chunkstart - offset, chunklength) |
|
992 |
r |
|
|
991 | r.decompress(b) | |
|
993 | 992 | |
|
994 | 993 | def dopatch(text, bins): |
|
995 | 994 | if not cache: |
@@ -140,22 +140,6 b' def hash(text, p1, p2):' | |||
|
140 | 140 | s.update(text) |
|
141 | 141 | return s.digest() |
|
142 | 142 | |
|
143 | def decompress(bin): | |
|
144 | """ decompress the given input """ | |
|
145 | if not bin: | |
|
146 | return bin | |
|
147 | t = bin[0] | |
|
148 | if t == '\0': | |
|
149 | return bin | |
|
150 | if t == 'x': | |
|
151 | try: | |
|
152 | return _decompress(bin) | |
|
153 | except zlib.error as e: | |
|
154 | raise RevlogError(_("revlog decompress error: %s") % str(e)) | |
|
155 | if t == 'u': | |
|
156 | return util.buffer(bin, 1) | |
|
157 | raise RevlogError(_("unknown compression type %r") % t) | |
|
158 | ||
|
159 | 143 | # index v0: |
|
160 | 144 | # 4 bytes: offset |
|
161 | 145 | # 4 bytes: compressed length |
@@ -1179,7 +1163,7 b' class revlog(object):' | |||
|
1179 | 1163 | |
|
1180 | 1164 | Returns a str holding uncompressed data for the requested revision. |
|
1181 | 1165 | """ |
|
1182 | return decompress(self._chunkraw(rev, rev, df=df)[1]) | |
|
1166 | return self.decompress(self._chunkraw(rev, rev, df=df)[1]) | |
|
1183 | 1167 | |
|
1184 | 1168 | def _chunks(self, revs, df=None): |
|
1185 | 1169 | """Obtain decompressed chunks for the specified revisions. |
@@ -1212,12 +1196,13 b' class revlog(object):' | |||
|
1212 | 1196 | # 2G on Windows |
|
1213 | 1197 | return [self._chunk(rev, df=df) for rev in revs] |
|
1214 | 1198 | |
|
1199 | decomp = self.decompress | |
|
1215 | 1200 | for rev in revs: |
|
1216 | 1201 | chunkstart = start(rev) |
|
1217 | 1202 | if inline: |
|
1218 | 1203 | chunkstart += (rev + 1) * iosize |
|
1219 | 1204 | chunklength = length(rev) |
|
1220 |
ladd(decomp |
|
|
1205 | ladd(decomp(buffer(data, chunkstart - offset, chunklength))) | |
|
1221 | 1206 | |
|
1222 | 1207 | return l |
|
1223 | 1208 | |
@@ -1509,6 +1494,26 b' class revlog(object):' | |||
|
1509 | 1494 | return ('u', text) |
|
1510 | 1495 | return ("", bin) |
|
1511 | 1496 | |
|
1497 | def decompress(self, data): | |
|
1498 | """Decompress a revlog chunk. | |
|
1499 | ||
|
1500 | The chunk is expected to begin with a header identifying the | |
|
1501 | format type so it can be routed to an appropriate decompressor. | |
|
1502 | """ | |
|
1503 | if not data: | |
|
1504 | return data | |
|
1505 | t = data[0] | |
|
1506 | if t == '\0': | |
|
1507 | return data | |
|
1508 | if t == 'x': | |
|
1509 | try: | |
|
1510 | return _decompress(data) | |
|
1511 | except zlib.error as e: | |
|
1512 | raise RevlogError(_('revlog decompress error: %s') % str(e)) | |
|
1513 | if t == 'u': | |
|
1514 | return util.buffer(data, 1) | |
|
1515 | raise RevlogError(_('unknown compression type %r') % t) | |
|
1516 | ||
|
1512 | 1517 | def _isgooddelta(self, d, textlen): |
|
1513 | 1518 | """Returns True if the given delta is good. Good means that it is within |
|
1514 | 1519 | the disk span, disk size, and chain length bounds that we know to be |
General Comments 0
You need to be logged in to leave comments.
Login now