# HG changeset patch # User Matt Harbison # Date 2018-01-19 02:18:10 # Node ID 693e3bcae19eff6dbd7333f8024cc955c1111e64 # Parent b4e1d06547365da7235645074b84e690a08ba868 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. diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py --- a/hgext/lfs/__init__.py +++ b/hgext/lfs/__init__.py @@ -160,9 +160,6 @@ def reposetup(ui, repo): 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 @@ def reposetup(ui, repo): 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