Mercurial > public > mercurial-scm > hg
comparison mercurial/debugcommands.py @ 35304:f77121b6bf1b
setdiscover: allow to ignore part of the local graph
Currently, the push discovery first determines the full set of common nodes
before looking into what changesets are outgoing. When pushing a specific
subset, this can lead to pathological situations where we search for the status
of thousand of local heads that are unrelated to the requested pushes.
To fix this, we need to teach the discovery to ignores part of the graph. Most
of the necessary pieces were already in place. This changeset just makes them
available to higher level API and tests them.
Change actually impacting pushes are coming in a later changeset.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Wed, 06 Dec 2017 22:44:51 +0100 |
parents | d4b108fdf423 |
children | c3e4f196b6e0 |
comparison
equal
deleted
inserted
replaced
35303:67b7e39b441b | 35304:f77121b6bf1b |
---|---|
732 | 732 |
733 @command('debugdiscovery', | 733 @command('debugdiscovery', |
734 [('', 'old', None, _('use old-style discovery')), | 734 [('', 'old', None, _('use old-style discovery')), |
735 ('', 'nonheads', None, | 735 ('', 'nonheads', None, |
736 _('use old-style discovery with non-heads included')), | 736 _('use old-style discovery with non-heads included')), |
737 ('', 'rev', [], 'restrict discovery to this set of revs'), | |
737 ] + cmdutil.remoteopts, | 738 ] + cmdutil.remoteopts, |
738 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]')) | 739 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]')) |
739 def debugdiscovery(ui, repo, remoteurl="default", **opts): | 740 def debugdiscovery(ui, repo, remoteurl="default", **opts): |
740 """runs the changeset discovery protocol in isolation""" | 741 """runs the changeset discovery protocol in isolation""" |
741 opts = pycompat.byteskwargs(opts) | 742 opts = pycompat.byteskwargs(opts) |
745 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl)) | 746 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl)) |
746 | 747 |
747 # make sure tests are repeatable | 748 # make sure tests are repeatable |
748 random.seed(12323) | 749 random.seed(12323) |
749 | 750 |
750 def doit(localheads, remoteheads, remote=remote): | 751 def doit(pushedrevs, remoteheads, remote=remote): |
751 if opts.get('old'): | 752 if opts.get('old'): |
752 if localheads: | |
753 raise error.Abort('cannot use localheads with old style ' | |
754 'discovery') | |
755 if not util.safehasattr(remote, 'branches'): | 753 if not util.safehasattr(remote, 'branches'): |
756 # enable in-client legacy support | 754 # enable in-client legacy support |
757 remote = localrepo.locallegacypeer(remote.local()) | 755 remote = localrepo.locallegacypeer(remote.local()) |
758 common, _in, hds = treediscovery.findcommonincoming(repo, remote, | 756 common, _in, hds = treediscovery.findcommonincoming(repo, remote, |
759 force=True) | 757 force=True) |
763 " ".join(sorted(short(n) for n in common))) | 761 " ".join(sorted(short(n) for n in common))) |
764 dag = dagutil.revlogdag(repo.changelog) | 762 dag = dagutil.revlogdag(repo.changelog) |
765 all = dag.ancestorset(dag.internalizeall(common)) | 763 all = dag.ancestorset(dag.internalizeall(common)) |
766 common = dag.externalizeall(dag.headsetofconnecteds(all)) | 764 common = dag.externalizeall(dag.headsetofconnecteds(all)) |
767 else: | 765 else: |
768 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote) | 766 nodes = None |
767 if pushedrevs: | |
768 revs = scmutil.revrange(repo, pushedrevs) | |
769 nodes = [repo[r].node() for r in revs] | |
770 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote, | |
771 ancestorsof=nodes) | |
769 common = set(common) | 772 common = set(common) |
770 rheads = set(hds) | 773 rheads = set(hds) |
771 lheads = set(repo.heads()) | 774 lheads = set(repo.heads()) |
772 ui.write(("common heads: %s\n") % | 775 ui.write(("common heads: %s\n") % |
773 " ".join(sorted(short(n) for n in common))) | 776 " ".join(sorted(short(n) for n in common))) |
792 doit(parts[3].split(' '), parts[2].split(' ')) | 795 doit(parts[3].split(' '), parts[2].split(' ')) |
793 line = logfile.readline() | 796 line = logfile.readline() |
794 else: | 797 else: |
795 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, | 798 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, |
796 opts.get('remote_head')) | 799 opts.get('remote_head')) |
797 localrevs = opts.get('local_head') | 800 localrevs = opts.get('rev') |
798 doit(localrevs, remoterevs) | 801 doit(localrevs, remoterevs) |
799 | 802 |
800 @command('debugextensions', cmdutil.formatteropts, [], norepo=True) | 803 @command('debugextensions', cmdutil.formatteropts, [], norepo=True) |
801 def debugextensions(ui, **opts): | 804 def debugextensions(ui, **opts): |
802 '''show information about active extensions''' | 805 '''show information about active extensions''' |