[issue1701] interhg screws up annotate links

Stephen Rasku mercurial-bugs at selenic.com
Fri Jun 19 17:27:05 UTC 2009


New submission from Stephen Rasku <mercurial at srasku.net>:

I am using it to link bug numbers to our bug tracking system.  It works fine in
the log view and changeset view but it corrupts the links in the annotate view.

This is the regular expression I am using:

   s!^(([^<>]|<[^<>]*>)*ITN-)([0-9]+)(([^<>]|<[^<>]*>)*)$!\1<a
href="http://jira:8080/browse/ITN-\3"><font
color="red">\3</font></a>\4!

For the following line:

</td></tr><tr class="parity1"><td class="annotate"><a
href="/hg/TUNet/annotate/f23e1d3fe42a/BASE_STATION/P1021/dba_phs1_store.pc#16"
title="f23e1d3fe42a: JIRA:ITN-9453:Resolved">srasku at 6467</a></td><td
class="source"><a href="#l16" id="l16">    16</a> #include
&lt;unistd.h&gt;

it is replacing it with:

</td></tr><tr class="parity1"><td class="annotate"><a
href="/hg/TUNet/annotate/f23e1d3fe42a/BASE_STATION/P1021/dba_phs1_store.pc#16"
title="f23e1d3fe42a: JIRA:ITN-<a
href="http://jira:8080/browse/ITN-9453"><font
color="red">9453</font></a>:Resolved">srasku at 6467</a></td><td
class="source"><a href="#l16" id="l16">    16</a> #include
&lt;unistd.h&gt;

However, if I use sed, it does what I expect:

$ sed -r 's!^(([^<>]|<[^<>]*>)*ITN-)([0-9]+)(([^<>]|<[^<>]*>)*)$!\1<a
href="http://jira:8080/browse/ITN-\3"><font
color="red">\3</font></a>\4!'


</td></tr><tr class="parity1"><td class="annotate"><a
href="/hg/TUNet/annotate/f23e1d3fe42a/BASE_STATION/P1021/dba_phs1_store.pc#16"
title="f23e1d3fe42a: JIRA:ITN-9453:Resolved">srasku at 6467</a></td><td
class="source"><a href="#l16" id="l16">    16</a> #include
&lt;unistd.h&gt
</td></tr><tr class="parity1"><td class="annotate"><a
href="/hg/TUNet/annotate/f23e1d3fe42a/BASE_STATION/P1021/dba_phs1_store.pc#16"
title="f23e1d3fe42a: JIRA:ITN-9453:Resolved">srasku at 6467</a></td><td
class="source"><a href="#l16" id="l16">    16</a> #include
&lt;unistd.h&gt

I guess there's a few ways to resolve this:

1. Stop interhg from substituting inside tags.
2. Fix regex processing so it works the same as sed.
3. Allow interhg to modify annotate links in a specified order.

For 3. what I am suggesting is that I be able to specify a substitution that
occurs before the bug substitution so I can change the text that triggers the
corrupting substitution so it won't match.

I tried to set up my [interhg] section like this:

annotate	= s/(title=".*)ITN-/\1issue /
jira		= s!^(([^<>]|<[^<>]*>)*ITN-)([0-9]+)(([^<>]|<[^<>]*>)*)$!\1<a
href="http://jira:8080/browse/ITN-\3"><font color="red">\3</font></a>\4!

I intended this to change ITN- tags to "issue " tags so it wouldn't be matched
by the following jira rule.  However, it doesn't work.  It's possible the
substitutions happen before they get to the web.  If this is the case then this
isn't a possible solution.

----------
messages: 9568
nosy: rasca1
priority: bug
status: unread
title: interhg screws up annotate links

____________________________________________________
Mercurial issue tracker <mercurial-bugs at selenic.com>
<http://www.selenic.com/mercurial/bts/issue1701>
____________________________________________________



More information about the Mercurial-devel mailing list