Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/debugcommands.py @ 42031:d31d8c5279c6
debugdiscovery: small internal refactoring
The part of the code displaying statistic is made independant from the one
running the discovery. In the same do, the declaration of the discovery
function is a bit simplified.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 26 Mar 2019 14:04:33 +0100 |
parents | 6ae1a776dd1a |
children | 63165e4a76da |
comparison
equal
deleted
inserted
replaced
42030:6ae1a776dd1a | 42031:d31d8c5279c6 |
---|---|
783 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl)) | 783 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl)) |
784 | 784 |
785 # make sure tests are repeatable | 785 # make sure tests are repeatable |
786 random.seed(int(opts['seed'])) | 786 random.seed(int(opts['seed'])) |
787 | 787 |
788 def doit(pushedrevs, remoteheads, remote=remote): | 788 |
789 if opts.get('old'): | 789 |
790 if opts.get('old'): | |
791 def doit(pushedrevs, remoteheads, remote=remote): | |
790 if not util.safehasattr(remote, 'branches'): | 792 if not util.safehasattr(remote, 'branches'): |
791 # enable in-client legacy support | 793 # enable in-client legacy support |
792 remote = localrepo.locallegacypeer(remote.local()) | 794 remote = localrepo.locallegacypeer(remote.local()) |
793 common, _in, hds = treediscovery.findcommonincoming(repo, remote, | 795 common, _in, hds = treediscovery.findcommonincoming(repo, remote, |
794 force=True) | 796 force=True) |
798 " ".join(sorted(short(n) for n in common))) | 800 " ".join(sorted(short(n) for n in common))) |
799 | 801 |
800 clnode = repo.changelog.node | 802 clnode = repo.changelog.node |
801 common = repo.revs('heads(::%ln)', common) | 803 common = repo.revs('heads(::%ln)', common) |
802 common = {clnode(r) for r in common} | 804 common = {clnode(r) for r in common} |
803 else: | 805 return common, hds |
806 else: | |
807 def doit(pushedrevs, remoteheads, remote=remote): | |
804 nodes = None | 808 nodes = None |
805 if pushedrevs: | 809 if pushedrevs: |
806 revs = scmutil.revrange(repo, pushedrevs) | 810 revs = scmutil.revrange(repo, pushedrevs) |
807 nodes = [repo[r].node() for r in revs] | 811 nodes = [repo[r].node() for r in revs] |
808 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote, | 812 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote, |
809 ancestorsof=nodes) | 813 ancestorsof=nodes) |
810 common = set(common) | 814 return common, hds |
811 rheads = set(hds) | |
812 lheads = set(repo.heads()) | |
813 ui.write(("common heads: %s\n") % | |
814 " ".join(sorted(short(n) for n in common))) | |
815 if lheads <= common: | |
816 ui.write(("local is subset\n")) | |
817 elif rheads <= common: | |
818 ui.write(("remote is subset\n")) | |
819 | 815 |
820 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, revs=None) | 816 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, revs=None) |
821 localrevs = opts['rev'] | 817 localrevs = opts['rev'] |
822 doit(localrevs, remoterevs) | 818 common, hds = doit(localrevs, remoterevs) |
819 | |
820 common = set(common) | |
821 rheads = set(hds) | |
822 lheads = set(repo.heads()) | |
823 ui.write(("common heads: %s\n") % | |
824 " ".join(sorted(short(n) for n in common))) | |
825 if lheads <= common: | |
826 ui.write(("local is subset\n")) | |
827 elif rheads <= common: | |
828 ui.write(("remote is subset\n")) | |
823 | 829 |
824 _chunksize = 4 << 10 | 830 _chunksize = 4 << 10 |
825 | 831 |
826 @command('debugdownload', | 832 @command('debugdownload', |
827 [ | 833 [ |