# HG changeset patch # User Pierre-Yves David # Date 2023-05-15 07:01:02 # Node ID b4a9c8f1892899e2c0441e1ca634a2e9aa71c615 # Parent 92611344aec2cc369af86e7588a9e4b03806f955 store: use StoreEntry API instead of parsing filename in largefile This is more explicit and more robust. diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py --- a/hgext/largefiles/lfutil.py +++ b/hgext/largefiles/lfutil.py @@ -551,11 +551,10 @@ def unixpath(path): def islfilesrepo(repo): '''Return true if the repo is a largefile repo.''' - if b'largefiles' in repo.requirements and any( - shortnameslash in entry.unencoded_path - for entry in repo.store.datafiles() - ): - return True + if b'largefiles' in repo.requirements: + for entry in repo.store.datafiles(): + if entry.is_revlog and shortnameslash in entry.target_id: + return True return any(openlfdirstate(repo.ui, repo, False)) diff --git a/hgext/largefiles/reposetup.py b/hgext/largefiles/reposetup.py --- a/hgext/largefiles/reposetup.py +++ b/hgext/largefiles/reposetup.py @@ -457,12 +457,16 @@ def reposetup(ui, repo): 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'