Make bug numbers clickable for hg.mozilla.org

RESOLVED FIXED

Status

Developer Services
Mercurial: hg.mozilla.org
RESOLVED FIXED
11 years ago
4 years ago

People

(Reporter: Mardak, Assigned: ted)

Tracking

Details

Attachments

(3 obsolete attachments)

(Reporter)

Description

11 years ago
Created attachment 279374 [details] [diff] [review]
v1

Linkify various bug-like checkin comments such as...

bug 1, bug #1, b=1, #12345, 20070

For the last 2 cases, it'll linkify only numbers that are 5 digits or longer.

This applies to viewing (long) changelogs, changesets, file annotations, file views.

I'll post it upstream and perhaps someone will generalize it to not have b.mo somewhat hardcoded. ;)
Comment on attachment 279374 [details] [diff] [review]
v1

>+    "bug": lambda x: bug(x, 'http://bugzilla.mozilla.org/show_bug.cgi?id='),

s/http/https/
Doing patches like this isn't going to work. Either the patches need to go upstream, or we need to put hgweb in a repo that we can edit and use. Local patches are _bad_ (re: prior experience with local patches for tinderbox/bonsai).
(Reporter)

Comment 3

11 years ago
Created attachment 279377 [details] [diff] [review]
v2

http -> https, look for 4 digits instead of 5

Setting up a local repository of mercurial would work. Basically it would be a branch of the main line, and we would be able to keep versions and so on.

Kinda like what I'm doing right now to generate these patches.. I've got hg keeping track of hg as well as serving itself.
Attachment #279374 - Attachment is obsolete: true
(Reporter)

Comment 4

11 years ago
Created attachment 279401 [details] [diff] [review]
v3

I've updated the patch to be generic (set bugtracker in [web]) and update the default template, so it should be more likely to land upstream.

----

Convert bug numbers to links in descriptions for hgweb; set bugtracker in [web]
http://www.selenic.com/pipermail/mercurial/2007-September/014492.html

This patch converts bug-like numbers in descriptions to be links if
the configuration [web] section has a "bugtracker" value. Updates
default and gitweb templates.

Commit messages can have references to bug numbers that contain useful
discussions, so providing a link to the bug lets people viewing the
repository get a bigger picture easier. The patch looks in the
description for text like bug 1, bug #1, b=1, #1234, 2007; so there
might be false positives, but that's not too bad.

I added the "bug" filter in hgmod_web.py because it needed to use a
configuration value that's not easily accessible from templater.py.
Additionally, filters that don't actually exist won't get applied, so
an unset bugtracker will have the "bug" filter do nothing.

Example .hgrc:
[web]
bugtracker = https://bugzilla.mozilla.org/show_bug.cgi?id=

The default and gitweb templates use "desc" in different places, but
all the non-link uses of desc should now be bug-ifyable. (I avoided
making nested links which work but are messy...)
Attachment #279377 - Attachment is obsolete: true
(Reporter)

Comment 5

11 years ago
Turns out there's an "interhg" extension-in-the-making which basically does what I've coded up, but slightly more general in some ways. You can specify a regular expression of text to match and the corresponding replace text.

There's currently some "issues" filed.. http://www.selenic.com/mercurial/bts/issue699 and http://www.selenic.com/mercurial/bts/issue698

But the extension is on the "crew" repository for people to test.
http://hg.intevation.org/mercurial/crew/file/4fe04b183fd8/hgext/interhg.py

To use it, it would probably be along the lines of..

[extensions]
interhg =

