Opened 15 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)
Change History (11)
by , 15 years ago
| Attachment: | 10091-no-default-repo-10621.patch added |
|---|
follow-up: 3 comment:2 by , 15 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.
comment:3 by , 15 years ago
| Milestone: | → 0.13 |
|---|---|
| Owner: | set to |
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 saysRepository '' 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 , 15 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 , 13 years ago
| Milestone: | 1.0 → next-major-0.1X |
|---|
Haven't started on this yet, moving post-1.0.
comment:7 by , 12 years ago
| Keywords: | traclinks added |
|---|
comment:8 by , 12 years ago
| Keywords: | traclink added; traclinks removed |
|---|
comment:9 by , 12 years ago
| Keywords: | traclinks added; traclink removed |
|---|
comment:10 by , 10 years ago
| Owner: | removed |
|---|



Suggested fix.