##// END OF EJS Templates
storageutil: extract revision number iteration...
Gregory Szorc -
r39917:d6315361 default
parent child Browse files
Show More
@@ -515,17 +515,7 b' class revlog(object):'
515 return iter(pycompat.xrange(len(self)))
515 return iter(pycompat.xrange(len(self)))
516 def revs(self, start=0, stop=None):
516 def revs(self, start=0, stop=None):
517 """iterate over all rev in this revlog (from start to stop)"""
517 """iterate over all rev in this revlog (from start to stop)"""
518 step = 1
518 return storageutil.iterrevs(len(self), start=start, stop=stop)
519 length = len(self)
520 if stop is not None:
521 if start > stop:
522 step = -1
523 stop += step
524 if stop > length:
525 stop = length
526 else:
527 stop = length
528 return pycompat.xrange(start, stop, step)
529
519
530 @util.propertycache
520 @util.propertycache
531 def nodemap(self):
521 def nodemap(self):
@@ -13,6 +13,9 b' import re'
13 from ..node import (
13 from ..node import (
14 nullid,
14 nullid,
15 )
15 )
16 from .. import (
17 pycompat,
18 )
16
19
17 _nullhash = hashlib.sha1(nullid)
20 _nullhash = hashlib.sha1(nullid)
18
21
@@ -81,3 +84,18 b' def filtermetadata(text):'
81
84
82 offset = text.index(b'\x01\n', 2)
85 offset = text.index(b'\x01\n', 2)
83 return text[offset + 2:]
86 return text[offset + 2:]
87
88 def iterrevs(storelen, start=0, stop=None):
89 """Iterate over revision numbers in a store."""
90 step = 1
91
92 if stop is not None:
93 if start > stop:
94 step = -1
95 stop += step
96 if stop > storelen:
97 stop = storelen
98 else:
99 stop = storelen
100
101 return pycompat.xrange(start, stop, step)
General Comments 0
You need to be logged in to leave comments. Login now