[interhg]
pat1 = s/((?:bug|b=|(?=#?\d{4,}))(?:\s*#?)(\d+))/<a href="https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=\2">\1</a>/
Assignee: server-ops → aravind
I can go ahead and install this extension if folks are okay with it.  I see you made some changes to the extension, do we need those or should I just pull from http://hg.intevation.org/mercurial/crew/file/4fe04b183fd8/hgext/interhg.py?

(Reporter)

Comment 7

11 years ago
The files I attached here are my own changes, interhg is a completely separate extension that someone else happened to start a couple months back.

I tried out the interhg extension and it's mostly working. There are those 2 issues that I linked to above -- 1) links can appear inside other links breaking the outer link and 2) there should be more flexibility in the expression.

Assuming those issues are fixed, we could just do..

[interhg]
bugzilla = s|((?:bug|b=|(?=#?\d{4,}))(?:\s*#?)(\d+))|<a
href="https://bugzilla.mozilla.org/show_bug.cgi?id=\2">\1</a>|i

(Whereas with the current extension that you can pull from the crew repository, you would need to do..

[interhg]
pat1 = s/((?:[bB][uU][gG]|[bB]=|(?=#?\d{4,}))(?:\s*#?)(\d+))/<a
href="https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=\2">\1</a>/

The changeset that added interhg only added that one file, so I guess if you put interhg.py into the hgext directory, that might do it..

http://hg.intevation.org/mercurial/crew/rev/0ac6b537893f
Moving this to projects since I will work on this next quarter.
Component: Server Operations → Server Operations: Projects
(Reporter)

Comment 9

11 years ago
Now that 0.9.5 is out, the .hgrc file just needs..

[extensions]
interhg =

[interhg]
bugzilla = s|((?:bug|b=|(?=#?\d{4,}))(?:\s*#?)(\d+))|<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=\2">\1</a>|i

However, there's a slight issue of links in links.. might be able to get around it with a span and onclick?
(Reporter)

Comment 10

11 years ago
This seems to be working for me.

bugzilla = s|((?:bug|b=|(?=#?\d{4,}))(?:\s*#?)(\d+))|<span style="text-decoration: underline;" onclick="event.preventDefault(); document.location = 'https://bugzilla.mozilla.org/show_bug.cgi?id=\2';" onmouseover="window.status = 'https://bugzilla.mozilla.org/show_bug.cgi?id=\2';" onmouseout="window.status = '';" title="View bug \2">\1</span>|i

Could make it fancier with changing styles and all.

Comment 11

10 years ago
*bump* What's the status here? Sounds like we just need to plop in an extension and make the change to the .hgrc file (per comment 9). Sounds easy enough.

Comment 12

10 years ago
Edward, can you explain why you prefer the onclick solution to normal links? I'm not sure I understand how common the "nested" case is going to be. I can stage this on a local server for testing if desirable.
(Reporter)

Comment 13

10 years ago
The problem with normal links is that commit messages are by default links.

http://hg.mozilla.org/cvs-trunk-mirror/

The commit message links to the changeset, and if we convert "bug ###" into a link, we end up with..

<a href="changeset">commit log <a href="bug">bug ###</a> broken link</a>

Where "broken link" doesn't show up as a link anymore.
(Reporter)

Comment 14

10 years ago
(In reply to comment #11)
> Sounds like we just need to plop in an extension
Actually, no need to plop in the extension since version 0.9.5 -- it has it installed by default and enabling it just requires modifying the .hgrc file.
bsmedberg: do we want this enabled globally?

Comment 16

10 years ago
Aravind, let me try a couple local tests and get back to you.

Comment 17

10 years ago
Aravind, here's what I'd like to do, if it sounds reasonable to you:

1) take some gitweb_mozilla template changes. I have a cloned repository at http://hg.mozilla.org/users/bsmedberg_mozilla.com/index.cgi/hg_templates/

2) Add the following settings to the global config:

[extensions]
interhg =

[interhg]
a_httplinks = s|(https?://\S+)|<a href="\1">\1</a>|i
bugzilla = s|((?:bug[\s#]*|b=#?|#)(\d{3,}))|<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=\2" title="Bug \2">\1</a>|i

These changes are running at http://office.smedbergs.us/hgwebdir.cgi/mozilla-central/ if you want to see them in action.
> bugzilla = s|((?:bug[\s#]*|b=#?|#)(\d{3,}))|<a
> href="https://bugzilla.mozilla.org/show_bug.cgi?id=\2" title="Bug \2">\1</a>|i

Bonsai requires at least 4 numbers in a row... might want to do the same thing with this, too...
Component: Server Operations: Projects → Server Operations
Done.

Reed: bumped that to 4 digits in a row.  Can't be upsetting bonsai!
Status: NEW → RESOLVED
Last Resolved: 10 years ago
Resolution: --- → FIXED

Comment 20

10 years ago
This causes the Atom feed to be malformed:

http://feedvalidator.org/check.cgi?url=http%3A%2F%2Fhg.mozilla.org%2Fmozilla-central%2Findex.cgi%2Fatom-log

So we're running interhg on the feed output incorrectly. Aravind, can you please turn off interhg for the moment, until I can figure out if there's a way to fix it?
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
sure.  Done.
Status: REOPENED → RESOLVED
Last Resolved: 10 years ago10 years ago
Resolution: --- → FIXED

Comment 22

10 years ago
Want this open... assigning to me for the moment to think about a better solution.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---

Updated

10 years ago
Assignee: aravind → benjamin
Status: REOPENED → NEW

Comment 23

10 years ago
Marking incomplete - re-open when you have a better solution.
Status: NEW → RESOLVED
Last Resolved: 10 years ago10 years ago
Resolution: --- → INCOMPLETE

Comment 24

10 years ago
This bug is assigned to me, please do not mark it incomplete or it will fall off my radar.
Status: RESOLVED → REOPENED
Resolution: INCOMPLETE → ---

Comment 25

10 years ago
Okay, pushed to Projecst.  Move out of there when you're ready (aren't you afk?).
Component: Server Operations → Server Operations: Projects
(Reporter)

Updated

10 years ago
Duplicate of this bug: 437145
bsmedberg: any update on this?

Comment 28

10 years ago
It's low-priority... the idea is to have an extension like interhg but rather than hooking the default escape filter to use a different filter and then use that filter from the templates for selected areas that we actually want filtered.
For anyone who doesn't want to wait for this bug to be fixed:  Zbigniew Braniecki has written a greasemonkey script that implements this.

Blog post:
  http://diary.braniecki.net/2008/06/05/hgmozillaorg-linkify-bookmarklet/
Script:
  http://labs.braniecki.net/mozilla/scripts/hglinkify.user.js

Comment 30

10 years ago
Changing QA Contact.
QA Contact: justin → mrz

Updated

10 years ago
Status: REOPENED → ASSIGNED
Component: Server Operations: Projects → Hg: Customizations
QA Contact: mrz → hg.customizations
(Assignee)

Comment 31

10 years ago
bsmedberg: are you still going to do this, or would you like me to take it?

Comment 32

10 years ago
If you'd like to take it, I don't mind. The plan I had was:

* write an hg extension which adds a new filter to do linkification in the same way interhg does
* modify our templates to use the new filter
(Assignee)

Comment 33

10 years ago
I added a small extension and modified the templates to use it:
http://hg.mozilla.org/users/bsmedberg_mozilla.com/hgpoller/index.cgi/rev/7b1f803a8b01
http://hg.mozilla.org/index.cgi/hg_templates/rev/faa27022b7de
Assignee: benjamin → ted.mielczarek
Status: ASSIGNED → NEW
(Assignee)

Updated

10 years ago
Attachment #279401 - Attachment is obsolete: true
(Assignee)

Updated

10 years ago
Status: NEW → RESOLVED
Last Resolved: 10 years ago10 years ago
Resolution: --- → FIXED

Comment 34

10 years ago
Sorry that I don't know how what Ted posted is supposed to get applied but since its resolved fixed, I assumed I would see clickable bug numbers on hg.mozilla.org but I don't.  Can we just reopen this and resolve it once its verified that the bug numbers are clickable?
(Assignee)

Comment 35

10 years ago
No. It's fixed in the repo, it needs to be deployed. I'll file that bug shortly.
(Assignee)

Comment 36

10 years ago
Filed bug 448459 on getting this deployed.
I do wonder, why not use interhg for this? What makes buglink.py better?
(Reporter)

Comment 38

10 years ago
interhg uses "extend" modifier which can be used in places where replacing text with an anchor node is undesirable: titles or rss feeds. buglink lets us pick exactly which spots to replace with a buglink.

Updated

10 years ago
Depends on: 448459
Product: mozilla.org → Release Engineering
Product: Release Engineering → Developer Services
You need to log in before you can comment on or make changes to this bug.