Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/sparse.py @ 45311:d70c972cec74
sparse: pass mergeresult obj in sparse.filterupdatesactions() (API)
Not able to see much which can be improved in this function by passing in
mergeresult object but for API consistency and no function directly touching
actions dict, it sounds like a good idea.
Differential Revision: https://phab.mercurial-scm.org/D8828
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Fri, 24 Jul 2020 19:19:47 +0530 |
parents | a03c177a4679 |
children | 30f3e278c5d7 |
comparison
equal
deleted
inserted
replaced
45310:1d1f112da75c | 45311:d70c972cec74 |
---|---|
364 repo._sparsematchercache[key] = result | 364 repo._sparsematchercache[key] = result |
365 | 365 |
366 return result | 366 return result |
367 | 367 |
368 | 368 |
369 def filterupdatesactions(repo, wctx, mctx, branchmerge, actions): | 369 def filterupdatesactions(repo, wctx, mctx, branchmerge, mresult): |
370 """Filter updates to only lay out files that match the sparse rules.""" | 370 """Filter updates to only lay out files that match the sparse rules.""" |
371 if not enabled: | 371 if not enabled: |
372 return actions | 372 return |
373 | 373 |
374 oldrevs = [pctx.rev() for pctx in wctx.parents()] | 374 oldrevs = [pctx.rev() for pctx in wctx.parents()] |
375 oldsparsematch = matcher(repo, oldrevs) | 375 oldsparsematch = matcher(repo, oldrevs) |
376 | 376 |
377 if oldsparsematch.always(): | 377 if oldsparsematch.always(): |
378 return actions | 378 return |
379 | 379 |
380 files = set() | 380 files = set() |
381 prunedactions = {} | 381 prunedactions = {} |
382 | 382 |
383 if branchmerge: | 383 if branchmerge: |
388 # If we're updating, use the target context's filter, since we're | 388 # If we're updating, use the target context's filter, since we're |
389 # moving to the target context. | 389 # moving to the target context. |
390 sparsematch = matcher(repo, [mctx.rev()]) | 390 sparsematch = matcher(repo, [mctx.rev()]) |
391 | 391 |
392 temporaryfiles = [] | 392 temporaryfiles = [] |
393 for file, action in pycompat.iteritems(actions): | 393 for file, action in pycompat.iteritems(mresult.actions): |
394 type, args, msg = action | 394 type, args, msg = action |
395 files.add(file) | 395 files.add(file) |
396 if sparsematch(file): | 396 if sparsematch(file): |
397 prunedactions[file] = action | 397 prunedactions[file] = action |
398 elif type == b'm': | 398 elif type == b'm': |
455 flags = mf.flags(file) | 455 flags = mf.flags(file) |
456 prunedactions[file] = (b'g', (flags, False), b'') | 456 prunedactions[file] = (b'g', (flags, False), b'') |
457 elif old and not new: | 457 elif old and not new: |
458 prunedactions[file] = (b'r', [], b'') | 458 prunedactions[file] = (b'r', [], b'') |
459 | 459 |
460 return prunedactions | 460 mresult.setactions(prunedactions) |
461 | 461 |
462 | 462 |
463 def refreshwdir(repo, origstatus, origsparsematch, force=False): | 463 def refreshwdir(repo, origstatus, origsparsematch, force=False): |
464 """Refreshes working directory by taking sparse config into account. | 464 """Refreshes working directory by taking sparse config into account. |
465 | 465 |