comparison mercurial/branchmap.py @ 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
comparison
equal deleted inserted replaced
24374:77fd1fb538cd 24375:fe255b2525d5
397 self._names.append(b) 397 self._names.append(b)
398 self._namesreverse[b] = branchidx 398 self._namesreverse[b] = branchidx
399 reponode = changelog.node(rev) 399 reponode = changelog.node(rev)
400 if close: 400 if close:
401 branchidx |= _rbccloseflag 401 branchidx |= _rbccloseflag
402 self._setcachedata(rev, reponode, branchidx)
403 return b, close
404
405 def _setcachedata(self, rev, node, branchidx):
406 """Writes the node's branch data to the in-memory cache data."""
402 rbcrevidx = rev * _rbcrecsize 407 rbcrevidx = rev * _rbcrecsize
403 rec = array('c') 408 rec = array('c')
404 rec.fromstring(pack(_rbcrecfmt, reponode, branchidx)) 409 rec.fromstring(pack(_rbcrecfmt, node, branchidx))
405 self._rbcrevs[rbcrevidx:rbcrevidx + _rbcrecsize] = rec 410 self._rbcrevs[rbcrevidx:rbcrevidx + _rbcrecsize] = rec
406 return b, close
407 411
408 def write(self): 412 def write(self):
409 """Save branch cache if it is dirty.""" 413 """Save branch cache if it is dirty."""
410 repo = self._repo 414 repo = self._repo
411 if self._rbcnamescount < len(self._names): 415 if self._rbcnamescount < len(self._names):