Mantis Bug Tracker
 

View Issue Details Jump to Notes ] Wiki ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008070mantisbtbugtrackerpublic2007-06-15 11:312009-03-03 17:35
Reportermarc 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
StatusacknowledgedResolutionopen 
PlatformOSOS Version
Product Version1.0.7 
Target VersionFixed in Version 
Summary0008070: Support for WebSVN
DescriptionI added support for WebSVN (http://websvn.tigris.org [^]).

Currently it converts text of the form
SVN:143:trunk/myproject/readme.txt
into a URL pointing to your WebSVN installation, showing you the diff between revision 143 of that file and the previous version.

Patch attached.
Additional Information--- mantis-1.0.7/core/string_api.php 2007-03-06 08:00:33.000000000 +0100
+++ mantis-1.0.7_mine/core/string_api.php 2007-06-15 16:16:02.000000000 +0200
@@ -101,6 +101,7 @@
                $p_string = string_process_bug_link( $p_string );
                $p_string = string_process_bugnote_link( $p_string );
                $p_string = string_process_cvs_link( $p_string );
+ $p_string = string_process_svn_link( $p_string );
 
                return $p_string;
        }
@@ -120,6 +121,7 @@
                $t_string = string_process_bug_link( $t_string, /* anchor */ true, /* detailInfo */ false, /* fqdn */ true );
                $t_string = string_process_bugnote_link( $t_string, /* anchor */ true, /* detailInfo */ false, /* fqdn */ true );
                $t_string = string_process_cvs_link( $t_string );
+ $t_string = string_process_svn_link( $t_string );
 
                # another escaping to escape the special characters created by the generated links
                $t_string = string_html_specialchars( $t_string );
@@ -143,6 +145,7 @@
                $p_string = string_process_bug_link( $p_string, false );
                $p_string = string_process_bugnote_link( $p_string, false );
                $p_string = string_process_cvs_link( $p_string, false );
+ $p_string = string_process_svn_link( $p_string, false );
 
                return $p_string;
        }
@@ -231,6 +234,51 @@
        }
 
        # --------------------
+ # process the $p_string and convert filenames in the formats
+ # SVN:rev:U full/path/filename.ext
+ # SVN:rev:full/path/filename.ext
+ # SVN:rev:
+ # into URLs pointing to the WebSVN server.
+ # 'rev' is the revision number.
+ # 'U full/path/filename.ext' is the output format
+ # of 'svnlook changed'.
+ #
+ # if $p_include_anchor is true, include an <a href="..."> tag,
+ # otherwise, just insert the URL as text
+ function string_process_svn_link( $p_string, $p_include_anchor=true ) {
+ $t_string = $p_string;
+ $t_svn_web = config_get( 'svn_web' );
+ $t_svn_web_repname = config_get( 'svn_web_repname' );
+ $t_svn_web_showdiff = config_get( 'svn_web_showdiff' );
+ $t_svn_web_file_page = $t_svn_web_showdiff ? "diff.php" : "filedetails.php";
+
+ $t_status['A '] = 'added: ';
+ $t_status['D '] = 'deleted: ';
+ $t_status['U '] = 'modified: ';
+ $t_status['_U'] = 'props: ';
+ $t_status['UU'] = 'mod+prop: ';
+
+ if ( $p_include_anchor ) {
+ $t_file_replace_with = "\$t_status['\\2'].'<a href=\"'.\$t_svn_web.'/'.\$t_svn_web_file_page.'?repname='.\$t_svn_web_repname.'&sc=1&path='.urlencode('/\\3').'&rev=\\1\" target=\"_blank\">\\3</a>'";
+ $t_rev_replace_with = 'Revision: '.$t_svn_web.'/listing.php?repname='.$t_svn_web_repname.'&sc=1&path=%2F&rev=\\1';
+ } else {
+ $t_file_replace_with = "\$t_status['\\2'].': \\3 - '.\$t_svn_web.'/'.\$t_svn_web_file_page.'?repname='.\$t_svn_web_repname.'&sc=1&path='.urlencode('/\\3').'&rev=\\1'";
+ $t_rev_replace_with = 'Revision: \\1 - '.$t_svn_web.'/listing.php?repname='.$t_svn_web_repname.'&sc=1&path=%2F&rev=\\1';
+ }
+ # files
+ $t_string = preg_replace( '/SVN:(\\d+):([\\w\\s]{2})\\s{5}((?:[\/\w\.]+)+)/e',
+ $t_file_replace_with,
+ $t_string );
+ $t_string = preg_replace( '/SVN:(\\d+):()((?:[\/\w\.]+)+)/e',
+ $t_file_replace_with,
+ $t_string );
+ # revisions
+ $t_string = preg_replace( '/SVN:(\\d+):/',
+ $t_rev_replace_with,
+ $t_string );
+ return $t_string;
+ }
+ # --------------------
        # Process $p_string, looking for bug ID references and creating bug view
        # links for them.
        #
--- mantis-1.0.7/config_defaults_inc.php 2007-04-01 10:09:32.000000000 +0200
+++ mantis-1.0.7_mine/config_defaults_inc.php 2007-06-15 16:37:32.000000000 +0200
@@ -1071,6 +1071,24 @@
        # eg: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/mantisbt/mantisbt/ [^]
        $g_cvs_web = '';
 
