comparison mercurial/merge.py @ 37762:7269b87f817c

scmutil: teach the file prefetch hook to handle multiple commits The remainder of the commands that need prefetch deal with multiple revisions. I initially coded this as a separate hook, but then it needed a list of files to handle `diff` and `grep`, so it didn't seem worth keeping them separate. Not every matcher will emit bad file messages (some are built from a list of files that are known to exist). But it seems better to filter this in one place than to push this on either each caller or each hook implementation.
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 14 Apr 2018 18:50:45 -0400
parents daef13da66fe
children 1322ae04d3d7 000039f6ca2d
comparison
equal deleted inserted replaced
37761:ff6b0a20849d 37762:7269b87f817c
1463 i += 1 1463 i += 1
1464 if i > 0: 1464 if i > 0:
1465 yield i, f 1465 yield i, f
1466 1466
1467 def _prefetchfiles(repo, ctx, actions): 1467 def _prefetchfiles(repo, ctx, actions):
1468 """Invoke ``scmutil.fileprefetchhooks()`` for the files relevant to the dict 1468 """Invoke ``scmutil.prefetchfiles()`` for the files relevant to the dict
1469 of merge actions. ``ctx`` is the context being merged in.""" 1469 of merge actions. ``ctx`` is the context being merged in."""
1470 1470
1471 # Skipping 'a', 'am', 'f', 'r', 'dm', 'e', 'k', 'p' and 'pr', because they 1471 # Skipping 'a', 'am', 'f', 'r', 'dm', 'e', 'k', 'p' and 'pr', because they
1472 # don't touch the context to be merged in. 'cd' is skipped, because 1472 # don't touch the context to be merged in. 'cd' is skipped, because
1473 # changed/deleted never resolves to something from the remote side. 1473 # changed/deleted never resolves to something from the remote side.
1474 oplist = [actions[a] for a in (ACTION_GET, ACTION_DELETED_CHANGED, 1474 oplist = [actions[a] for a in (ACTION_GET, ACTION_DELETED_CHANGED,
1475 ACTION_LOCAL_DIR_RENAME_GET, ACTION_MERGE)] 1475 ACTION_LOCAL_DIR_RENAME_GET, ACTION_MERGE)]
1476 prefetch = scmutil.fileprefetchhooks 1476 prefetch = scmutil.prefetchfiles
1477 prefetch(repo, ctx, [f for sublist in oplist for f, args, msg in sublist]) 1477 matchfiles = scmutil.matchfiles
1478 prefetch(repo, [ctx.rev()],
1479 matchfiles(repo,
1480 [f for sublist in oplist for f, args, msg in sublist]))
1478 1481
1479 @attr.s(frozen=True) 1482 @attr.s(frozen=True)
1480 class updateresult(object): 1483 class updateresult(object):
1481 updatedcount = attr.ib() 1484 updatedcount = attr.ib()
1482 mergedcount = attr.ib() 1485 mergedcount = attr.ib()