changeset 24375:fe255b2525d5

revbranchcache: move entry writing to a separate function This moves the actual writing of entries to the cache to a separate function. This will allow us to use it in multiple places. Ex: in one place we will write dummy entries, and in another place we will write real data.
author Durham Goode <durham@fb.com>
date Tue, 10 Feb 2015 20:01:08 -0800
parents 77fd1fb538cd
children 203a078da052
files mercurial/branchmap.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/branchmap.py	Tue Feb 10 19:57:51 2015 -0800
+++ b/mercurial/branchmap.py	Tue Feb 10 20:01:08 2015 -0800
@@ -399,11 +399,15 @@
         reponode = changelog.node(rev)
         if close:
             branchidx |= _rbccloseflag
+        self._setcachedata(rev, reponode, branchidx)
+        return b, close
+
+    def _setcachedata(self, rev, node, branchidx):
+        """Writes the node's branch data to the in-memory cache data."""
         rbcrevidx = rev * _rbcrecsize
         rec = array('c')
-        rec.fromstring(pack(_rbcrecfmt, reponode, branchidx))
+        rec.fromstring(pack(_rbcrecfmt, node, branchidx))
         self._rbcrevs[rbcrevidx:rbcrevidx + _rbcrecsize] = rec
-        return b, close
 
     def write(self):
         """Save branch cache if it is dirty."""