##// END OF EJS Templates
merge: replace use of actions dict with mergeresult object...
Pulkit Goyal -
r45897:5ce63ee1 default
parent child Browse files
Show More
@@ -1352,7 +1352,6 b' def applyupdates('
1352 1352 batchget.
1353 1353 """
1354 1354
1355 actions = mresult.actionsdict
1356 1355 _prefetchfiles(repo, mctx, mresult)
1357 1356
1358 1357 updated, merged, removed = 0, 0, 0
@@ -1370,13 +1369,16 b' def applyupdates('
1370 1369 ms.addmergedother(f)
1371 1370
1372 1371 moves = []
1373 for m, l in actions.items():
1374 l.sort()
1375 1372
1376 1373 # 'cd' and 'dc' actions are treated like other merge conflicts
1377 mergeactions = sorted(actions[mergestatemod.ACTION_CHANGED_DELETED])
1378 mergeactions.extend(sorted(actions[mergestatemod.ACTION_DELETED_CHANGED]))
1379 mergeactions.extend(actions[mergestatemod.ACTION_MERGE])
1374 mergeactions = mresult.getactions(
1375 [
1376 mergestatemod.ACTION_CHANGED_DELETED,
1377 mergestatemod.ACTION_DELETED_CHANGED,
1378 mergestatemod.ACTION_MERGE,
1379 ],
1380 sort=True,
1381 )
1380 1382 for f, args, msg in mergeactions:
1381 1383 f1, f2, fa, move, anc = args
1382 1384 if f == b'.hgsubstate': # merged internally
@@ -1407,22 +1409,20 b' def applyupdates('
1407 1409 wctx[f].audit()
1408 1410 wctx[f].remove()
1409 1411
1410 numupdates = sum(
1411 len(l) for m, l in actions.items() if m != mergestatemod.ACTION_KEEP
1412 numupdates = len(mresult.actions) - len(
1413 mresult._actionmapping[mergestatemod.ACTION_KEEP]
1412 1414 )
1413 1415 progress = repo.ui.makeprogress(
1414 1416 _(b'updating'), unit=_(b'files'), total=numupdates
1415 1417 )
1416 1418
1417 if [
1418 a
1419 for a in actions[mergestatemod.ACTION_REMOVE]
1420 if a[0] == b'.hgsubstate'
1421 ]:
1419 if b'.hgsubstate' in mresult._actionmapping[mergestatemod.ACTION_REMOVE]:
1422 1420 subrepoutil.submerge(repo, wctx, mctx, wctx, overwrite, labels)
1423 1421
1424 1422 # record path conflicts
1425 for f, args, msg in actions[mergestatemod.ACTION_PATH_CONFLICT]:
1423 for f, args, msg in mresult.getactions(
1424 [mergestatemod.ACTION_PATH_CONFLICT], sort=True
1425 ):
1426 1426 f1, fo = args
1427 1427 s = repo.ui.status
1428 1428 s(
@@ -1450,14 +1450,16 b' def applyupdates('
1450 1450 cost,
1451 1451 batchremove,
1452 1452 (repo, wctx),
1453 actions[mergestatemod.ACTION_REMOVE],
1453 mresult.getactions([mergestatemod.ACTION_REMOVE], sort=True),
1454 1454 )
1455 1455 for i, item in prog:
1456 1456 progress.increment(step=i, item=item)
1457 removed = len(actions[mergestatemod.ACTION_REMOVE])
1457 removed = len(mresult._actionmapping[mergestatemod.ACTION_REMOVE])
1458 1458
1459 1459 # resolve path conflicts (must come before getting)
1460 for f, args, msg in actions[mergestatemod.ACTION_PATH_CONFLICT_RESOLVE]:
1460 for f, args, msg in mresult.getactions(
1461 [mergestatemod.ACTION_PATH_CONFLICT_RESOLVE], sort=True
1462 ):
1461 1463 repo.ui.debug(b" %s: %s -> pr\n" % (f, msg))
1462 1464 (f0, origf0) = args
1463 1465 if wctx[f0].lexists():
@@ -1476,7 +1478,7 b' def applyupdates('
1476 1478 cost,
1477 1479 batchget,
1478 1480 (repo, mctx, wctx, wantfiledata),
1479 actions[mergestatemod.ACTION_GET],
1481 mresult.getactions([mergestatemod.ACTION_GET], sort=True),
1480 1482 threadsafe=threadsafe,
1481 1483 hasretval=True,
1482 1484 )
@@ -1487,33 +1489,43 b' def applyupdates('
1487 1489 else:
1488 1490 i, item = res
1489 1491 progress.increment(step=i, item=item)
1490 updated = len(actions[mergestatemod.ACTION_GET])
1492 updated = len(mresult._actionmapping[mergestatemod.ACTION_GET])
1491 1493
1492 if [a for a in actions[mergestatemod.ACTION_GET] if a[0] == b'.hgsubstate']:
1494 if b'.hgsubstate' in mresult._actionmapping[mergestatemod.ACTION_GET]:
1493 1495 subrepoutil.submerge(repo, wctx, mctx, wctx, overwrite, labels)
1494 1496
1495 1497 # forget (manifest only, just log it) (must come first)
1496 for f, args, msg in actions[mergestatemod.ACTION_FORGET]:
1498 for f, args, msg in mresult.getactions(
1499 (mergestatemod.ACTION_FORGET,), sort=True
1500 ):
1497 1501 repo.ui.debug(b" %s: %s -> f\n" % (f, msg))
1498 1502 progress.increment(item=f)
1499 1503
1500 1504 # re-add (manifest only, just log it)
1501 for f, args, msg in actions[mergestatemod.ACTION_ADD]:
1505 for f, args, msg in mresult.getactions(
1506 (mergestatemod.ACTION_ADD,), sort=True
1507 ):
1502 1508 repo.ui.debug(b" %s: %s -> a\n" % (f, msg))
1503 1509 progress.increment(item=f)
1504 1510
1505 1511 # re-add/mark as modified (manifest only, just log it)
1506 for f, args, msg in actions[mergestatemod.ACTION_ADD_MODIFIED]:
1512 for f, args, msg in mresult.getactions(
1513 (mergestatemod.ACTION_ADD_MODIFIED,), sort=True
1514 ):
1507 1515 repo.ui.debug(b" %s: %s -> am\n" % (f, msg))
1508 1516 progress.increment(item=f)
1509 1517
1510 1518 # keep (noop, just log it)
1511 for f, args, msg in actions[mergestatemod.ACTION_KEEP]:
1519 for f, args, msg in mresult.getactions(
1520 (mergestatemod.ACTION_KEEP,), sort=True
1521 ):
1512 1522 repo.ui.debug(b" %s: %s -> k\n" % (f, msg))
1513 1523 # no progress
1514 1524
1515 1525 # directory rename, move local
1516 for f, args, msg in actions[mergestatemod.ACTION_DIR_RENAME_MOVE_LOCAL]:
1526 for f, args, msg in mresult.getactions(
1527 (mergestatemod.ACTION_DIR_RENAME_MOVE_LOCAL,), sort=True
1528 ):
1517 1529 repo.ui.debug(b" %s: %s -> dm\n" % (f, msg))
1518 1530 progress.increment(item=f)
1519 1531 f0, flags = args
@@ -1524,7 +1536,9 b' def applyupdates('
1524 1536 updated += 1
1525 1537
1526 1538 # local directory rename, get
1527 for f, args, msg in actions[mergestatemod.ACTION_LOCAL_DIR_RENAME_GET]:
1539 for f, args, msg in mresult.getactions(
1540 (mergestatemod.ACTION_LOCAL_DIR_RENAME_GET,), sort=True
1541 ):
1528 1542 repo.ui.debug(b" %s: %s -> dg\n" % (f, msg))
1529 1543 progress.increment(item=f)
1530 1544 f0, flags = args
@@ -1533,7 +1547,9 b' def applyupdates('
1533 1547 updated += 1
1534 1548
1535 1549 # exec
1536 for f, args, msg in actions[mergestatemod.ACTION_EXEC]:
1550 for f, args, msg in mresult.getactions(
1551 (mergestatemod.ACTION_EXEC,), sort=True
1552 ):
1537 1553 repo.ui.debug(b" %s: %s -> e\n" % (f, msg))
1538 1554 progress.increment(item=f)
1539 1555 (flags,) = args
@@ -1614,9 +1630,10 b' def applyupdates('
1614 1630
1615 1631 extraactions = ms.actions()
1616 1632 if extraactions:
1617 mfiles = {a[0] for a in actions[mergestatemod.ACTION_MERGE]}
1633 mfiles = {
1634 a[0] for a in mresult.getactions((mergestatemod.ACTION_MERGE,))
1635 }
1618 1636 for k, acts in pycompat.iteritems(extraactions):
1619 actions[k].extend(acts)
1620 1637 for a in acts:
1621 1638 mresult.addfile(a[0], k, *a[1:])
1622 1639 if k == mergestatemod.ACTION_GET and wantfiledata:
@@ -1641,16 +1658,15 b' def applyupdates('
1641 1658 # those lists aren't consulted again.
1642 1659 mfiles.difference_update(a[0] for a in acts)
1643 1660
1644 actions[mergestatemod.ACTION_MERGE] = [
1645 a for a in actions[mergestatemod.ACTION_MERGE] if a[0] in mfiles
1646 ]
1647 1661 for a in mresult.getactions([mergestatemod.ACTION_MERGE]):
1648 1662 if a[0] not in mfiles:
1649 1663 mresult.removefile(a[0])
1650 1664
1651 1665 progress.complete()
1652 1666 assert len(getfiledata) == (
1653 len(actions[mergestatemod.ACTION_GET]) if wantfiledata else 0
1667 len(mresult._actionmapping[mergestatemod.ACTION_GET])
1668 if wantfiledata
1669 else 0
1654 1670 )
1655 1671 return updateresult(updated, merged, removed, unresolved), getfiledata
1656 1672
General Comments 0
You need to be logged in to leave comments. Login now