# HG changeset patch # User Pierre-Yves David # Date 1493837786 -7200 # Node ID 6b751daad348b350776635e34d841e37081f4753 # Parent 72853bade8532ef9cfe606d3244788d238071fb2 obscache: extract _updatemarkers code into its own function This split the update logic from the bit retrieving markers. That cannot be bad. diff -r 72853bade853 -r 6b751daad348 hgext3rd/evolve/obscache.py --- 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"""