How to implements the /svn-history/ path like Goog

2019-03-27 00:35发布

问题:

When you publish a Subversion repository trough Apache Httpd you got an bonus feature: you can browse the HEAD revision of you sources with any HTTP client.

For example, we have this repository:

http://trash-cli.googlecode.com/svn/trunk/

With any HTTP client (e.g. Firefox) you can browse the files at the HEAD revision. The svnbook explain very well how do that.

But Google Code Hosting offer an extra feature: you can browse also the past revisions. For example you can browse the r10 revision:

http://trash-cli.googlecode.com/svn-history/r10/trunk/

Do you know how Google do that? I want this feature in my company repository too! :)

Thanks

Update 1

The following behavior may help us to solve the problem. If I visit a path that doesn't exist in repository, for example

http://trash-cli.googlecode.com/svn-history/r10/non-existent

I got the following 404 error:

Not Found

The requested URL /svn/!svn/bc/10/non-existent was not found on this server.

I suspect that there is a URL rewrite rule under the scene.

Update 2

Please note that this is not the same of this question. I want to expose the this service on my company repository in a way that is comfortable to the user in a way that Google Code do, I'm not interested how to get old revision in a external repository that doesn't has this feature. I'm using the perspective of the service provider, not the perspective of the user. I want make life easier to my colleagues.

回答1:

From the subversion 1.6 release notes:

New public 'historical' HTTP URI syntax for mod_dav_svn (server)

mod_dav_svn now supports a new public URI syntax for examining older versions of files or directories. The intent here is to allow users to examine history without the use of an svn client, and to make it easier for 3rd-party tools (e.g. code-review services) to work directly against repositories without using svn libraries.

http://host/repos/path?[p=PEG][&r=REV]



回答2:

I believe the basic install (from the SubVersion team) doesn't come with this feature out of the box. I believe people have built extensions or programs on top of or in conjunction with a Subversion client to get that feature.

If you run the repository, you can probably install WebSVN (http://websvn.tigris.org/) to get what you need. There are other options, I'm sure.



回答3:

Append something like this to your repository URL:

!svn/bc/<revision_number>/

E.g.

http://www.example.com/svnrepository/!svn/bc/3/

Duplicate: How do I browse an old revision of a Subversion repository through the web view?



回答4:

I studied the Apache docs and I think it could be solved using this rule in httpd.conf.

RewriteRule ^/svn-history/r([0-9]+)/(.*) /svn/!svn/bc/$1/$2

I didn't yet test it. I'll test it later.



标签: svn http