# HG changeset patch # User Gregory Szorc # Date 2018-09-19 20:48:59 # Node ID 1f7b3b980af882142dfbe674e675950522dd7e0d # Parent d89d5bc06eaa60095c766419eefc058ef8b178c1 lfs: add repository feature denoting the use of LFS Whether LFS is enabled seems like a useful feature to expose. This will also facilitate some future work around LFS feature compatibility. Differential Revision: https://phab.mercurial-scm.org/D4710 diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py --- a/hgext/lfs/__init__.py +++ b/hgext/lfs/__init__.py @@ -143,6 +143,7 @@ from mercurial import ( node, pycompat, registrar, + repository, revlog, scmutil, templateutil, @@ -242,6 +243,7 @@ def reposetup(ui, repo): if any(ctx[f].islfs() for f in ctx.files() if f in ctx and match(f)): repo.requirements.add('lfs') + repo.features.add(repository.REPO_FEATURE_LFS) repo._writerequirements() repo.prepushoutgoinghooks.add('lfs', wrapper.prepush) break @@ -306,6 +308,8 @@ def extsetup(ui): wrapfunction = extensions.wrapfunction + wrapfunction(localrepo, 'makefilestorage', wrapper.localrepomakefilestorage) + wrapfunction(cmdutil, '_updatecatformatter', wrapper._updatecatformatter) wrapfunction(scmutil, 'wrapconvertsink', wrapper.convertsink) diff --git a/hgext/lfs/wrapper.py b/hgext/lfs/wrapper.py --- a/hgext/lfs/wrapper.py +++ b/hgext/lfs/wrapper.py @@ -14,6 +14,7 @@ from mercurial.node import bin, hex, nul from mercurial import ( error, + repository, revlog, util, ) @@ -29,6 +30,12 @@ from . import ( pointer, ) +def localrepomakefilestorage(orig, requirements, features, **kwargs): + if b'lfs' in requirements: + features.add(repository.REPO_FEATURE_LFS) + + return orig(requirements=requirements, features=features, **kwargs) + def allsupportedversions(orig, ui): versions = orig(ui) versions.add('03') diff --git a/mercurial/repository.py b/mercurial/repository.py --- a/mercurial/repository.py +++ b/mercurial/repository.py @@ -25,6 +25,8 @@ NARROW_REQUIREMENT = 'narrowhg-experimen REPO_FEATURE_REVLOG_FILE_STORAGE = b'revlogfilestorage' # The storage part of the repository is shared from an external source. REPO_FEATURE_SHARED_STORAGE = b'sharedstore' +# LFS supported for backing file storage. +REPO_FEATURE_LFS = b'lfs' class ipeerconnection(interfaceutil.Interface): """Represents a "connection" to a repository.