Patchwork D9865: store: use `endswith` to detect revlog extension

login
register
mail settings
Submitter phabricator
Date Jan. 25, 2021, 9:32 p.m.
Message ID <differential-rev-PHID-DREV-ww46edzp6ena6ox7euiy-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48176/
State Superseded
Headers show

Comments

phabricator - Jan. 25, 2021, 9:32 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Suggested by Gregory Szorc.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9865

AFFECTED FILES
  mercurial/store.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/store.py b/mercurial/store.py
--- a/mercurial/store.py
+++ b/mercurial/store.py
@@ -387,13 +387,12 @@ 
     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):