clone: process 'lookup' return as an arbitrary symbol stable
authorBoris Feld <boris.feld@octobus.net>
Mon, 30 Jul 2018 15:36:04 +0200
branchstable
changeset 38753 e06a10d3b926
parent 38752 8623a6c96998
child 38754 8b5f97ab5774
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.
mercurial/hg.py
--- a/mercurial/hg.py	Mon Jul 30 10:18:29 2018 -0400
+++ b/mercurial/hg.py	Mon Jul 30 15:36:04 2018 +0200
@@ -731,8 +731,14 @@
                 uprev = None
                 status = None
                 if checkout is not None:
-                    if checkout in destrepo:
+                    # Some extensions (at least hg-git and hg-subversion) have
+                    # a peer.lookup() implementation that returns a name instead
+                    # of a nodeid. We work around it here until we've figured
+                    # out a better solution.
+                    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: