Patchwork [evolve] evolve: fix createmarkers() wrapper to accept an iterable

login
register
mail settings
Submitter Greg Ward
Date June 5, 2014, 10:09 p.m.
Message ID <12a3fc661230a3d4afb9.1402006170@queequeg.renesys.com>
Download mbox | patch
Permalink /patch/4939/
State Not Applicable
Headers show

Comments

Greg Ward - June 5, 2014, 10:09 p.m.
# HG changeset patch
# User Greg Ward <greg@gerg.ca>
# Date 1402006059 14400
#      Thu Jun 05 18:07:39 2014 -0400
# Branch stable
# Node ID 12a3fc661230a3d4afb9515ac15222c60b661bc6
# Parent  fc7ca26f74915c371f9cf2f1cfca85206edb7f55
evolve: fix createmarkers() wrapper to accept an iterable

Docstring in mercurial.obsolete says "<relations> must be an iterable
of ...", and hgsubversion takes it at its word and passes a generator.
Until around Mercurial 3.0, this did not cause any problems, but now
it does: in a repo with both evolve and hgsubversion enabled, pushing
to Subversion when obsolete changesets are present causes a crash:

  [...]
  File "/home/gward/src/hgsubversion/hgsubversion/wrappers.py", line 346, in push
    obsolete.createmarkers(repo, relations)
  File "/home/gward/src/hg-stable/mercurial/extensions.py", line 196, in wrap
    return wrapper(origfn, *args, **kwargs)
  File "/home/gward/src/hg-evolve/hgext/evolve.py", line 332, in _createmarkers
    relations[idx] = (prec, sucs, meta)
TypeError: 'generator' object does not support item assignment

Since hgsubersion is playing by the documented rules, evolve must be
the guilty party here.
Pierre-Yves David - June 5, 2014, 11:20 p.m.
Pushed, thanks!

(please next time use "evolve-ext" instead of "evolve" as a flag)

On 06/05/2014 03:09 PM, Greg Ward wrote:
> # HG changeset patch
> # User Greg Ward <greg@gerg.ca>
> # Date 1402006059 14400
> #      Thu Jun 05 18:07:39 2014 -0400
> # Branch stable
> # Node ID 12a3fc661230a3d4afb9515ac15222c60b661bc6
> # Parent  fc7ca26f74915c371f9cf2f1cfca85206edb7f55
> evolve: fix createmarkers() wrapper to accept an iterable
>
> Docstring in mercurial.obsolete says "<relations> must be an iterable
> of ...", and hgsubversion takes it at its word and passes a generator.
> Until around Mercurial 3.0, this did not cause any problems, but now
> it does: in a repo with both evolve and hgsubversion enabled, pushing
> to Subversion when obsolete changesets are present causes a crash:
>
>    [...]
>    File "/home/gward/src/hgsubversion/hgsubversion/wrappers.py", line 346, in push
>      obsolete.createmarkers(repo, relations)
>    File "/home/gward/src/hg-stable/mercurial/extensions.py", line 196, in wrap
>      return wrapper(origfn, *args, **kwargs)
>    File "/home/gward/src/hg-evolve/hgext/evolve.py", line 332, in _createmarkers
>      relations[idx] = (prec, sucs, meta)
> TypeError: 'generator' object does not support item assignment
>
> Since hgsubersion is playing by the documented rules, evolve must be
> the guilty party here.
>
> diff --git a/hgext/evolve.py b/hgext/evolve.py
> --- a/hgext/evolve.py
> +++ b/hgext/evolve.py
> @@ -331,6 +331,7 @@
>       # every time this test is run, a kitten is slain.
>       # Change it as soon as possible
>       if '[,{metadata}]' in orig.__doc__:
> +        relations = list(relations)
>           for idx, rel in enumerate(relations):
>               prec = rel[0]
>               sucs = rel[1]
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -331,6 +331,7 @@ 
     # every time this test is run, a kitten is slain.
     # Change it as soon as possible
     if '[,{metadata}]' in orig.__doc__:
+        relations = list(relations)
         for idx, rel in enumerate(relations):
             prec = rel[0]
             sucs = rel[1]