From patchwork Tue Mar 17 03:36:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3,of,6] revbranchcache: move entry writing to a separate function From: Durham Goode X-Patchwork-Id: 8110 Message-Id: <8e61a4ec3f3d7d6af1ac.1426563375@dev2000.prn2.facebook.com> To: Cc: pierre-yves.david@ens-lyon.org Date: Mon, 16 Mar 2015 20:36:15 -0700 # HG changeset patch # User Durham Goode # Date 1423627268 28800 # Tue Feb 10 20:01:08 2015 -0800 # Node ID 8e61a4ec3f3d7d6af1ac5d31094c69173862f972 # Parent 99e73b9195b1d8bcb3d191db7aa430fd6f70fdcd 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. diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py --- a/mercurial/branchmap.py +++ b/mercurial/branchmap.py @@ -399,11 +399,15 @@ class revbranchcache(object): 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."""