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

login
register
mail settings
Submitter via Mercurial-devel
Date July 30, 2018, 4:46 p.m.
Message ID <CAESOdVAajd6_aoiQuU1ibqZCpQcNuN1-t3fxM-m-o7XAWPq1dg@mail.gmail.com>
Download mbox | patch
Permalink /patch/32973/
State New
Headers show

Comments

via Mercurial-devel - July 30, 2018, 4:46 p.m.
I'll queue with the following folded in:

                     if len(checkout) == 20 and checkout in destrepo:
                         uprev = checkout
                     elif scmutil.isrevsymbol(destrepo, checkout):


On Mon, Jul 30, 2018 at 7:41 AM Boris Feld <boris.feld@octobus.net> wrote:

> # 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.
>
> 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:
>
Boris Feld - July 31, 2018, 10:10 a.m.
On 30/07/2018 18:46, Martin von Zweigbergk via Mercurial-devel wrote:
> I'll queue with the following folded in:

Perfect, thanks
>
> diff --git a/mercurial/hg.py b/mercurial/hg.py
> --- a/mercurial/hg.py
> +++ b/mercurial/hg.py
> @@ -731,6 +731,10 @@ def clone(ui, peeropts, source, dest=Non
>                  uprev = None
>                  status = None
>                  if checkout is not None:
> +                    # 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):
>
>
> On Mon, Jul 30, 2018 at 7:41 AM Boris Feld <boris.feld@octobus.net 
> <mailto:boris.feld@octobus.net>> wrote:
>
>     # HG changeset patch
>     # User Boris Feld <boris.feld@octobus.net
>     <mailto: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.
>
>     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:
>
>
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -731,6 +731,10 @@  def clone(ui, peeropts, source, dest=Non
                 uprev = None
                 status = None
                 if checkout is not None:
+                    # 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.