# HG changeset patch # User Gregory Szorc # Date 2015-05-25 23:48:55 # Node ID 47edeff19139f02f1f29e95b171d17e493d964df # Parent eaa456c5e6995f687178fb897181c7722a804b0a tags: support setting hgtags fnodes cache entries An upcoming patch will teach bundle2 to transfer .hgtags fnodes values. To support this, we need to support inserting values into the cache. Add functionality to do that. diff --git a/mercurial/tags.py b/mercurial/tags.py --- a/mercurial/tags.py +++ b/mercurial/tags.py @@ -484,14 +484,27 @@ class hgtagsfnodescache(object): # No .hgtags file on this revision. fnode = nullid + self._writeentry(offset, properprefix, fnode) + return fnode + + def setfnode(self, node, fnode): + """Set the .hgtags filenode for a given changeset.""" + assert len(fnode) == 20 + ctx = self._repo[node] + + # Do a lookup first to avoid writing if nothing has changed. + if self.getfnode(ctx.node(), computemissing=False) == fnode: + return + + self._writeentry(ctx.rev() * _fnodesrecsize, node[0:4], fnode) + + def _writeentry(self, offset, prefix, fnode): # Slices on array instances only accept other array. - entry = array('c', properprefix + fnode) + entry = array('c', prefix + fnode) self._raw[offset:offset + _fnodesrecsize] = entry # self._dirtyoffset could be None. self._dirtyoffset = min(self._dirtyoffset, offset) or 0 - return fnode - def write(self): """Perform all necessary writes to cache file.