+ # --- SVN linking ---------------
+ # Converts SVN filenames into URLs pointing to your WebSVN server
+ # (e.g.: 'svn:513:trunk/myproject/readme.txt')
+ #
+ # insert the URL to your WebSVN server
+ # eg: http://www.mydomain.org/WebSVN [^]
+ # (no trailing slash, no php filename)
+ $g_svn_web = '';
+
+ # the WebSVN name of the repository
+ # (WebSVNs $config->addRepository())
+ $g_svn_web_repname = '';
+
+ # when showing a file, WebSVN can either display
+ # a diff with the previous version (true) or
+ # the whole file contents (false).
+ $g_svn_web_showdiff = true;
+
        # --- Source Control Integration ------
 
        # For open source projects it is expected that the notes be public, however,
TagsNo tags attached.
Attached Files? file icon post-commit [^] (347 bytes) 2007-06-15 11:32
patch file icon websvn_support.patch [^] (4,737 bytes) 2007-08-27 11:18 [Show Content]
patch file icon websvn_support2.patch [^] (4,536 bytes) 2007-09-14 06:19 [Show Content]
? file icon post-commit2 [^] (352 bytes) 2007-09-14 06:20

- Relationships

-  Notes
User avatar (0014766)
marc (reporter)
2007-06-15 11:34

added an example subversion commit hook, which generates issues in the required format.

This belongs into the 'hooks' directory of your SVN repository
User avatar (0014783)
vboctor (administrator)
2007-06-20 20:37

Looks good. Following are some comments:

+ # insert the URL to your WebSVN server
+ # eg: http://www.mydomain.org/WebSVN [^] [^]
+ # (no trailing slash, no php filename)
+ $g_svn_web = '';

I would change this to require a trailing slash. This a standard requirement for similar configurations.

+ # the WebSVN name of the repository
+ # (WebSVNs $config->addRepository())
+ $g_svn_web_repname = '';

The comment here doesn't tell me what needs to be assigned to this configuration option.

+ # when showing a file, WebSVN can either display
+ # a diff with the previous version (true) or
+ # the whole file contents (false).
+ $g_svn_web_showdiff = true;

Use ON/OFF (without quotations) rather than true and false.

It would be nice if you can upload an updated patch as an attachment. I'll then clear the old from from Additional Information field.
User avatar (0015538)
marc (reporter)
2007-08-27 11:25

Oops, never noticed that comment till now...

I just uploaded the adjusted patch. Regarding the g_svn_web_repname question, that is a setting in WebSVN. One WebSVN installation can handle multiple SVN repositories, and this option tells Mantis which one to use.
User avatar (0015539)
marc (reporter)
2007-08-27 11:40

I guess a little bit more of an explanation would be in order:

When I commit my changes into the SVN repository, I can use a comment like this:
"adjusted my patch for bug #0008070"

That comment will then be added to the issue 8070 in Mantis as a Bug Note. This is done by the post-commit file I attached here.

The post-commit in addition to adding the commit comment also queries the SVN repository for the list of files changed by my commit, and attaches that list in a special format to the Bug Note.

Now my patch here parses that format, and for display converts it into clickable links, which will open WebSVN to display the diff for every single file or the complete commit.
User avatar (0015637)
marc (reporter)
2007-09-14 06:22

Sorry, I just noticed that I uploaded some broken versions of the files. I just uploaded two new ones, post-commit2 and websvn_support2.patch.

I cannot delete the old files, could someone please do that, and also delete the Addtitional Info text.

Thanks.
User avatar (0020993)
jreese (administrator)
2009-03-03 17:35

For anyone interested, in the development versions of 1.2.x, there is support for plugins; I've created a Source Integration plugin set that includes support for WebSVN.

http://leetcode.net/blog/2009/01/integrating-git-svn-with-mantisbt/ [^]

Cheers

- Issue History
Date Modified Username Field Change
2007-06-15 11:31 marc New Issue
2007-06-15 11:32 marc File Added: post-commit
2007-06-15 11:34 marc Note Added: 0014766
2007-06-20 20:37 vboctor Note Added: 0014783
2007-06-20 20:37 vboctor Status new => acknowledged
2007-07-10 05:29 AKR Issue Monitored: AKR
2007-08-06 17:32 RoystonS Issue Monitored: RoystonS
2007-08-27 11:18 marc File Added: websvn_support.patch
2007-08-27 11:25 marc Note Added: 0015538
2007-08-27 11:40 marc Note Added: 0015539
2007-09-14 06:19 marc File Added: websvn_support2.patch
2007-09-14 06:20 marc File Added: post-commit2
2007-09-14 06:22 marc Note Added: 0015637
2008-01-07 04:21 stagomantis Issue Monitored: stagomantis
2008-02-27 06:22 totten2 Issue Monitored: totten2
2008-07-01 10:38 totten2 Issue End Monitor: totten2
2009-03-03 13:15 MFWSchmidt Issue Monitored: MFWSchmidt
2009-03-03 17:35 jreese Note Added: 0020993


MantisBT 1.2.2 git master-1.2.x[^]
Copyright © 2000 - 2010 MantisBT Group
Time: 0.2480 seconds.
memory usage: 2,008 KB
Powered by Mantis Bugtracker