From patchwork Fri Jan 19 02:21:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: lfs: defer registering the pre-push hook until blobs are committed From: Matt Harbison X-Patchwork-Id: 26941 Message-Id: <4e88280e794b1caafabf.1516328462@Envy> To: mercurial-devel@mercurial-scm.org Date: Thu, 18 Jan 2018 21:21:02 -0500 # HG changeset patch # User Matt Harbison # Date 1516328290 18000 # Thu Jan 18 21:18:10 2018 -0500 # Node ID 4e88280e794b1caafabf903a6afadbe0bd4402c0 # Parent 45b678bf3a787085d56fad5bee494e0c160aa120 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 @@ -156,9 +156,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): @@ -181,10 +178,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