Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/sparse.py @ 45315:30f3e278c5d7
mergeactions: use action constants instead of string values
Having constants inplace of strings like 'c', 'cm' etc. makes it easier to
understand the code.
Differential Revision: https://phab.mercurial-scm.org/D8832
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Fri, 24 Jul 2020 23:40:07 +0530 |
parents | d70c972cec74 |
children | 6a8eafaeff3b |
comparison
equal
deleted
inserted
replaced
45314:4e6a2889dd1d | 45315:30f3e278c5d7 |
---|---|
393 for file, action in pycompat.iteritems(mresult.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 == mergestatemod.ACTION_MERGE: |
399 temporaryfiles.append(file) | 399 temporaryfiles.append(file) |
400 prunedactions[file] = action | 400 prunedactions[file] = action |
401 elif branchmerge: | 401 elif branchmerge: |
402 if type != b'k': | 402 if type != mergestatemod.ACTION_KEEP: |
403 temporaryfiles.append(file) | 403 temporaryfiles.append(file) |
404 prunedactions[file] = action | 404 prunedactions[file] = action |
405 elif type == b'f': | 405 elif type == mergestatemod.ACTION_FORGET: |
406 prunedactions[file] = action | 406 prunedactions[file] = action |
407 elif file in wctx: | 407 elif file in wctx: |
408 prunedactions[file] = (b'r', args, msg) | 408 prunedactions[file] = (mergestatemod.ACTION_REMOVE, args, msg) |
409 | 409 |
410 if branchmerge and type == mergestatemod.ACTION_MERGE: | 410 if branchmerge and type == mergestatemod.ACTION_MERGE: |
411 f1, f2, fa, move, anc = args | 411 f1, f2, fa, move, anc = args |
412 if not sparsematch(f1): | 412 if not sparsematch(f1): |
413 temporaryfiles.append(f1) | 413 temporaryfiles.append(f1) |
430 if file in wctxmanifest: | 430 if file in wctxmanifest: |
431 fctx = repo[None][file] | 431 fctx = repo[None][file] |
432 actions.append((file, (fctx.flags(), False), message)) | 432 actions.append((file, (fctx.flags(), False), message)) |
433 | 433 |
434 typeactions = mergemod.emptyactions() | 434 typeactions = mergemod.emptyactions() |
435 typeactions[b'g'] = actions | 435 typeactions[mergestatemod.ACTION_GET] = actions |
436 mergemod.applyupdates( | 436 mergemod.applyupdates( |
437 repo, typeactions, repo[None], repo[b'.'], False, wantfiledata=False | 437 repo, typeactions, repo[None], repo[b'.'], False, wantfiledata=False |
438 ) | 438 ) |
439 | 439 |
440 dirstate = repo.dirstate | 440 dirstate = repo.dirstate |
451 for file in mf: | 451 for file in mf: |
452 old = oldsparsematch(file) | 452 old = oldsparsematch(file) |
453 new = sparsematch(file) | 453 new = sparsematch(file) |
454 if not old and new: | 454 if not old and new: |
455 flags = mf.flags(file) | 455 flags = mf.flags(file) |
456 prunedactions[file] = (b'g', (flags, False), b'') | 456 prunedactions[file] = ( |
457 mergestatemod.ACTION_GET, | |
458 (flags, False), | |
459 b'', | |
460 ) | |
457 elif old and not new: | 461 elif old and not new: |
458 prunedactions[file] = (b'r', [], b'') | 462 prunedactions[file] = (mergestatemod.ACTION_REMOVE, [], b'') |
459 | 463 |
460 mresult.setactions(prunedactions) | 464 mresult.setactions(prunedactions) |
461 | 465 |
462 | 466 |
463 def refreshwdir(repo, origstatus, origsparsematch, force=False): | 467 def refreshwdir(repo, origstatus, origsparsematch, force=False): |