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.
--- a/mercurial/tags.py Mon May 25 16:24:23 2015 -0700
+++ b/mercurial/tags.py Mon May 25 16:48:55 2015 -0700
@@ -484,14 +484,27 @@
# 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.