Trac ticket regexp parsing

2 views
Skip to first unread message

Erik Andersson

unread,
Jun 23, 2009, 2:37:38 AM6/23/09
to trac...@googlegroups.com
Hi

I've added support to add time spent dev/test in the svn commit message with syntax:
#<ticket number>:<time spent dev>:<time spent test>

Unfortunately that broke the ticket parsing in Trac.

#1234:-1:0 gives me a valid Trac link to ticket 1234
#1234:1:0 highlights #1234:1 but there is no link.

Since I already pushed some entries into the database and the difference was minimal I thought it would be nice to tweak the regexp.


Today I asked coderanger if he knew what I could possibly break if I modified the regexp. He took a quick look and found something he wanted me post here. 

[23:13:52] <coderanger_> hmm, not sure why the regex uses the Ranges string
[23:13:57] <coderanger_> that doesn't seem right
[23:15:07] <coderanger_> I would ask on tracdev
[23:15:36] <coderanger_> someone probably planned to do something with that and never did

Anyone knows anything about this?

The regexp used seems to be: "\d+(?:[-:]\d+)?(?:,\d+(?:[-:]\d+)?)*"

Cheers / Erik





Remy Blank

unread,
Jun 23, 2009, 3:22:47 AM6/23/09
to trac...@googlegroups.com
Erik Andersson wrote:
> Since I already pushed some entries into the database and the difference
> was minimal I thought it would be nice to tweak the regexp.

I would switch to a syntax that doesn't interfere with ticket links,
something like #<ticket number>|<time spent dev>|<time spent test>, and
edit the commit messages that have the old syntax with svnadmin.

-- Remy

signature.asc

Christian Boos

unread,
Jun 23, 2009, 3:28:15 AM6/23/09
to trac...@googlegroups.com
Erik Andersson wrote:
> Hi
>
> I've added support to add time spent dev/test in the svn commit
> message with syntax:
> #<ticket number>:<time spent dev>:<time spent test>
>
> Unfortunately that broke the ticket parsing in Trac.
>
> #1234:-1:0 gives me a valid Trac link to ticket 1234
> #1234:1:0 highlights #1234:1 but there is no link.
>
> Since I already pushed some entries into the database and the
> difference was minimal I thought it would be nice to tweak the regexp.
>
> Osimons pointed me
> to http://trac.edgewall.org/browser/branches/0.11-stable/trac/ticket/api.py#L360
>
> Today I asked coderanger if he knew what I could possibly break if I
> modified the regexp. He took a quick look and found something he
> wanted me post here.
>
> [23:13:52 <http://pacopablo.com/irclogs#UTC2009-06-23T06:13:52>]
> <coderanger_> hmm, not sure why the regex uses the Ranges string
> [23:13:57 <http://pacopablo.com/irclogs#UTC2009-06-23T06:13:57>]
> <coderanger_> that doesn't seem right
> [23:15:07 <http://pacopablo.com/irclogs#UTC2009-06-23T06:15:07>]
> <coderanger_> I would ask on tracdev
> [23:15:36 <http://pacopablo.com/irclogs#UTC2009-06-23T06:15:36>]
> <coderanger_> someone probably planned to do something with that and
> never did
>
>
> Anyone knows anything about this?
>
> The regexp used seems to be: "\d+(?:[-:]\d+)?(?:,\d+(?:[-:]\d+)?)*"
>

This is a new feature of Trac 0.11:

http://trac.edgewall.org/wiki/TracLinks#ticket:links

For some reason though the #500:600 syntax doesn't seem to work - the
documented #500-600 one does.

For your new specific feature, I'd advise you to *start* with something
specific to the time tracking, then mention the resource which is
tracked, a bit similar to the attachment: and comment: syntax.
E.g.
tracking:<time spent dev>:<time spent test>:#<ticket number>,
TT:<time spent dev>:<time spent test>:#<ticket number>
or anything more fancy like: $<time spent dev>$<time spent
test>$#<ticket number>

-- Christian

Erik Andersson

unread,
Jun 24, 2009, 1:33:43 PM6/24/09
to trac...@googlegroups.com
Thanks to all that helped out. I'm now using a different syntax and I wrote a script that modifies the svn comment and resyncs trac..

Cheers / Erik
Reply all
Reply to author
Forward
0 new messages