Show More
@@ -69,6 +69,7 b' from . import (' | |||||
69 |
|
|
69 | pycompat, | |
70 |
|
|
70 | registrar, | |
71 |
|
|
71 | repair, | |
|
72 | repoview, | |||
72 |
|
|
73 | revlog, | |
73 |
|
|
74 | revset, | |
74 |
|
|
75 | revsetlang, | |
@@ -964,20 +965,73 b' def debugstate(ui, repo, **opts):' | |||||
964 |
|
|
965 | ), | |
965 |
|
|
966 | (b'', b'rev', [], b'restrict discovery to this set of revs'), | |
966 |
|
|
967 | (b'', b'seed', b'12323', b'specify the random seed use for discovery'), | |
|
968 | ( | |||
|
969 | b'', | |||
|
970 | b'local-as-revs', | |||
|
971 | "", | |||
|
972 | 'treat local has having these revisions only', | |||
|
973 | ), | |||
|
974 | ( | |||
|
975 | b'', | |||
|
976 | b'remote-as-revs', | |||
|
977 | "", | |||
|
978 | 'use local as remote, with only these these revisions', | |||
|
979 | ), | |||
967 |
|
|
980 | ] | |
968 |
|
|
981 | + cmdutil.remoteopts, | |
969 |
|
|
982 | _(b'[--rev REV] [OTHER]'), | |
970 |
|
|
983 | ) | |
971 |
|
|
984 | def debugdiscovery(ui, repo, remoteurl=b"default", **opts): | |
972 |
|
|
985 | """runs the changeset discovery protocol in isolation | |
|
986 | ||||
|
987 | The local peer can be "replaced" by a subset of the local repository by | |||
|
988 | using the `--local-as-revs` flag. Int he same way, usual `remote` peer can | |||
|
989 | be "replaced" by a subset of the local repository using the | |||
|
990 | `--local-as-revs` flag. This is useful to efficiently debug pathological | |||
|
991 | discovery situation. | |||
|
992 | """ | |||
973 |
|
|
993 | opts = pycompat.byteskwargs(opts) | |
974 | remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl)) |
|
994 | unfi = repo.unfiltered() | |
975 | remote = hg.peer(repo, opts, remoteurl) |
|
995 | ||
976 | ui.status(_(b'comparing with %s\n') % util.hidepassword(remoteurl)) |
|
996 | # setup potential extra filtering | |
|
997 | local_revs = opts[b"local_as_revs"] | |||
|
998 | remote_revs = opts[b"remote_as_revs"] | |||
977 |
|
999 | |||
978 |
|
|
1000 | # make sure tests are repeatable | |
979 |
|
|
1001 | random.seed(int(opts[b'seed'])) | |
980 |
|
1002 | |||
|
1003 | if not remote_revs: | |||
|
1004 | ||||
|
1005 | remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl)) | |||
|
1006 | remote = hg.peer(repo, opts, remoteurl) | |||
|
1007 | ui.status(_(b'comparing with %s\n') % util.hidepassword(remoteurl)) | |||
|
1008 | else: | |||
|
1009 | branches = (None, []) | |||
|
1010 | remote_filtered_revs = scmutil.revrange( | |||
|
1011 | unfi, [b"not (::(%s))" % remote_revs] | |||
|
1012 | ) | |||
|
1013 | remote_filtered_revs = frozenset(remote_filtered_revs) | |||
|
1014 | ||||
|
1015 | def remote_func(x): | |||
|
1016 | return remote_filtered_revs | |||
|
1017 | ||||
|
1018 | repoview.filtertable[b'debug-discovery-remote-filter'] = remote_func | |||
|
1019 | ||||
|
1020 | remote = repo.peer() | |||
|
1021 | remote._repo = remote._repo.filtered(b'debug-discovery-remote-filter') | |||
|
1022 | ||||
|
1023 | if local_revs: | |||
|
1024 | local_filtered_revs = scmutil.revrange( | |||
|
1025 | unfi, [b"not (::(%s))" % local_revs] | |||
|
1026 | ) | |||
|
1027 | local_filtered_revs = frozenset(local_filtered_revs) | |||
|
1028 | ||||
|
1029 | def local_func(x): | |||
|
1030 | return local_filtered_revs | |||
|
1031 | ||||
|
1032 | repoview.filtertable[b'debug-discovery-local-filter'] = local_func | |||
|
1033 | repo = repo.filtered(b'debug-discovery-local-filter') | |||
|
1034 | ||||
981 |
|
|
1035 | data = {} | |
982 |
|
|
1036 | if opts.get(b'old'): | |
983 |
|
1037 |
@@ -283,7 +283,7 b' Show all commands + options' | |||||
283 | debugdate: extended |
|
283 | debugdate: extended | |
284 | debugdeltachain: changelog, manifest, dir, template |
|
284 | debugdeltachain: changelog, manifest, dir, template | |
285 | debugdirstate: nodates, dates, datesort |
|
285 | debugdirstate: nodates, dates, datesort | |
286 | debugdiscovery: old, nonheads, rev, seed, ssh, remotecmd, insecure |
|
286 | debugdiscovery: old, nonheads, rev, seed, local-as-revs, remote-as-revs, ssh, remotecmd, insecure | |
287 | debugdownload: output |
|
287 | debugdownload: output | |
288 | debugextensions: template |
|
288 | debugextensions: template | |
289 | debugfileset: rev, all-files, show-matcher, show-stage |
|
289 | debugfileset: rev, all-files, show-matcher, show-stage |
@@ -1588,3 +1588,139 b' returned as common heads.' | |||||
1588 | common: 0 |
|
1588 | common: 0 | |
1589 | missing: 1 |
|
1589 | missing: 1 | |
1590 | common heads: 66f7d451a68b |
|
1590 | common heads: 66f7d451a68b | |
|
1591 | ||||
|
1592 | $ cd .. | |||
|
1593 | ||||
|
1594 | ||||
|
1595 | Test debuging discovery using different subset of the same repository | |||
|
1596 | ===================================================================== | |||
|
1597 | ||||
|
1598 | remote is a local subset | |||
|
1599 | ------------------------ | |||
|
1600 | ||||
|
1601 | remote will be last 25 heads of the local graph | |||
|
1602 | ||||
|
1603 | $ cd $TESTTMP/manyheads | |||
|
1604 | $ hg -R a debugdiscovery \ | |||
|
1605 | > --debug \ | |||
|
1606 | > --remote-as-revs 'last(heads(all()), 25)' \ | |||
|
1607 | > --config devel.discovery.randomize=false | |||
|
1608 | query 1; heads | |||
|
1609 | searching for changes | |||
|
1610 | all remote heads known locally | |||
|
1611 | elapsed time: * seconds (glob) | |||
|
1612 | round-trips: 1 | |||
|
1613 | heads summary: | |||
|
1614 | total common heads: 25 | |||
|
1615 | also local heads: 25 | |||
|
1616 | also remote heads: 25 | |||
|
1617 | both: 25 | |||
|
1618 | local heads: 260 | |||
|
1619 | common: 25 | |||
|
1620 | missing: 235 | |||
|
1621 | remote heads: 25 | |||
|
1622 | common: 25 | |||
|
1623 | unknown: 0 | |||
|
1624 | local changesets: 1340 | |||
|
1625 | common: 400 | |||
|
1626 | heads: 25 | |||
|
1627 | roots: 1 | |||
|
1628 | missing: 940 | |||
|
1629 | heads: 235 | |||
|
1630 | roots: 235 | |||
|
1631 | first undecided set: 940 | |||
|
1632 | heads: 235 | |||
|
1633 | roots: 235 | |||
|
1634 | common: 0 | |||
|
1635 | missing: 940 | |||
|
1636 | common heads: 0dfd965d91c6 0fe09b60448d 14a17233ce9d 175c0a3072cf 1c51e2c80832 1e51600e0698 24eb5f9bdbab 25ce09526613 36bd00abde57 426989fdefa0 596d87362679 5dd1039ea5c0 5ef24f022278 5f230dc19419 80b39998accb 88f40688ffb5 9e37ddf8c632 abf4d55b075e b2ce801fddfe b368b6ac3ce3 c959bf2e869c c9fba6ba4e2e d783207cf649 d9a51e256f21 e3717a4e3753 | |||
|
1637 | ||||
|
1638 | local is a local subset | |||
|
1639 | ------------------------ | |||
|
1640 | ||||
|
1641 | remote will be last 25 heads of the local graph | |||
|
1642 | ||||
|
1643 | $ cd $TESTTMP/manyheads | |||
|
1644 | $ hg -R a debugdiscovery b \ | |||
|
1645 | > --debug \ | |||
|
1646 | > --local-as-revs 'first(heads(all()), 25)' \ | |||
|
1647 | > --config devel.discovery.randomize=false | |||
|
1648 | comparing with b | |||
|
1649 | query 1; heads | |||
|
1650 | searching for changes | |||
|
1651 | taking quick initial sample | |||
|
1652 | query 2; still undecided: 375, sample size is: 81 | |||
|
1653 | sampling from both directions | |||
|
1654 | query 3; still undecided: 3, sample size is: 3 | |||
|
1655 | 3 total queries *s (glob) | |||
|
1656 | elapsed time: * seconds (glob) | |||
|
1657 | round-trips: 3 | |||
|
1658 | heads summary: | |||
|
1659 | total common heads: 1 | |||
|
1660 | also local heads: 0 | |||
|
1661 | also remote heads: 0 | |||
|
1662 | both: 0 | |||
|
1663 | local heads: 25 | |||
|
1664 | common: 0 | |||
|
1665 | missing: 25 | |||
|
1666 | remote heads: 1 | |||
|
1667 | common: 0 | |||
|
1668 | unknown: 1 | |||
|
1669 | local changesets: 400 | |||
|
1670 | common: 300 | |||
|
1671 | heads: 1 | |||
|
1672 | roots: 1 | |||
|
1673 | missing: 100 | |||
|
1674 | heads: 25 | |||
|
1675 | roots: 25 | |||
|
1676 | first undecided set: 400 | |||
|
1677 | heads: 25 | |||
|
1678 | roots: 1 | |||
|
1679 | common: 300 | |||
|
1680 | missing: 100 | |||
|
1681 | common heads: 3ee37d65064a | |||
|
1682 | ||||
|
1683 | both local and remove are subset | |||
|
1684 | ------------------------ | |||
|
1685 | ||||
|
1686 | remote will be last 25 heads of the local graph | |||
|
1687 | ||||
|
1688 | $ cd $TESTTMP/manyheads | |||
|
1689 | $ hg -R a debugdiscovery \ | |||
|
1690 | > --debug \ | |||
|
1691 | > --local-as-revs 'first(heads(all()), 25)' \ | |||
|
1692 | > --remote-as-revs 'last(heads(all()), 25)' \ | |||
|
1693 | > --config devel.discovery.randomize=false | |||
|
1694 | query 1; heads | |||
|
1695 | searching for changes | |||
|
1696 | taking quick initial sample | |||
|
1697 | query 2; still undecided: 375, sample size is: 81 | |||
|
1698 | sampling from both directions | |||
|
1699 | query 3; still undecided: 3, sample size is: 3 | |||
|
1700 | 3 total queries in *s (glob) | |||
|
1701 | elapsed time: * seconds (glob) | |||
|
1702 | round-trips: 3 | |||
|
1703 | heads summary: | |||
|
1704 | total common heads: 1 | |||
|
1705 | also local heads: 0 | |||
|
1706 | also remote heads: 0 | |||
|
1707 | both: 0 | |||
|
1708 | local heads: 25 | |||
|
1709 | common: 0 | |||
|
1710 | missing: 25 | |||
|
1711 | remote heads: 25 | |||
|
1712 | common: 0 | |||
|
1713 | unknown: 25 | |||
|
1714 | local changesets: 400 | |||
|
1715 | common: 300 | |||
|
1716 | heads: 1 | |||
|
1717 | roots: 1 | |||
|
1718 | missing: 100 | |||
|
1719 | heads: 25 | |||
|
1720 | roots: 25 | |||
|
1721 | first undecided set: 400 | |||
|
1722 | heads: 25 | |||
|
1723 | roots: 1 | |||
|
1724 | common: 300 | |||
|
1725 | missing: 100 | |||
|
1726 | common heads: 3ee37d65064a |
General Comments 0
You need to be logged in to leave comments.
Login now