TypeError on newer versions of Mercurial

Create issue
Issue #12 resolved
manizzle NA created an issue

This extension seems to work with versions of mercurial upto and including 3.1.2. Versions 3.2 and 3.2.1 fail with the following traceback:

** Unknown exception encountered with possibly-broken third-party extension collapse
** which supports versions unknown of Mercurial.
** Please disable collapse and try your action again.
** If that fixes the bug please report it to the extension author.
** Python 2.7.8 (default, Sep 24 2014, 18:26:21) [GCC 4.9.1 20140903 (prerelease)]
** Mercurial Distributed SCM (version 3.2)
** Extensions loaded: convert, purge, graphlog, hgk, rebase, strip, mq, collapse, histedit
Traceback (most recent call last):
  File "/usr/local/bin/hg", line 43, in <module>
    mercurial.dispatch.run()
  File "/usr/local/lib/python2.7/site-packages/mercurial/dispatch.py", line 28, in run
    sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
  File "/usr/local/lib/python2.7/site-packages/mercurial/dispatch.py", line 71, in dispatch
    ret = _runcatch(req)
  File "/usr/local/lib/python2.7/site-packages/mercurial/dispatch.py", line 140, in _runcatch
    return _dispatch(req)
  File "/usr/local/lib/python2.7/site-packages/mercurial/dispatch.py", line 850, in _dispatch
    cmdpats, cmdoptions)
  File "/usr/local/lib/python2.7/site-packages/mercurial/dispatch.py", line 611, in runcommand
    ret = _runcommand(ui, options, cmd, d)
  File "/usr/local/lib/python2.7/site-packages/mercurial/dispatch.py", line 941, in _runcommand
    return checkargs()
  File "/usr/local/lib/python2.7/site-packages/mercurial/dispatch.py", line 912, in checkargs
    return cmdfunc()
  File "/usr/local/lib/python2.7/site-packages/mercurial/dispatch.py", line 847, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
  File "/usr/local/lib/python2.7/site-packages/mercurial/util.py", line 677, in check
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/mercurial/extensions.py", line 151, in wrap
    util.checksignature(origfn), *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/mercurial/util.py", line 677, in check
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/hgext/mq.py", line 3448, in mqcommand
    return orig(ui, repo, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/mercurial/util.py", line 677, in check
    return func(*args, **kwargs)
  File "/home/manizzle/.hgext/hgcollapse/hgext/collapse.py", line 67, in collapse
    first = rng[0]
TypeError: 'baseset' object does not support indexing

Comments (11)

  1. Peer Stritzinger repo owner

    Patches welcome, I'm very busy at the moment and can't investigate this currently

  2. hokorobi hokorobi

    Hi.

    diff -r b42d3b57df3a hgext/collapse.py
    --- a/hgext/collapse.py Tue Nov 13 18:05:58 2012 +0100
    +++ b/hgext/collapse.py Sat Nov 29 15:23:41 2014 +0900
    @@ -64,8 +64,12 @@
                 # FIXME FIXME: rework ui to make the distinction between auto
                 # and not unnecessary.  Integrate revsets (event disjoint)
    
    -            first = rng[0]
    -            last = rng[-1]
    +            if hasattr(rng, 'first'):
    +                first = rng.first()
    +                last = rng.last()
    +            else:
    +                first = rng[0]
    +                last = rng[-1]
                 revs = inbetween(repo, first, last)
    
                 if not revs:
    
  3. Peer Stritzinger repo owner

    Hi hokorobi what was the problem with your Pull request?

    I'd love to pull a fix for this since I have currently no time to fix myself

  4. abuechle

    Hi,

    applying hokorobis patch I still get an error:

    ** Unknown exception encountered with possibly-broken third-party extension collapse
    ** which supports versions unknown of Mercurial.
    ** Please disable collapse and try your action again.
    ** If that fixes the bug please report it to the extension author.
    ** Python 2.7.6 (default, Sep  9 2014, 15:04:36) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)]
    ** Mercurial Distributed SCM (version 3.2.1)
    ** Extensions loaded: shelve, collapse, mercurial_keyring, graphlog
    Traceback (most recent call last):
      File "/usr/local/bin/hg", line 43, in <module>
        mercurial.dispatch.run()
      File "/usr/local/Cellar/mercurial/3.2.1/lib/python2.7/site-packages/mercurial/dispatch.py", line 28, in run
        sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
      File "/usr/local/Cellar/mercurial/3.2.1/lib/python2.7/site-packages/mercurial/dispatch.py", line 71, in dispatch
        ret = _runcatch(req)
      File "/usr/local/Cellar/mercurial/3.2.1/lib/python2.7/site-packages/mercurial/dispatch.py", line 140, in _runcatch
        return _dispatch(req)
      File "/usr/local/Cellar/mercurial/3.2.1/lib/python2.7/site-packages/mercurial/dispatch.py", line 850, in _dispatch
        cmdpats, cmdoptions)
      File "/usr/local/Cellar/mercurial/3.2.1/lib/python2.7/site-packages/mercurial/dispatch.py", line 611, in runcommand
        ret = _runcommand(ui, options, cmd, d)
      File "/usr/local/Cellar/mercurial/3.2.1/lib/python2.7/site-packages/mercurial/dispatch.py", line 941, in _runcommand
        return checkargs()
      File "/usr/local/Cellar/mercurial/3.2.1/lib/python2.7/site-packages/mercurial/dispatch.py", line 912, in checkargs
        return cmdfunc()
      File "/usr/local/Cellar/mercurial/3.2.1/lib/python2.7/site-packages/mercurial/dispatch.py", line 847, in <lambda>
        d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
      File "/usr/local/Cellar/mercurial/3.2.1/lib/python2.7/site-packages/mercurial/util.py", line 677, in check
        return func(*args, **kwargs)
      File "/Users/andi/dev/bin/hg-extensions/hgcollapse/hgext/collapse.py", line 82, in collapse
        opts)
      File "/Users/andi/dev/bin/hg-extensions/hgcollapse/hgext/collapse.py", line 177, in do_collapse
        parent_hgtags, movelog, debug_delay)
      File "/Users/andi/dev/bin/hg-extensions/hgcollapse/hgext/collapse.py", line 275, in movedescendants
        repo.dirstate.setparents(movemap[parents[0]].node())
      File "/usr/local/Cellar/mercurial/3.2.1/lib/python2.7/site-packages/mercurial/dirstate.py", line 261, in setparents
        raise ValueError("cannot set dirstate parent without "
    ValueError: cannot set dirstate parent without calling dirstate.beginparentchange
    

    Regards, Andi

  5. hokorobi hokorobi

    Hi, Andi.

    How about with this?

    diff -r 062ebb117dc0 -r e88987f9f0ad hgext/collapse.py
    --- a/hgext/collapse.py Sat Nov 29 15:23:41 2014 +0900
    +++ b/hgext/collapse.py Wed Dec 17 21:47:26 2014 +0900
    @@ -268,6 +268,8 @@
                 assert phex in tagsmap
                 tagsmap[nodehex] = tagsmap[phex]
             else:
    +            if hasattr(repo.dirstate, 'beginparentchange'):
    +                repo.dirstate.beginparentchange()
                 if len(parents) == 1:
                     ui.debug(_('setting parent to %d\n')
                              % movemap[parents[0]].rev())
    @@ -282,7 +284,9 @@
                                                         parents[1]).node())
    
                 repo.dirstate.write()
    -
    +            if hasattr(repo.dirstate, 'endparentchange'):
    +                repo.dirstate.endparentchange()
    +
                 ui.debug(_('reverting to revision %d\n') % r)
                 recreaterev(ui, repo, r)
    
  6. Peer Stritzinger repo owner

    Hi Dan,

    yes I was planning to merge this after I gave a chance to try it and make sure the tests pass. Just swamped with work ATM so slow

    Cheers, -- Peer

  7. Gabriel Ganam

    @hokorobi

    I have this exact same error, and the fix doesn’t work for me, since “repo.dirstate” has no 'beginparentchange' attribute.

    Can you help?

  8. Log in to comment