diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py --- a/hgext/lfs/__init__.py +++ b/hgext/lfs/__init__.py @@ -237,13 +237,15 @@ def reposetup(ui, repo): if 'lfs' not in repo.requirements: def checkrequireslfs(ui, repo, **kwargs): - if 'lfs' not in repo.requirements: - last = kwargs.get(r'node_last') - _bin = node.bin - if last: - s = repo.set('%n:%n', _bin(kwargs[r'node']), _bin(last)) - else: - s = repo.set('%n', _bin(kwargs[r'node'])) + if 'lfs' in repo.requirements: + return 0 + + last = kwargs.get(r'node_last') + _bin = node.bin + if last: + s = repo.set('%n:%n', _bin(kwargs[r'node']), _bin(last)) + else: + s = repo.set('%n', _bin(kwargs[r'node'])) match = repo.narrowmatch() for ctx in s: # TODO: is there a way to just walk the files in the commit? diff --git a/tests/test-lfs-serve.t b/tests/test-lfs-serve.t --- a/tests/test-lfs-serve.t +++ b/tests/test-lfs-serve.t @@ -244,6 +244,30 @@ should have an 'lfs' requirement after i $TESTTMP/client3_pull/.hg/requires:lfs (lfsremote-on !) $TESTTMP/server/.hg/requires:lfs (lfsremote-on !) +Test that the commit/changegroup requirement check hook can be run multiple +times. + + $ hg clone -qr 0 http://localhost:$HGPORT $TESTTMP/cmdserve_client3 + + $ cd ../cmdserve_client3 + + >>> from __future__ import absolute_import + >>> from hgclient import check, readchannel, runcommand + >>> @check + ... def addrequirement(server): + ... readchannel(server) + ... # change the repo in a way that adds the lfs requirement + ... runcommand(server, ['pull', '-qu']) + ... # Now cause the requirement adding hook to fire again, without going + ... # through reposetup() again. + ... with open('file.txt', 'wb') as fp: + ... fp.write('data') + ... runcommand(server, ['ci', '-Aqm', 'non-lfs']) + *** runcommand pull -qu + *** runcommand ci -Aqm non-lfs + + $ cd ../client + The difference here is the push failed above when the extension isn't enabled on the server. $ hg identify http://localhost:$HGPORT