--- a/hgext/lfs/__init__.py Thu Nov 30 22:32:13 2017 +0900
+++ b/hgext/lfs/__init__.py Wed Nov 15 23:43:15 2017 -0500
@@ -37,6 +37,7 @@
exchange,
extensions,
filelog,
+ localrepo,
registrar,
revlog,
scmutil,
@@ -84,6 +85,13 @@
templatekeyword = registrar.templatekeyword()
+def featuresetup(ui, supported):
+ # don't die on seeing a repo with the lfs requirement
+ supported |= {'lfs'}
+
+def uisetup(ui):
+ localrepo.localrepository.featuresetupfuncs.add(featuresetup)
+
def reposetup(ui, repo):
# Nothing to do with a remote repo
if not repo.local():
@@ -98,6 +106,17 @@
# Push hook
repo.prepushoutgoinghooks.add('lfs', wrapper.prepush)
+ if 'lfs' not in repo.requirements:
+ def checkrequireslfs(ui, repo, **kwargs):
+ if 'lfs' not in repo.requirements:
+ ctx = repo[kwargs['node']]
+ # TODO: is there a way to just walk the files in the commit?
+ if any(ctx[f].islfs() for f in ctx.files()):
+ repo.requirements.add('lfs')
+ repo._writerequirements()
+
+ ui.setconfig('hooks', 'commit.lfs', checkrequireslfs, 'lfs')
+
def wrapfilelog(filelog):
wrapfunction = extensions.wrapfunction