Mercurial > hg-stable
comparison mercurial/tags.py @ 25380:eaa456c5e699
tags: support reading tags cache without populating
An upcoming patch will teach the bundle2 protocol to transfer .hgtags
fnodes to the client. We don't want this to incur any extra work
at serve time. Create an optional cache query mode that doesn't
populate the cache as a side-effect.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 25 May 2015 16:24:23 -0700 |
parents | 559f24e3957d |
children | 47edeff19139 |
comparison
equal
deleted
inserted
replaced
25379:894bcdbb9e7a | 25380:eaa456c5e699 |
---|---|
440 # slightly less evil than copying a potentially large array slice. | 440 # slightly less evil than copying a potentially large array slice. |
441 for i in range(rawlen - wantedlen): | 441 for i in range(rawlen - wantedlen): |
442 self._raw.pop() | 442 self._raw.pop() |
443 self._dirtyoffset = len(self._raw) | 443 self._dirtyoffset = len(self._raw) |
444 | 444 |
445 def getfnode(self, node): | 445 def getfnode(self, node, computemissing=True): |
446 """Obtain the filenode of the .hgtags file at a specified revision. | 446 """Obtain the filenode of the .hgtags file at a specified revision. |
447 | 447 |
448 If the value is in the cache, the entry will be validated and returned. | 448 If the value is in the cache, the entry will be validated and returned. |
449 Otherwise, the filenode will be computed and returned. | 449 Otherwise, the filenode will be computed and returned unless |
450 "computemissing" is False, in which case None will be returned without | |
451 any potentially expensive computation being performed. | |
450 | 452 |
451 If an .hgtags does not exist at the specified revision, nullid is | 453 If an .hgtags does not exist at the specified revision, nullid is |
452 returned. | 454 returned. |
453 """ | 455 """ |
454 ctx = self._repo[node] | 456 ctx = self._repo[node] |
468 self.hitcount += 1 | 470 self.hitcount += 1 |
469 return record[4:] | 471 return record[4:] |
470 | 472 |
471 # Fall through. | 473 # Fall through. |
472 | 474 |
473 # If we get here, the entry is either missing or invalid. Populate it. | 475 # If we get here, the entry is either missing or invalid. |
476 | |
477 if not computemissing: | |
478 return None | |
479 | |
480 # Populate missing entry. | |
474 try: | 481 try: |
475 fnode = ctx.filenode('.hgtags') | 482 fnode = ctx.filenode('.hgtags') |
476 except error.LookupError: | 483 except error.LookupError: |
477 # No .hgtags file on this revision. | 484 # No .hgtags file on this revision. |
478 fnode = nullid | 485 fnode = nullid |