Edgewall Software
Modify

Opened 5 years ago

Closed 2 years ago

#11811 closed defect (fixed)

AttributeError: 'function' object has no attribute 'warn'

Reported by: Vaclav Hapla <vaclav.hapla@…> Owned by: Christian Boos
Priority: normal Milestone: plugin - mercurial
Component: plugin/mercurial Version: 1.0dev
Severity: critical Keywords:
Cc: Branch:
Release Notes:
API Changes:

Description

How to Reproduce

While doing a GET operation on /browser, Trac issued an internal error.

Comments:

It seems that the fix [3bf996dd58c7/mercurial-plugin] fixing #11696 is not sufficient. When a warning is raised by Mercurial this error occurs - self._log is a function and thus does not have a warn method.

I am not a Python programmer. However, I installed TracMercurial using python setup.py develop -mxd and I was able to overcome this error by

  • tracext/hg/backend.py

    a b  
    188188            self._log.info('(mercurial status) %s', a)
    189189
    190190    def write_err(self, *args, **opts):
    191         for a in args:
    192             self._log.warn('(mercurial warning) %s', a)
     191        return False
     192        #for a in args:
     193        #    self._log.warn('(mercurial warning) %s', a)
    193194
    194195    def plain(self, *args, **kw):
    195196        return False # so that '[hg] hgrc' file can specify [ui] options

Local variables at line 192, in write_err:

Name Value
a 'not trusting file /var/lib/mercurial-server/repos/fllop/.hg/hgrc from ...
args ('not trusting file /var/lib/mercurial-server/repos/fllop/.hg/hgrc ...
opts {'label': ' ui.warning'}
self <tracext.hg.backend.trac_ui object at 0xa7bce0ec>

Request parameters:

{'path': '/'}

User agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36

System Information

Mercurial 3.0.1
Trac 1.0.3dev-r13216
Babel 1.3
Genshi 0.7 (with speedups)
mod_wsgi 3.3 (WSGIProcessGroup WSGIApplicationGroup %{GLOBAL})
Pygments 1.4
pysqlite 2.6.0
Python 2.7.3 (default, Feb 27 2014, 20:11:37)
[GCC 4.6.3]
pytz 2014.9
setuptools 0.6
SQLite 3.7.9
jQuery 1.7.2
jQuery UI 1.8.21
jQuery Timepicker 1.0.1

Enabled Plugins

TracAccountManager 0.5dev-r13324
TracDateField 3.0.0dev-r12118
TracMasterTickets 3.0.5dev-r13319
TracMercurial 1.0.0.3dev

Python Traceback

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0.3dev_r13216-py2.7.egg/trac/web/main.py", line 512, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0.3dev_r13216-py2.7.egg/trac/web/main.py", line 221, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0.3dev_r13216-py2.7.egg/trac/versioncontrol/web_ui/browser.py", line 398, in process_request
    context, all_repositories, order, desc)
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0.3dev_r13216-py2.7.egg/trac/versioncontrol/web_ui/browser.py", line 520, in _render_repository_index
    repos = rm.get_repository(reponame)
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0.3dev_r13216-py2.7.egg/trac/versioncontrol/api.py", line 579, in get_repository
    repoinfo.copy())
  File "/opt/srv/trac/projects/permon/plugins/mercurial-plugin-src/tracext/hg/backend.py", line 440, in get_repository
    repos = MercurialRepository(dir, params, self.log, self)
  File "/opt/srv/trac/projects/permon/plugins/mercurial-plugin-src/tracext/hg/backend.py", line 564, in __init__
    self.repo = hg.repository(ui=self.ui, path=str_path)
  File "/usr/lib/python2.7/dist-packages/mercurial/hg.py", line 119, in repository
    peer = _peerorrepo(ui, path, create)
  File "/usr/lib/python2.7/dist-packages/mercurial/hg.py", line 106, in _peerorrepo
    obj = _peerlookup(path).instance(ui, path, create)
  File "/usr/lib/python2.7/dist-packages/mercurial/localrepo.py", line 1907, in instance
    return localrepository(ui, util.urllocalpath(path), create)
  File "/usr/lib/python2.7/dist-packages/mercurial/localrepo.py", line 209, in __init__
    self.ui.readconfig(self.join("hgrc"), self.root)
  File "/usr/lib/python2.7/dist-packages/mercurial/ui.py", line 87, in readconfig
    trusted = sections or trust or self._trusted(fp, filename)
  File "/usr/lib/python2.7/dist-packages/mercurial/ui.py", line 74, in _trusted
    'user %s, group %s\n') % (f, user, group))
  File "/usr/lib/python2.7/dist-packages/mercurial/ui.py", line 714, in warn
    self.write_err(*msg, **opts)
  File "/opt/srv/trac/projects/permon/plugins/mercurial-plugin-src/tracext/hg/backend.py", line 192, in write_err
    self._log.warn('(mercurial warning) %s', a)
AttributeError: 'function' object has no attribute 'warn'

Attachments (0)

Change History (5)

comment:1 by Christian Boos, 5 years ago

Milestone: plugin - mercurial
Owner: set to Christian Boos
Status: newassigned

Can't figure what's going on yet - must try to reproduce.

comment:2 by Christian Boos, 5 years ago

Resolution: fixed
Status: assignedclosed

I indeed didn't fix #11696 properly, corrected in [94fc1af5c223/mercurial-plugin].

I also took this opportunity to make a 1.0.0.4 version.

Thanks for the report!

comment:3 by Vaclav Hapla <vaclav.hapla@…>, 5 years ago

It works now, thanks!

comment:4 by mathieu@…, 2 years ago

Resolution: fixed
Status: closedreopened

I've got the same problem with mercurial 4.2.3 and TracMercurial-0.12.0.31dev.

Applying the same patch as [94fc1af5c223/mercurial-plugin] on branch 0.12 solve the problem. Could someone do it on the official repo ?

comment:5 by Ryan J Ollos, 2 years ago

Resolution: fixed
Status: reopenedclosed

Done in [53/mercurial-plugin].

Please upgrade. We aren't maintaining 0.12 any longer.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to as closed The owner will be changed from Christian Boos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.