diff mercurial/revlog.py @ 39886:d63153611ed5

storageutil: extract revision number iteration This code is a bit quirky (and possibly buggy). It will likely be used by multiple storage backends. Let's extract it so it is reusable. Differential Revision: https://phab.mercurial-scm.org/D4757
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 24 Sep 2018 15:19:52 -0700
parents d269ddbf54f0
children debc4ee597e7
line wrap: on
line diff
--- a/mercurial/revlog.py	Mon Sep 24 14:54:28 2018 -0700
+++ b/mercurial/revlog.py	Mon Sep 24 15:19:52 2018 -0700
@@ -515,17 +515,7 @@
         return iter(pycompat.xrange(len(self)))
     def revs(self, start=0, stop=None):
         """iterate over all rev in this revlog (from start to stop)"""
-        step = 1
-        length = len(self)
-        if stop is not None:
-            if start > stop:
-                step = -1
-            stop += step
-            if stop > length:
-                stop = length
-        else:
-            stop = length
-        return pycompat.xrange(start, stop, step)
+        return storageutil.iterrevs(len(self), start=start, stop=stop)
 
     @util.propertycache
     def nodemap(self):