lfs: defer registering the pre-push hook until blobs are committed
The hook searches outgoing commits for blobs, and uploads them before letting
the push occur. No reason to search for that which isn't there.
--- a/hgext/lfs/__init__.py Thu Jan 18 18:04:56 2018 -0500
+++ b/hgext/lfs/__init__.py Thu Jan 18 21:18:10 2018 -0500
@@ -160,9 +160,6 @@
repo.svfs.lfslocalblobstore = blobstore.local(repo)
repo.svfs.lfsremoteblobstore = blobstore.remote(repo)
- # Push hook
- repo.prepushoutgoinghooks.add('lfs', wrapper.prepush)
-
class lfsrepo(repo.__class__):
@localrepo.unfilteredmethod
def commitctx(self, ctx, error=False):
@@ -185,10 +182,13 @@
if any(ctx[f].islfs() for f in ctx.files() if f in ctx):
repo.requirements.add('lfs')
repo._writerequirements()
+ repo.prepushoutgoinghooks.add('lfs', wrapper.prepush)
break
ui.setconfig('hooks', 'commit.lfs', checkrequireslfs, 'lfs')
ui.setconfig('hooks', 'pretxnchangegroup.lfs', checkrequireslfs, 'lfs')
+ else:
+ repo.prepushoutgoinghooks.add('lfs', wrapper.prepush)
def _trackedmatcher(repo, ctx):
"""Return a function (path, size) -> bool indicating whether or not to