[PATCH 3 of 3 STABLE] clone: process 'lookup' return as an arbitrary symbol

Boris Feld boris.feld at octobus.net
Thu Jul 26 12:21:20 UTC 2018


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1532595350 -7200
#      Thu Jul 26 10:55:50 2018 +0200
# Branch stable
# Node ID 88a0bf46a3ffb78aaab203d13a7c9f53e244282b
# Parent  a920f2620726ef26e6caed3d72b24297699b5b39
# EXP-Topic compat-hggit
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 88a0bf46a3ff
clone: process 'lookup' return as an arbitrary symbol

In theory, checkout is expected to be a node here because it was returned by
peer.lookup.

In practice, multiple important extensions (like hg-git, hg-subversion) use
peers not backed by a mercurial repository where lookup cannot return a node.

Allowing arbitrary symbols is necessary to make these extensions working with
4.7.

We should probably introduce a new API in Core to have these extensions to
work without abusing the lookup API. In the meantime, a small change to
restore compatibility in 4.7 seems in order.

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -730,6 +730,19 @@ def clone(ui, peeropts, source, dest=Non
 
                 uprev = None
                 status = None
+                if checkout is not None and not node.isnode(checkout):
+                    # checkout was expected to be a node here because it was
+                    # returned by peer.lookup.
+                    #
+                    # However, some extension (like hg-git) introduce peer not
+                    # backed by a mercurial repository where lookup cannot
+                    # return a node. Processing 'checkout' as an arbitrary
+                    # symbols make it possible with these extensions keep
+                    # working.
+                    if scmutil.isrevsymbol(destrepo, checkout):
+                        checkout = scmutil.revsymbol(destrepo, checkout).node()
+                    else:
+                        checkout = None
                 if checkout is not None:
                     if checkout in destrepo:
                         uprev = checkout



More information about the Mercurial-devel mailing list