Patchwork [evolve-ext] obsdiscovery: adopt to calling convention change

login
register
mail settings
Submitter Gregory Szorc
Date Sept. 17, 2018, 4:26 p.m.
Message ID <eb8410cf882514e7db8c.1537201590@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/34732/
State New
Headers show

Comments

Gregory Szorc - Sept. 17, 2018, 4:26 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1537201528 25200
#      Mon Sep 17 09:25:28 2018 -0700
# Node ID eb8410cf882514e7db8cb1ab0ca17be6f2225135
# Parent  d3ea35ad88f35c158070077b83fa66e5f708940f
obsdiscovery: adopt to calling convention change

Upstream commits 71d83b315778 and abce899c985f changed the calling
convention of setdiscovery._takefullsample().

We inspect the signature of the function before calling it so
we can pass the proper arguments.
Boris Feld - Oct. 19, 2018, 4:06 p.m.
I was checking the in-flight patches and saw that we never acknowledge
the reception of those patches.

Thank you, they have been merged in evolve.

Sorry about the delay.

On 17/09/2018 18:26, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1537201528 25200
> #      Mon Sep 17 09:25:28 2018 -0700
> # Node ID eb8410cf882514e7db8cb1ab0ca17be6f2225135
> # Parent  d3ea35ad88f35c158070077b83fa66e5f708940f
> obsdiscovery: adopt to calling convention change
>
> Upstream commits 71d83b315778 and abce899c985f changed the calling
> convention of setdiscovery._takefullsample().
>
> We inspect the signature of the function before calling it so
> we can pass the proper arguments.
>
> diff --git a/hgext3rd/evolve/obsdiscovery.py b/hgext3rd/evolve/obsdiscovery.py
> --- a/hgext3rd/evolve/obsdiscovery.py
> +++ b/hgext3rd/evolve/obsdiscovery.py
> @@ -24,6 +24,7 @@ except ImportError:
>  
>  import hashlib
>  import heapq
> +import inspect
>  import sqlite3
>  import struct
>  import weakref
> @@ -110,7 +111,12 @@ def findcommonobsmarkers(ui, local, remo
>          if len(undecided) < fullsamplesize:
>              sample = set(undecided)
>          else:
> -            sample = _takefullsample(dag, undecided, size=fullsamplesize)
> +            # Mercurial 4.8 changed calling convention.
> +            if len(inspect.getargspec(_takefullsample)[0]) == 4:
> +                sample = _takefullsample(local, None, undecided,
> +                                         size=fullsamplesize)
> +            else:
> +                sample = _takefullsample(dag, undecided, size=fullsamplesize)
>  
>          roundtrips += 1
>          ui.progress(_("comparing with other"), totalnb - len(undecided),
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext3rd/evolve/obsdiscovery.py b/hgext3rd/evolve/obsdiscovery.py
--- a/hgext3rd/evolve/obsdiscovery.py
+++ b/hgext3rd/evolve/obsdiscovery.py
@@ -24,6 +24,7 @@  except ImportError:
 
 import hashlib
 import heapq
+import inspect
 import sqlite3
 import struct
 import weakref
@@ -110,7 +111,12 @@  def findcommonobsmarkers(ui, local, remo
         if len(undecided) < fullsamplesize:
             sample = set(undecided)
         else:
-            sample = _takefullsample(dag, undecided, size=fullsamplesize)
+            # Mercurial 4.8 changed calling convention.
+            if len(inspect.getargspec(_takefullsample)[0]) == 4:
+                sample = _takefullsample(local, None, undecided,
+                                         size=fullsamplesize)
+            else:
+                sample = _takefullsample(dag, undecided, size=fullsamplesize)
 
         roundtrips += 1
         ui.progress(_("comparing with other"), totalnb - len(undecided),