Patchwork [STABLE,V2] discovery: avoid wrongly saying there are nothing to pull

login
register
mail settings
Submitter Pierre-Yves David
Date April 5, 2020, 11:33 p.m.
Message ID <2d761788a0f24e85d6d7.1586129608@nodosa.octobus.net>
Download mbox | patch
Permalink /patch/46025/
State Accepted
Headers show

Comments

Pierre-Yves David - April 5, 2020, 11:33 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1586125497 -7200
#      Mon Apr 06 00:24:57 2020 +0200
# Branch stable
# Node ID 2d761788a0f24e85d6d7e2784a72fa13ccf5217b
# 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 2d761788a0f2
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.
Yuya Nishihara - April 6, 2020, 1:57 p.m.
On Mon, 06 Apr 2020 01:33:28 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1586125497 -7200
> #      Mon Apr 06 00:24:57 2020 +0200
> # Branch stable
> # Node ID 2d761788a0f24e85d6d7e2784a72fa13ccf5217b
> # 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 2d761788a0f2
> discovery: avoid wrongly saying there are nothing to pull

Sounds good, queued, thanks.

Patch

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