hgext/largefiles/reposetup.py
changeset 50488 b4a9c8f18928
parent 50471 521fec115dad
child 50504 862e3a13da44
--- a/hgext/largefiles/reposetup.py	Mon May 15 09:00:46 2023 +0200
+++ b/hgext/largefiles/reposetup.py	Mon May 15 09:01:02 2023 +0200
@@ -457,12 +457,16 @@
 
     def checkrequireslfiles(ui, repo, **kwargs):
         with repo.lock():
-            if b'largefiles' not in repo.requirements and any(
-                lfutil.shortname + b'/' in entry.unencoded_path
-                for entry in repo.store.datafiles()
-            ):
-                repo.requirements.add(b'largefiles')
-                scmutil.writereporequirements(repo)
+            if b'largefiles' in repo.requirements:
+                return
+            marker = lfutil.shortnameslash
+            for entry in repo.store.datafiles():
+                # XXX note that this match is not rooted and can wrongly match
+                # directory ending with ".hglf"
+                if entry.is_revlog and marker in entry.target_id:
+                    repo.requirements.add(b'largefiles')
+                    scmutil.writereporequirements(repo)
+                    break
 
     ui.setconfig(
         b'hooks', b'changegroup.lfiles', checkrequireslfiles, b'largefiles'