Edgewall Software
Modify

Opened 14 years ago

Last modified 10 years ago

#10091 new defect

Exception when formatting Mercurial changeset link

Reported by: Mitar Owned by:
Priority: normal Milestone: next-major-releases
Component: plugin/mercurial Version: 0.12.2
Severity: normal Keywords: traclinks
Cc: mmitar@… Branch:
Release Notes:
API Changes:
Internal Changes:

Description

When trying to format [cset:34c7144cba5a] or [123:34c7144cba5a] when having multiple Mercurial repositories but no default repository fails with the following exception:

UnboundLocalError: local variable 'errmsg' referenced before assignment

Stack trace:

File "/usr/lib/python2.6/dist-packages/trac/ticket/templates/ticket_change.html", line 61, in <Expression u'wiki_to_html(context, change.comment, escape_newlines=preserve_newlines)'>
  <py:otherwise>${wiki_to_html(context, change.comment, escape_newlines=preserve_newlines)}</py:otherwise>
File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 1497, in format_to_html
  return HtmlFormatter(env, context, wikidom).generate(escape_newlines)
File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 1452, in generate
  escape_newlines)
File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 1240, in format
  result = re.sub(self.wikiparser.rules, self.replace, line)
File "/usr/lib/python2.6/re.py", line 151, in sub
  return _compile(pattern, 0).sub(repl, string, count)
File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 1158, in replace
  replacement = self.handle_match(fullmatch)
File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 1154, in handle_match
  return internal_handler(match, fullmatch)
File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 540, in _lhref_formatter
  return self._make_lhref_link(match, fullmatch, rel, ns, target, label)
File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 581, in _make_lhref_link
  fullmatch)
File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 590, in _make_link
  fullmatch)
File "build/bdist.linux-x86_64/egg/tracext/hg/backend.py", line 438, in _format_link
  title=errmsg, rel="nofollow")

Attachments (1)

10091-no-default-repo-10621.patch (2.0 KB ) - added by Remy Blank 14 years ago.
Suggested fix.

Download all attachments as: .zip

Change History (11)

by Remy Blank, 14 years ago

Suggested fix.

comment:1 by Remy Blank, 14 years ago

comment:2 by Mitar, 14 years ago

Now it does not crash, but it works strangely. Using [cset:34c7144cba5a] renders gray [34c7144cba5a] and tooltip says Repository '' not found. [285:34c7144cba5a] renders [285:34c7144cba5a] where only the part after the : is gray, with the same tooltip. Is this really the behavior we want? Shouldn't they be rendered equally? And shouldn't tooltip say something better, like Could not determine the repository for the changeset.

Even better it would be if the plugin would automatically find in which repository this changeset is. So that even without the default repository and without explicitly specifying in which repository the changeset is the links of the form [34c7144cba5a] would simply work. Changeset hashes are quite unique even between repositories.

in reply to:  2 comment:3 by Remy Blank, 14 years ago

Milestone: 0.13
Owner: set to Remy Blank

Replying to Mitar:

Now it does not crash, but it works strangely.

Thanks for testing. So we're not quite there yet.

Using [cset:34c7144cba5a] renders gray [34c7144cba5a] and tooltip says Repository '' not found. [285:34c7144cba5a] renders [285:34c7144cba5a] where only the part after the : is gray, with the same tooltip. Is this really the behavior we want? Shouldn't they be rendered equally?

I don't think we ever supported the [285:34c7144cba5a] syntax, so the parser only sees the 34c7144cba5a part. [34c7144cba5a] works correctly, though.

And shouldn't tooltip say something better, like Could not determine the repository for the changeset.

This assumes what you suggest below is already implemented, which it isn't. We could at least improve the message in this specific case, and say something like "No default repository defined".

Even better it would be if the plugin would automatically find in which repository this changeset is. So that even without the default repository and without explicitly specifying in which repository the changeset is the links of the form [34c7144cba5a] would simply work. Changeset hashes are quite unique even between repositories.

Yes, that's a valid enhancement request. I actually thought we did it already, but looking at the code, it seems we don't. It shouldn't be too difficult to support in Mercurial, but if you are using both Mercurial and Git repositories, only one of them would be searched, and you couldn't choose which one.

Supporting the functionality "globally" would require some support in core, so I'm targeting this for 0.13. I'll apply the fix to avoid the crash to the 0.12 branch of the plugin.

comment:4 by Mitar, 14 years ago

Yes, I also thought this is already working. ;-) This is why I tried cset prefix thinking that maybe then it will work. Am looking forward to seeing this in 0.13. ;-)

comment:6 by Remy Blank, 12 years ago

Milestone: 1.0next-major-0.1X

Haven't started on this yet, moving post-1.0.

comment:7 by anonymous, 11 years ago

Keywords: traclinks added

comment:8 by Ryan J Ollos, 11 years ago

Keywords: traclink added; traclinks removed

comment:9 by Ryan J Ollos, 11 years ago

Keywords: traclinks added; traclink removed

comment:10 by Ryan J Ollos, 10 years ago

Owner: Remy Blank removed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.
The ticket will be disowned.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from (none) to anonymous. Next status will be 'assigned'.

Add Comment


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