Bug-tracker --> SCM system autolinkification

Aleksey 'Commander' Pershin commander at avanquestusa.com
Thu Oct 20 23:27:13 UTC 2005

Hello Max,

Max Kanat-Alexander wrote:
 >> It would be
 >> nice if there was a convention 3rd party integration of SCM systems
 >> could follow when it comes to inserting comments in a bug-tracker.
 >> Then bug-trackers could search and parse for that syntax and
 >> autolinkify accordingly to their favorite linkification system
 >> (CVSView, WebSVN, etc).
 > Kristis -
 > What are the input parameters of such a function? That is, what
 > data would "bug_insert_comment" be passed, and what are some example
 > outputs that you'd like to see?

I could probably answer this question for Kristis. Kristis
(the developer of SCMBUG - a nice tool I used to integrate
Bugzilla with Subversion) and I were discussing why Bugzilla
2.20 was crashing when called from SCMBUG, when I mentioned
to Kristis that I had modified Bugzilla to support this kind
of autolinkification.

When a user commits files to Subversion and marks the change
as a fix for a particular bug in Bugzilla, SCMBUG adds
a comment to this bug (or bugs) in the following form:

Derive from the CHashTable and use CHashTable's functions
to do everything. Calculate max/min/average count and
Calculate the number of strings.

Affected files:
388 --> 723 PDX:trunk/Common/Inc/HashCell.h
391 --> 723 PDX:trunk/Common/Src/HashCell.cpp
708 --> 723 PDX:trunk/Testing/Common/CommTest.cpp
690 --> 723 PDX:trunk/Testing/Common/Inc/SpecTabl.h
704 --> 723 PDX:trunk/Testing/Common/Src/SpecTabl.cpp

I modified Bugzilla's autolinkification code to recognize
such comments and turn the file names into links to WebSVN
showing the changes in a side-by-side comparing page.

Is it really worth adding a special function to Bugzilla
that would allow SCM integrators to add these comments?
IMHO, probably not, as the variety of possibilities is
too large and greatly depends on the underlying SCM.
The existing function Bugzilla::Bug::AppendComment
seems to be general enough. The only thing an SCM integrator
needs to do is to form a comment in some standard form
and give it to Bugzilla::Bug::AppendComment.

If I were asked to make some sort of generalization for
these comments, I would define them like this:

<An arbitrary text from the commit comment>


Each <Operation> can be defined like this:

<Operation> := <Change> <Project>:<Path>

If <Path> ends with a slash, it is a directory, otherwise
it is a file. <Project> is just a name of the corresponding
project in the SCM. <Change> can be defined like this:

<Change> := <Revision> <Arrow> <Revision>   # Regular change
           | <NONE>     <Arrow> <Revision>   # New file/dir
           | <Revision> <Arrow> <NONE>       # Deleted file/dir

With this approach, one needs to have only the following
things as parameters (as regex):


Once all these things are known, it is relatively easy
to write an autolinkification regex that recognizes
such comments. The only thing left is the actual URL.

The URL, obviously, also needs to be a parameter
using things like %OLDREV%, %NEWREV%, %PROJECT% and %PATH%.
There need to be three variants of the URL: one for a regular
change, one for deleted files and another one for new files.
It would be nice to have the type of the object (file/dir)
as a variable as well (%TYPE%), with its values as configurable
parameters. I am not sure about ViewCVS, but WebSVN does
require this to be specified in the URL.

Combined, there are 9 parameters for the administrator
to configure:

<The_file_list_marker> (regex)
<Revision>             (regex)
<Arrow>                (regex)
<NONE>                 (regex)
<URL_change>           (string with env variables)
<URL_delete>           (string with env variables)
<URL_new>              (string with env variables)
<Value_dir>            (string)
<Value_file>           (string)

I hope this rather verbose (sorry) response answers
your question. If you like, I can send you the regex
I used in my setup to autolinkify SCMBUG's comments,
but it will have to be modified a little bit to make
it more generic.

With best regards,
Aleksey Pershin

P.S. Max, if you could help us solve the mystery
of Bugzilla::Bug::AppendComment crashing in 2.20, I would
be infinitely thankful :)

More information about the developers mailing list