Patchwork [STABLE,follow-up] clone: process 'lookup' return as an arbitrary symbol

login
register
mail settings
Submitter Boris Feld
Date July 30, 2018, 2:41 p.m.
Message ID <85b015944582ad639278.1532961670@FB-lair>
Download mbox | patch
Permalink /patch/32972/
State New
Headers show

Comments

Boris Feld - July 30, 2018, 2:41 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1532957764 -7200
#      Mon Jul 30 15:36:04 2018 +0200
# Branch stable
# Node ID 85b015944582ad63927849e253ca7077924b0ec9
# Parent  ae17555ef93fc95d800b46ccab865ea93f9951ca
# EXP-Topic compat-hggit
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 85b015944582
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.

Patch

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -731,8 +731,10 @@  def clone(ui, peeropts, source, dest=Non
                 uprev = None
                 status = None
                 if checkout is not None:
-                    if checkout in destrepo:
+                    if len(checkout) == 20 and checkout in destrepo:
                         uprev = checkout
+                    elif scmutil.isrevsymbol(destrepo, checkout):
+                        uprev = scmutil.revsymbol(destrepo, checkout).node()
                     else:
                         if update is not True:
                             try: