store: use `endswith` to detect revlog extension
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 25 Jan 2021 16:34:43 +0100
changeset 46383 374d7fff7cb5
parent 46382 d4c8b4b90ecb
child 46384 7bb31c367847
store: use `endswith` to detect revlog extension Suggested by Gregory Szorc. Differential Revision: https://phab.mercurial-scm.org/D9865
mercurial/store.py
--- a/mercurial/store.py	Tue Dec 01 12:59:33 2020 -0500
+++ b/mercurial/store.py	Mon Jan 25 16:34:43 2021 +0100
@@ -387,13 +387,13 @@
     b'requires',
 ]
 
+REVLOG_FILES_EXT = (b'.i', b'.d', b'.n', b'.nd')
+
 
 def isrevlog(f, kind, st):
     if kind != stat.S_IFREG:
         return False
-    if f[-2:] in (b'.i', b'.d', b'.n'):
-        return True
-    return f[-3:] == b'.nd'
+    return f.endswith(REVLOG_FILES_EXT)
 
 
 class basicstore(object):