[Bug 5137] New: AttributeError: 'function' object has no attribute 'norepo'

mercurial-bugs at selenic.com mercurial-bugs at selenic.com
Fri Mar 11 19:13:51 EST 2016


            Bug ID: 5137
           Summary: AttributeError: 'function' object has no attribute
           Product: Mercurial
           Version: default branch
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: bug
          Priority: normal
         Component: mq
          Assignee: bugzilla at selenic.com
          Reporter: gregory.szorc at gmail.com
                CC: mercurial-devel at selenic.com

Pulled down latest @ (1c658391b22f) and I immediately got crashes because I had
the MQ extension loaded:

Traceback (most recent call last):
  File "/Users/gps/bin/hg", line 43, in <module>
  File "/Users/gps/lib/python2.7/site-packages/mercurial/dispatch.py", line 54,
in run
    sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
  File "/Users/gps/lib/python2.7/site-packages/mercurial/dispatch.py", line
120, in dispatch
    ret = _runcatch(req)
  File "/Users/gps/lib/python2.7/site-packages/mercurial/dispatch.py", line
191, in _runcatch
    return _dispatch(req)
  File "/Users/gps/lib/python2.7/site-packages/mercurial/dispatch.py", line
767, in _dispatch
  File "/Users/gps/lib/python2.7/site-packages/mercurial/extensions.py", line
150, in loadall
  File "/Users/gps/lib/python2.7/site-packages/hgext/mq.py", line 3576, in
    dotable(getattr(extmodule, 'cmdtable', {}))
  File "/Users/gps/lib/python2.7/site-packages/hgext/mq.py", line 3567, in
    if func.norepo:
AttributeError: 'function' object has no attribute 'norepo'

The stack is deceiving in that it points to an error in the MQ extension.
However, the underlying problem is an old extension I have loaded that is
assigning to cmdtable directly instead of going through the decorator. e.g.

cmdtable = {
    'newbug': (newbug,
        [('c', 'comment', '', 'Comment to add with the bug'),
         ('e', 'edit', False,
          'Open a text editor to modify bug fields'),
         ('i', 'interactive', False,
          'Interactive -- request confirmation before any permanent action'),
         ('f', 'force', False,
          'Proceed even if the working directory contains changes'),
         ('', 'take-bug', False,
          'Assign bug to myself'),
         ] + newbug_opts,
        _('hg newbug [-e] [[-t] TITLE] [[-c] COMMENT]')),

I know we broke API compatibility with the refactor to commands registration
and the old extension deserves to break. However, I think the user experience
of crashing on every command invocation is a bit much.

I think the extension loader should verify that functions in cmdtable have the
attributes added by @cmdutil.command. If they don't, it can add them or we
could potentially refuse to load the extension.

You are receiving this mail because:
You are on the CC list for the bug.

More information about the Mercurial-devel mailing list