Mercurial > hg
comparison mercurial/revlog.py @ 31750:f319981c24c9
revlog: rename some "text"s to "rawtext"
This makes code easier to understand. "_addrevision" is left untouched - it
will be changed in a later patch.
author | Jun Wu <quark@fb.com> |
---|---|
date | Thu, 30 Mar 2017 14:56:09 -0700 |
parents | 17d0dab7b2b6 |
children | 2133437dad17 |
comparison
equal
deleted
inserted
replaced
31749:17d0dab7b2b6 | 31750:f319981c24c9 |
---|---|
1269 if self._cache[0] == node: | 1269 if self._cache[0] == node: |
1270 return self._cache[2] | 1270 return self._cache[2] |
1271 cachedrev = self._cache[1] | 1271 cachedrev = self._cache[1] |
1272 | 1272 |
1273 # look up what we need to read | 1273 # look up what we need to read |
1274 text = None | 1274 rawtext = None |
1275 if rev is None: | 1275 if rev is None: |
1276 rev = self.rev(node) | 1276 rev = self.rev(node) |
1277 | 1277 |
1278 chain, stopped = self._deltachain(rev, stoprev=cachedrev) | 1278 chain, stopped = self._deltachain(rev, stoprev=cachedrev) |
1279 if stopped: | 1279 if stopped: |
1280 text = self._cache[2] | 1280 rawtext = self._cache[2] |
1281 | 1281 |
1282 # drop cache to save memory | 1282 # drop cache to save memory |
1283 self._cache = None | 1283 self._cache = None |
1284 | 1284 |
1285 bins = self._chunks(chain, df=_df) | 1285 bins = self._chunks(chain, df=_df) |
1286 if text is None: | 1286 if rawtext is None: |
1287 text = bytes(bins[0]) | 1287 rawtext = bytes(bins[0]) |
1288 bins = bins[1:] | 1288 bins = bins[1:] |
1289 | 1289 |
1290 text = mdiff.patches(text, bins) | 1290 rawtext = mdiff.patches(rawtext, bins) |
1291 | 1291 |
1292 text, validatehash = self._processflags(text, self.flags(rev), 'read', | 1292 text, validatehash = self._processflags(rawtext, self.flags(rev), |
1293 raw=raw) | 1293 'read', raw=raw) |
1294 if validatehash: | 1294 if validatehash: |
1295 self.checkhash(text, node, rev=rev) | 1295 self.checkhash(text, node, rev=rev) |
1296 | 1296 |
1297 self._cache = (node, rev, text) | 1297 self._cache = (node, rev, text) |
1298 return text | 1298 return text |
1449 % self.indexfile) | 1449 % self.indexfile) |
1450 | 1450 |
1451 if flags: | 1451 if flags: |
1452 node = node or self.hash(text, p1, p2) | 1452 node = node or self.hash(text, p1, p2) |
1453 | 1453 |
1454 newtext, validatehash = self._processflags(text, flags, 'write') | 1454 rawtext, validatehash = self._processflags(text, flags, 'write') |
1455 | 1455 |
1456 # If the flag processor modifies the revision data, ignore any provided | 1456 # If the flag processor modifies the revision data, ignore any provided |
1457 # cachedelta. | 1457 # cachedelta. |
1458 if newtext != text: | 1458 if rawtext != text: |
1459 cachedelta = None | 1459 cachedelta = None |
1460 text = newtext | 1460 |
1461 | 1461 if len(rawtext) > _maxentrysize: |
1462 if len(text) > _maxentrysize: | |
1463 raise RevlogError( | 1462 raise RevlogError( |
1464 _("%s: size of %d bytes exceeds maximum revlog storage of 2GiB") | 1463 _("%s: size of %d bytes exceeds maximum revlog storage of 2GiB") |
1465 % (self.indexfile, len(text))) | 1464 % (self.indexfile, len(rawtext))) |
1466 | 1465 |
1467 node = node or self.hash(text, p1, p2) | 1466 node = node or self.hash(rawtext, p1, p2) |
1468 if node in self.nodemap: | 1467 if node in self.nodemap: |
1469 return node | 1468 return node |
1470 | 1469 |
1471 if validatehash: | 1470 if validatehash: |
1472 self.checkhash(text, node, p1=p1, p2=p2) | 1471 self.checkhash(rawtext, node, p1=p1, p2=p2) |
1473 | 1472 |
1474 dfh = None | 1473 dfh = None |
1475 if not self._inline: | 1474 if not self._inline: |
1476 dfh = self.opener(self.datafile, "a+") | 1475 dfh = self.opener(self.datafile, "a+") |
1477 ifh = self.opener(self.indexfile, "a+", checkambig=self._checkambig) | 1476 ifh = self.opener(self.indexfile, "a+", checkambig=self._checkambig) |
1478 try: | 1477 try: |
1479 return self._addrevision(node, text, transaction, link, p1, p2, | 1478 return self._addrevision(node, rawtext, transaction, link, p1, p2, |
1480 flags, cachedelta, ifh, dfh) | 1479 flags, cachedelta, ifh, dfh) |
1481 finally: | 1480 finally: |
1482 if dfh: | 1481 if dfh: |
1483 dfh.close() | 1482 dfh.close() |
1484 ifh.close() | 1483 ifh.close() |