comparison hgext/lfs/wrapper.py @ 36142:60dd840a7fdb

merge: invoke scmutil.fileprefetchhooks() prior to applying updates This moves the file list calculation into core, so other extensions don't need to duplicate it.
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 11 Feb 2018 13:25:56 -0500
parents a991fcc48222
children dcb6fbaa43a8
comparison
equal deleted inserted replaced
36141:62719115875d 36142:60dd840a7fdb
249 if 'lfs' in destrepo.requirements: 249 if 'lfs' in destrepo.requirements:
250 destrepo.vfs.append('hgrc', util.tonativeeol('\n[extensions]\nlfs=\n')) 250 destrepo.vfs.append('hgrc', util.tonativeeol('\n[extensions]\nlfs=\n'))
251 251
252 def _prefetchfiles(repo, ctx, files): 252 def _prefetchfiles(repo, ctx, files):
253 """Ensure that required LFS blobs are present, fetching them as a group if 253 """Ensure that required LFS blobs are present, fetching them as a group if
254 needed. 254 needed."""
255
256 This is centralized logic for various prefetch hooks."""
257 pointers = [] 255 pointers = []
258 localstore = repo.svfs.lfslocalblobstore 256 localstore = repo.svfs.lfslocalblobstore
259 257
260 for f in files: 258 for f in files:
261 p = pointerfromctx(ctx, f) 259 p = pointerfromctx(ctx, f)
263 p.filename = f 261 p.filename = f
264 pointers.append(p) 262 pointers.append(p)
265 263
266 if pointers: 264 if pointers:
267 repo.svfs.lfsremoteblobstore.readbatch(pointers, localstore) 265 repo.svfs.lfsremoteblobstore.readbatch(pointers, localstore)
268
269 def mergemodapplyupdates(orig, repo, actions, wctx, mctx, overwrite,
270 labels=None):
271 """Ensure that the required LFS blobs are present before applying updates,
272 fetching them as a group if needed.
273
274 This has the effect of ensuring all necessary LFS blobs are present before
275 making working directory changes during an update (including after clone and
276 share) or merge."""
277
278 # Skipping 'a', 'am', 'f', 'r', 'dm', 'e', 'k', 'p' and 'pr', because they
279 # don't touch mctx. 'cd' is skipped, because changed/deleted never resolves
280 # to something from the remote side.
281 oplist = [actions[a] for a in 'g dc dg m'.split()]
282
283 _prefetchfiles(repo, mctx,
284 [f for sublist in oplist for f, args, msg in sublist])
285
286 return orig(repo, actions, wctx, mctx, overwrite, labels)
287 266
288 def _canskipupload(repo): 267 def _canskipupload(repo):
289 # if remotestore is a null store, upload is a no-op and can be skipped 268 # if remotestore is a null store, upload is a no-op and can be skipped
290 return isinstance(repo.svfs.lfsremoteblobstore, blobstore._nullremote) 269 return isinstance(repo.svfs.lfsremoteblobstore, blobstore._nullremote)
291 270