revlog: don't include trailing nullrev in revlog.revs(stop=len(revlog))
authorMartin von Zweigbergk <martinvonz@google.com>
Fri, 20 Jul 2018 11:17:33 -0700
changeset 38777 83a505b5cf85
parent 38776 65ed2fcb9032
child 38778 a4d847cea6f8
revlog: don't include trailing nullrev in revlog.revs(stop=len(revlog)) This was an odd side effect of the nullid entry that's in the index. The existing callers (mostly repair.py) seem to have handled it fine. It doesn't seem intentional, and it's pretty surprising, so let's remove that surprise. Differential Revision: https://phab.mercurial-scm.org/D4015
mercurial/revlog.py
--- a/mercurial/revlog.py	Mon Jul 16 14:15:29 2018 -0400
+++ b/mercurial/revlog.py	Fri Jul 20 11:17:33 2018 -0700
@@ -1070,12 +1070,15 @@
     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 = len(self)
+            stop = length
         return xrange(start, stop, step)
 
     @util.propertycache