Mercurial > evolve
changeset 2327:6b751daad348
obscache: extract _updatemarkers code into its own function
This split the update logic from the bit retrieving markers. That cannot be bad.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 03 May 2017 20:56:26 +0200 |
parents | 72853bade853 |
children | 7ccacaa38782 |
files | hgext3rd/evolve/obscache.py |
diffstat | 1 files changed, 10 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/obscache.py Wed May 03 18:46:48 2017 +0200 +++ b/hgext3rd/evolve/obscache.py Wed May 03 20:56:26 2017 +0200 @@ -258,7 +258,6 @@ # process the new obsmarkers if startidx is not None: - rev = cl.nodemap.get markers = repo.obsstore._all # Note: # @@ -275,13 +274,8 @@ # responsible for adding a markers. # # Option 2 is probably a bit more invasive, but more solid on the long run - - for i in xrange(startidx, len(repo.obsstore)): - r = rev(markers[i][0]) - # If markers affect a newly added nodes, it would have been - # caught in the previous loop, (so we skip < startrev) - if r is not None and (startrev is None or r < startrev): - self._data[r] = 1 + markers = [markers[i] for i in xrange(startidx, len(repo.obsstore))] + self._updatemarkers(repo, markers) self._cachekey = getcachekey(repo) @@ -307,6 +301,14 @@ val = 0 self._data.append(val) + def _updatemarkers(self, repo, obsmarkers): + """update the cache with new markers""" + rev = repo.changelog.nodemap.get + for m in obsmarkers: + r = rev(m[0]) + if r is not None: + self._data[r] = 1 + def save(self, repo): """save the data to disk"""