Mercurial > public > mercurial-scm > hg
comparison mercurial/merge.py @ 45518:32ce4cbaec4b
mergedriver: delete it
The merge driver code was added in late 2015. I think
'406a654b::6f045b56 & user("sid0")' is a reasonable revset for finding
the relevant commits, including preparation for it. The code is very
poorly tested, which makes it very hard to maintain. It seems it's
only used by FB and they don't use this code base anymore, so let's
remove the code to make it easier for us to maintain our product.
Differential Revision: https://phab.mercurial-scm.org/D9041
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 17 Sep 2020 22:34:36 -0700 |
parents | 19590b126764 |
children | 6877b0ee5f9d |
comparison
equal
deleted
inserted
replaced
45517:2a68a5ec8dd0 | 45518:32ce4cbaec4b |
---|---|
351 % (lastfull, f) | 351 % (lastfull, f) |
352 ) | 352 ) |
353 foldprefix = fold + b'/' | 353 foldprefix = fold + b'/' |
354 unfoldprefix = f + b'/' | 354 unfoldprefix = f + b'/' |
355 lastfull = f | 355 lastfull = f |
356 | |
357 | |
358 def driverpreprocess(repo, ms, wctx, labels=None): | |
359 """run the preprocess step of the merge driver, if any | |
360 | |
361 This is currently not implemented -- it's an extension point.""" | |
362 return True | |
363 | |
364 | |
365 def driverconclude(repo, ms, wctx, labels=None): | |
366 """run the conclude step of the merge driver, if any | |
367 | |
368 This is currently not implemented -- it's an extension point.""" | |
369 return True | |
370 | 356 |
371 | 357 |
372 def _filesindirs(repo, manifest, dirs): | 358 def _filesindirs(repo, manifest, dirs): |
373 """ | 359 """ |
374 Generator that yields pairs of all the files in the manifest that are found | 360 Generator that yields pairs of all the files in the manifest that are found |
1603 mergestatemod.ACTION_EXEC, | 1589 mergestatemod.ACTION_EXEC, |
1604 mergestatemod.ACTION_LOCAL_DIR_RENAME_GET, | 1590 mergestatemod.ACTION_LOCAL_DIR_RENAME_GET, |
1605 mergestatemod.ACTION_DIR_RENAME_MOVE_LOCAL, | 1591 mergestatemod.ACTION_DIR_RENAME_MOVE_LOCAL, |
1606 ) | 1592 ) |
1607 ) | 1593 ) |
1608 # the ordering is important here -- ms.mergedriver will raise if the merge | |
1609 # driver has changed, and we want to be able to bypass it when overwrite is | |
1610 # True | |
1611 usemergedriver = not overwrite and mergeactions and ms.mergedriver | |
1612 | |
1613 if usemergedriver: | |
1614 ms.commit() | |
1615 proceed = driverpreprocess(repo, ms, wctx, labels=labels) | |
1616 # the driver might leave some files unresolved | |
1617 unresolvedf = set(ms.unresolved()) | |
1618 if not proceed: | |
1619 # XXX setting unresolved to at least 1 is a hack to make sure we | |
1620 # error out | |
1621 return updateresult( | |
1622 updated, merged, removed, max(len(unresolvedf), 1) | |
1623 ) | |
1624 newactions = [] | |
1625 for f, args, msg in mergeactions: | |
1626 if f in unresolvedf: | |
1627 newactions.append((f, args, msg)) | |
1628 mergeactions = newactions | |
1629 | 1594 |
1630 try: | 1595 try: |
1631 # premerge | 1596 # premerge |
1632 tocomplete = [] | 1597 tocomplete = [] |
1633 for f, args, msg in mergeactions: | 1598 for f, args, msg in mergeactions: |
1653 finally: | 1618 finally: |
1654 ms.commit() | 1619 ms.commit() |
1655 | 1620 |
1656 unresolved = ms.unresolvedcount() | 1621 unresolved = ms.unresolvedcount() |
1657 | 1622 |
1658 if ( | |
1659 usemergedriver | |
1660 and not unresolved | |
1661 and ms.mdstate() != mergestatemod.MERGE_DRIVER_STATE_SUCCESS | |
1662 ): | |
1663 if not driverconclude(repo, ms, wctx, labels=labels): | |
1664 # XXX setting unresolved to at least 1 is a hack to make sure we | |
1665 # error out | |
1666 unresolved = max(unresolved, 1) | |
1667 | |
1668 ms.commit() | |
1669 | |
1670 msupdated, msmerged, msremoved = ms.counts() | 1623 msupdated, msmerged, msremoved = ms.counts() |
1671 updated += msupdated | 1624 updated += msupdated |
1672 merged += msmerged | 1625 merged += msmerged |
1673 removed += msremoved | 1626 removed += msremoved |
1674 | 1627 |
1675 extraactions = ms.actions() | 1628 extraactions = ms.actions() |
1676 if extraactions: | 1629 if extraactions: |
1677 mfiles = { | |
1678 a[0] for a in mresult.getactions((mergestatemod.ACTION_MERGE,)) | |
1679 } | |
1680 for k, acts in pycompat.iteritems(extraactions): | 1630 for k, acts in pycompat.iteritems(extraactions): |
1681 for a in acts: | 1631 for a in acts: |
1682 mresult.addfile(a[0], k, *a[1:]) | 1632 mresult.addfile(a[0], k, *a[1:]) |
1683 if k == mergestatemod.ACTION_GET and wantfiledata: | 1633 if k == mergestatemod.ACTION_GET and wantfiledata: |
1684 # no filedata until mergestate is updated to provide it | 1634 # no filedata until mergestate is updated to provide it |
1685 for a in acts: | 1635 for a in acts: |
1686 getfiledata[a[0]] = None | 1636 getfiledata[a[0]] = None |
1687 # Remove these files from actions[ACTION_MERGE] as well. This is | |
1688 # important because in recordupdates, files in actions[ACTION_MERGE] | |
1689 # are processed after files in other actions, and the merge driver | |
1690 # might add files to those actions via extraactions above. This can | |
1691 # lead to a file being recorded twice, with poor results. This is | |
1692 # especially problematic for actions[ACTION_REMOVE] (currently only | |
1693 # possible with the merge driver in the initial merge process; | |
1694 # interrupted merges don't go through this flow). | |
1695 # | |
1696 # The real fix here is to have indexes by both file and action so | |
1697 # that when the action for a file is changed it is automatically | |
1698 # reflected in the other action lists. But that involves a more | |
1699 # complex data structure, so this will do for now. | |
1700 # | |
1701 # We don't need to do the same operation for 'dc' and 'cd' because | |
1702 # those lists aren't consulted again. | |
1703 mfiles.difference_update(a[0] for a in acts) | |
1704 | |
1705 for a in list(mresult.getactions((mergestatemod.ACTION_MERGE,))): | |
1706 if a[0] not in mfiles: | |
1707 mresult.removefile(a[0]) | |
1708 | 1637 |
1709 progress.complete() | 1638 progress.complete() |
1710 assert len(getfiledata) == ( | 1639 assert len(getfiledata) == ( |
1711 mresult.len((mergestatemod.ACTION_GET,)) if wantfiledata else 0 | 1640 mresult.len((mergestatemod.ACTION_GET,)) if wantfiledata else 0 |
1712 ) | 1641 ) |