3

Hey folks,

does somebody know how to change a template of the web-interface hgweb (in my case ..\gitweb\changeset.tmpl") in a mercurial extension? I just want to replace an Bug-ID with an link to the corresponding Bug-Post.

(Also it would like know how to add a template filter. [but the above way is preferred]
I found that, but how can I do this within an extension dynamically and safe for future)

Thank you, in advance (much!)

flag

1 Answer

3

You don't actually need to write an extension for that; there already is one, called interhg, which comes with Mercurial. interhg will look for text in commit messages that match a regex, and use those capture groups to make a URL—which sounds like exactly what you're trying to achieve.

To use it, in your main .hgrc or Mercurial.ini file, add the lines

[extensions]
hgext.interhg=

and then, in the relevant repository's .hg/hgrc file, add lines like

[interhg]
fogbugz = s!bugzid: (\\d+)!<a href="http://your.fogbugz.com/?\\1">bugzid: \\1</a>!

adjusting the regex as appropriate. The value to the left of the = doesn't really matter; all that matters is the substitution pattern on the right. In the case above, the regex looks for bugzid: # and turns it into a FogBugz link.

Note that Kiln automatically bidirectionally links FogBugz cases to changesets whenever you commit message has any variant of "case 123", "bugzid 123", "review 123", etc., and is generally quite flexible (e.g., "CASES: 123, 456, and 789" will link as expected).

link|flag
no it has unfortunetely the bug: on the shortlog view, it only links the text left of the interhg link to the changeset (there is also a changeset link in another column, so no big problem). this is maybe because it nests <a> tags (not sure this is allowed by html). better would be to close and reopen the outer tag. :( – Joschua Apr 14 2010 at 14:13

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.