--- viewcvs.py.bak	Tue Jul 15 14:46:11 2003
+++ viewcvs.py	Tue Jul 15 16:11:14 2003
@@ -346,10 +346,23 @@
 
 _re_rewrite_url = re.compile('((http|ftp)(://[-a-zA-Z0-9%.~:_/]+)([?&]([-a-zA-Z0-9%.~:_]+)=([-a-zA-Z0-9%.~:_])+)*(#([-a-zA-Z0-9%.~:_]+)?)?)')
 _re_rewrite_email = re.compile('([-a-zA-Z0-9_.]+@([-a-zA-Z0-9]+\.)+[A-Za-z]{2,4})')
+_re_buglink = re.compile('^BugID:((\s+#*\d+,*){1,})', re.M)
+def bug_linkify(m):
+    url = """<a href="http://bugs.example.com/show_bug.cgi?id=%s">%s</a href> """
+    bugs = m.group(1).replace('#', '')
+    bugs = bugs.replace(',', '')
+    bugs = bugs.split()
+
+    text = ""
+    for bug in bugs:
+        text = text + url % (bug, bug)
+    return "BugID: %s" % text
+
 def htmlify(html):
   html = cgi.escape(html)
   html = re.sub(_re_rewrite_url, r'<a href="\1">\1</a>', html)
   html = re.sub(_re_rewrite_email, r'<a href="mailto:\1">\1</a>', html)
+  html = re.sub(_re_buglink, bug_linkify, html)
   return html
 
 def format_log(log):
