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
--- a/hgext/lfs/__init__.py Wed Sep 19 14:36:57 2018 -0700
+++ b/hgext/lfs/__init__.py Wed Sep 19 13:48:59 2018 -0700
@@ -143,6 +143,7 @@
node,
pycompat,
registrar,
+ repository,
revlog,
scmutil,
templateutil,
@@ -242,6 +243,7 @@
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 @@
wrapfunction = extensions.wrapfunction
+ wrapfunction(localrepo, 'makefilestorage', wrapper.localrepomakefilestorage)
+
wrapfunction(cmdutil, '_updatecatformatter', wrapper._updatecatformatter)
wrapfunction(scmutil, 'wrapconvertsink', wrapper.convertsink)
--- a/hgext/lfs/wrapper.py Wed Sep 19 14:36:57 2018 -0700
+++ b/hgext/lfs/wrapper.py Wed Sep 19 13:48:59 2018 -0700
@@ -14,6 +14,7 @@
from mercurial import (
error,
+ repository,
revlog,
util,
)
@@ -29,6 +30,12 @@
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')
--- a/mercurial/repository.py Wed Sep 19 14:36:57 2018 -0700
+++ b/mercurial/repository.py Wed Sep 19 13:48:59 2018 -0700
@@ -25,6 +25,8 @@
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.