Mercurial > hg
comparison hgext/lfs/__init__.py @ 35735:693e3bcae19e
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.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 18 Jan 2018 21:18:10 -0500 |
parents | 10e62d5efa73 |
children | 73432eee0ac4 |
comparison
equal
deleted
inserted
replaced
35734:b4e1d0654736 | 35735:693e3bcae19e |
---|---|
158 return | 158 return |
159 | 159 |
160 repo.svfs.lfslocalblobstore = blobstore.local(repo) | 160 repo.svfs.lfslocalblobstore = blobstore.local(repo) |
161 repo.svfs.lfsremoteblobstore = blobstore.remote(repo) | 161 repo.svfs.lfsremoteblobstore = blobstore.remote(repo) |
162 | 162 |
163 # Push hook | |
164 repo.prepushoutgoinghooks.add('lfs', wrapper.prepush) | |
165 | |
166 class lfsrepo(repo.__class__): | 163 class lfsrepo(repo.__class__): |
167 @localrepo.unfilteredmethod | 164 @localrepo.unfilteredmethod |
168 def commitctx(self, ctx, error=False): | 165 def commitctx(self, ctx, error=False): |
169 repo.svfs.options['lfstrack'] = _trackedmatcher(self, ctx) | 166 repo.svfs.options['lfstrack'] = _trackedmatcher(self, ctx) |
170 return super(lfsrepo, self).commitctx(ctx, error) | 167 return super(lfsrepo, self).commitctx(ctx, error) |
183 for ctx in s: | 180 for ctx in s: |
184 # TODO: is there a way to just walk the files in the commit? | 181 # TODO: is there a way to just walk the files in the commit? |
185 if any(ctx[f].islfs() for f in ctx.files() if f in ctx): | 182 if any(ctx[f].islfs() for f in ctx.files() if f in ctx): |
186 repo.requirements.add('lfs') | 183 repo.requirements.add('lfs') |
187 repo._writerequirements() | 184 repo._writerequirements() |
185 repo.prepushoutgoinghooks.add('lfs', wrapper.prepush) | |
188 break | 186 break |
189 | 187 |
190 ui.setconfig('hooks', 'commit.lfs', checkrequireslfs, 'lfs') | 188 ui.setconfig('hooks', 'commit.lfs', checkrequireslfs, 'lfs') |
191 ui.setconfig('hooks', 'pretxnchangegroup.lfs', checkrequireslfs, 'lfs') | 189 ui.setconfig('hooks', 'pretxnchangegroup.lfs', checkrequireslfs, 'lfs') |
190 else: | |
191 repo.prepushoutgoinghooks.add('lfs', wrapper.prepush) | |
192 | 192 |
193 def _trackedmatcher(repo, ctx): | 193 def _trackedmatcher(repo, ctx): |
194 """Return a function (path, size) -> bool indicating whether or not to | 194 """Return a function (path, size) -> bool indicating whether or not to |
195 track a given file with lfs.""" | 195 track a given file with lfs.""" |
196 data = '' | 196 data = '' |