add buglink extension
authorTed Mielczarek <ted.mielczarek@gmail.com>
Tue, 29 Jul 2008 19:15:31 -0400
changeset 35 7b1f803a8b016f09aa37e566087fd0c3498afe3c
parent 34 c5106c94d59d1482798e43a593867d10c8c31c3a
child 36 44a4db71c3e967fa3352777ded673bf370924244
push id12
push usertmielczarek@mozilla.com
push dateTue, 29 Jul 2008 23:15:41 +0000
add buglink extension
buglink.py
new file mode 100644
--- /dev/null
+++ b/buglink.py
@@ -0,0 +1,15 @@
+# To enable:
+#
+# [extensions]
+# buglink = /path/to/buglink.py
+
+import re
+from mercurial import templatefilters
+
+bugzilla = r'<a href="https://bugzilla.mozilla.org/show_bug.cgi=\2">\1</a>'
+bug_re = re.compile(r'((?:bug|b=|(?=#?\d{4,}))(?:\s*#?)(\d+))', re.I)
+
+def buglink(x):
+    return bug_re.sub(bugzilla, x)
+
+templatefilters.filters["buglink"] = buglink