From patchwork Sun Apr 5 23:32:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [STABLE] discovery: avoid wrongly saying there are nothing to pull From: Pierre-Yves David X-Patchwork-Id: 46024 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Mon, 06 Apr 2020 01:32:07 +0200 # HG changeset patch # User Pierre-Yves David # Date 1586125497 -7200 # Mon Apr 06 00:24:57 2020 +0200 # Branch stable # Node ID e58f537d4c33b4d203b867eca11a1e19ae65e4b9 # Parent 3f29c5edac8e4a663f062960f65bba7bc8a26536 # EXP-Topic pull-shadow # Available At https://foss.heptapod.net/octobus/mercurial-devel/ # hg pull https://foss.heptapod.net/octobus/mercurial-devel/ -r e58f537d4c33 discovery: avoid wrongly saying there are nothing to pull We can be in a situation where a revision passed through `hg pull --rev REV`. For example the server could be during heads advertisement, to hide some pull request. Or obsolete/hidden content could be explicitly pulled. So in this case the lookup associated to `REV` returned successfully, but the normal discovery will find all advertised heads already known locally. This flip a special boolean `anyinc` that will prevent any fetch attempt, preventing `REV` to be pulled over. We add three line of code to detect this case and make sure a pull actually happens. My main target is to make some third party extensions happy (I expect the associated test to move upstream with the extension). However this fix already make some of the `infinitepush` test happier. diff --git a/mercurial/discovery.py b/mercurial/discovery.py --- a/mercurial/discovery.py +++ b/mercurial/discovery.py @@ -67,6 +67,10 @@ def findcommonincoming(repo, remote, hea ancestorsof=ancestorsof, ) common, anyinc, srvheads = res + if heads and not anyinc: + # server could be lying on the advertised heads + has_node = repo.changelog.hasnode + anyinc = any(not has_node(n) for n in heads) return (list(common), anyinc, heads or list(srvheads)) diff --git a/tests/test-infinitepush-ci.t b/tests/test-infinitepush-ci.t --- a/tests/test-infinitepush-ci.t +++ b/tests/test-infinitepush-ci.t @@ -249,12 +249,12 @@ XXX: we should show better message when $ hg pull -r b4e4bce660512ad3e71189e14588a70ac8e31fef pulling from ssh://user@dummy/repo searching for changes - no changes found adding changesets adding manifests adding file changes added 4 changesets with 4 changes to 4 files new changesets eaba929e866c:b4e4bce66051 + (run 'hg update' to get a working copy) $ hg glog o 5:b4e4bce66051 added e | public diff --git a/tests/test-infinitepush.t b/tests/test-infinitepush.t --- a/tests/test-infinitepush.t +++ b/tests/test-infinitepush.t @@ -165,3 +165,36 @@ Make sure phase on the client is public. (run 'hg heads .' to see heads, 'hg merge' to merge) $ hg log -r scratch/scratchontopofpublic -T '{phase}' draft (no-eol) + + + $ cd .. + +Try pulling explicite rev from a vanillia fresh clone + +(similar to something done with client3, but without the extension this time) + + $ hg clone ssh://user@dummy/repo client4 + requesting all changes + adding changesets + adding manifests + adding file changes + added 2 changesets with 2 changes to 2 files + new changesets 67145f466344:a79b6597f322 + updating to branch default + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + + $ cd client4 + $ cat << EOF >> .hg/hgrc + > [extensions] + > infinitepush=! + > EOF + $ hg pull -r `cat ../testpullbycommithash1` + pulling from ssh://user@dummy/repo + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 1 changes to 1 files (+1 heads) + new changesets 33910bfe6ffe (1 drafts) + (run 'hg heads' to see heads, 'hg merge' to merge) + $ cd ..