#24 Allow using URLs with parameters as viewers

closed-accepted
nobody
None
5
2008-09-09
2008-08-16
Vadim Zeitlin
No

This is similar to patch 1710760 except that this allows to use URLs with parameters for svn repositories. A typical example (and why I needed this):

$file_viewer =
{
'svn:file:///var/svn/project/trunk' => 'http://some.whe.re/cgi-bin/viewvc.cgi/trunk/?root=Project&view=markup',
};

The patch is attached but here it is also inline for ease of review:

--- codestriker-1.9.6-orig/lib/Codestriker/Repository/Subversion.pm 2008-08-16 22:00:29.000000000 +0200
+++ codestriker/lib/Codestriker/Repository/Subversion.pm 2008-08-16 22:22:26.000000000 +0200
@@ -103,5 +103,16 @@
}

- return (defined $viewer) ? $viewer . "/" . $filename : "";
+ return "" unless defined $viewer;
+
+ # check for parameters in the URL: if we have them, the file name must be
+ # inserted before them; otherwise we simply append it to the end
+ if ( $viewer =~ /^([^?]+)(\?.*)$/ ) {
+ $viewer = $1 . $filename . $2;
+ }
+ else {
+ $viewer .= '/' . $filename;
+ }
+
+ return $viewer;
}

Thanks!

Discussion

  • Vadim Zeitlin
    Vadim Zeitlin
    2008-08-16

    Patch to allow parameters in svn viewers

     
    Attachments
  • David Sitsky
    David Sitsky
    2008-08-18

    Logged In: YES
    user_id=208928
    Originator: NO

    Looks good. I need to move this code into the base class, as Cvs.pm would also benefit from this. Thanks for the contribution.

     
  • David Sitsky
    David Sitsky
    2008-09-09

    • status: open --> closed-accepted
     
  • David Sitsky
    David Sitsky
    2008-09-09

    Now is CVS. I created a Repository base class which all repository objects extend from. I moved this code into the base class for now. Thanks for the submission.