Edgewall Software
Modify

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#10545 closed defect (worksforme)

Mercurial plugin fails with IndexError

Reported by: Mitar Owned by:
Priority: normal Milestone:
Component: version control Version: 0.12.2
Severity: normal Keywords: verify
Cc: mmitar@… Branch:
Release Notes:
API Changes:

Description (last modified by Christian Boos)

I am getting IndexError: list index out of range when I am trying to search Trac with Mercurial repository.

File "/usr/lib/python2.6/dist-packages/trac/web/main.py", line 511, in _dispatch_request
  dispatcher.dispatch(req)
File "/usr/lib/python2.6/dist-packages/trac/web/main.py", line 237, in dispatch
  resp = chosen_handler.process_request(req)
File "/usr/lib/python2.6/dist-packages/trac/search/web_ui.py", line 103, in process_request
  results = self._do_search(req, terms, filters)
File "/usr/lib/python2.6/dist-packages/trac/search/web_ui.py", line 208, in _do_search
  or [])
File "/usr/lib/python2.6/dist-packages/trac/versioncontrol/web_ui/changeset.py", line 1153, in get_search_results
  if 'CHANGESET_VIEW' in req.perm(cset):
File "/usr/lib/python2.6/dist-packages/trac/perm.py", line 553, in has_permission
  return self._has_permission(action, resource)
File "/usr/lib/python2.6/dist-packages/trac/perm.py", line 567, in _has_permission
  check_permission(action, perm.username, resource, perm)
File "/usr/lib/python2.6/dist-packages/trac/perm.py", line 454, in check_permission
  perm)
File "/usr/lib/python2.6/dist-packages/trac/versioncontrol/svn_authz.py", line 204, in check_permission
  changes = list(repos.get_changeset(resource.id).get_changes())
File "build/bdist.linux-x86_64/egg/tracext/hg/backend.py", line 653, in get_changeset
  return MercurialChangeset(self, self.changectx(rev))
File "build/bdist.linux-x86_64/egg/tracext/hg/backend.py", line 537, in changectx
  return self.repo[self.short_rev(rev)]
File "/usr/lib/python2.6/dist-packages/mercurial/localrepo.py", line 205, in __getitem__
  return context.changectx(self, changeid)
File "/usr/lib/python2.6/dist-packages/mercurial/context.py", line 26, in __init__
  self._node = self._repo.changelog.node(changeid)
File "/usr/lib/python2.6/dist-packages/mercurial/revlog.py", line 309, in node
  return self.index[rev][7]

To get this error I first have to change error reporting by removing

 <td><code>${shorten_line(repr(value))}</code></td>

from error.html. If I do not remove it, I get this error instead:

  File "/usr/lib/pymodules/python2.6/genshi/template/eval.py", line 178, in evaluate
    return eval(self.code, _globals, {'__data__': data})
  File "/usr/lib/python2.6/dist-packages/trac/templates/error.html", line 165, in <Expression u'shorten_line(repr(value))'>
    <td><code>${shorten_line(repr(value))}</code></td>
  File "/usr/lib/python2.6/dist-packages/mercurial/context.py", line 38, in __repr__
    return "<changectx %s>" % str(self)
  File "/usr/lib/python2.6/dist-packages/mercurial/context.py", line 32, in __str__
    return short(self.node())
  File "/usr/lib/python2.6/dist-packages/mercurial/context.py", line 101, in node
    return self._node
AttributeError: 'changectx' object has no attribute '_node'

I am using Mercurial 2.0.1 and 10899 revision of Mercurial plugin for Trac.

Attachments (0)

Change History (6)

comment:1 by Christian Boos, 8 years ago

Description: modified (diff)

Looks like a nasty one…

Btw, how did you manage to search on Mercurial changesets? ;-)

comment:2 by Mitar, 8 years ago

Hm. This thing magically disappeared now once I have played a bit more with it.

I have no idea how I managed to search on Mercurial changesets. We went from SVN to Mercurial and I just wanted to search over whole Trac for svn keyword to update URLs and such, and BAM. It blew.

BTW, description still does not render correctly.

comment:3 by Mitar, 8 years ago

It is possible that the problem was me having repository_dir set. Now I moved to repository defined through the admin interface and not config file anymore. And about there is suspicious /usr/lib/python2.6/dist-packages/trac/versioncontrol/svn_authz.py entry in the backtrace. It seems it somehow searched over Mercurial changesets through SVN?

comment:4 by Christian Boos, 8 years ago

Description: modified (diff)
Keywords: verify added

No, the svn_authz is for the AuthzSourcePolicy.

I think that simply there were still the old svn changesets in the cache, and they were associated with the repos id which is now a mercurial one. We should probably try to reproduce such a scenrio (changing type from svn to hg) and check if the advice given is correct (and see if a resync works correctly in such situation, i.e. that it removes the old svn changesets).

Sorry to still not have the DB backend for Mercurial (#8417), hence no possibility to search for now. Incidentally I'm working in this area today, but no promise as the when this might become available in a branch near you ;-)

Also, the problem you had with the repr was already mentioned in #10174 and I think that we should indeed use some kind of safe_repr in the error reporting code.

comment:5 by Christian Boos, 8 years ago

Component: plugin/mercurialversion control
Resolution: worksforme
Status: newclosed

I checked that we indeed give the advice to resync when changing the type of a repos:

You may have to run trac-admin $ENV repository resync "repoXYZ" to synchronize Trac with the repository.

comment:6 by Mitar <mmitar@…>, 8 years ago

May != must. ;-)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to as closed The owner will be changed from (none) 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.