indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Whether LFS is enabled seems like a useful feature to expose. This
  will also facilitate some future work around LFS feature compatibility.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/lfs/__init__.py
  hgext/lfs/wrapper.py
  mercurial/repository.py

CHANGE DETAILS

diff --git a/mercurial/repository.py b/mercurial/repository.py
--- a/mercurial/repository.py
+++ b/mercurial/repository.py
@@ -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.
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 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')
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 @@
     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)
 



To: indygreg, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to