There exists a hook in Mercurial that posts the changeset message along with a link the changeset to the bug monitoring software. We're using separate repos for every branch. If we are completed with a branch we wish to push it for an archive repository and remove the initial repo to ensure that the Mercurial page of databases does not get cluttered with old databases. We'd like to reclaim the area the old databases occupy. I must configure Apache to ensure that it redirects for an existing changeset when the changeset can't be found.

For instance, whether it aren't able to find http://hg/hg/repo1/rev/c36b1c72fc6e, it might try the next so as:

http://hg/hg/repo1/rev/c36b1c72fc6e  
http://hg/hg/repo2/rev/c36b1c72fc6e  
http://hg/hg/repo3/rev/c36b1c72fc6e  
http://hg/hg/archive/rev/c36b1c72fc6e

until it finds a current changeset.

I believe I ought to have the ability to use mod_rewrite rules to get this done however it did not work. This really is my latest attempt:

RewriteEngine on  
RewriteLog /var/log/httpd/rewrite.log  
RewriteLogLevel 9  

# Re-map URLs that aren't found

RewriteCond %{REQUEST_URI}   !-U
RewriteRule ^/hg/repo1/(.*)$ http://hg/hg/archive/$1

Listed here are may be the log of the an effort while using above configuration:

(2) init rewrite engine with requested uri /hg/repo1/rev/c36b1c72fc6e
(3) applying pattern '^/hg/repo1/(.*)$' to uri '/hg/repo1/rev/c36b1c72fc6e'
(2) init rewrite engine with requested uri /hg/repo1/rev/c36b1c72fc6e
(3) applying pattern '^/hg/repo1/(.*)$' to uri '/hg/repo1/rev/c36b1c72fc6e'
(4) RewriteCond: input='/hg/repo1/rev/c36b1c72fc6e' pattern='!-U' => matched
(2) rewrite '/hg/repo1/rev/c36b1c72fc6e' -> 'http://hg/hg/archive/rev/c36b1c72fc6e'
(2) implicitly forcing redirect (rc=302) with http://hg/hg/archive/rev/c36b1c72fc6e
(1) escaping http://hg/hg/archive/rev/c36b1c72fc6e for redirect
(1) redirect to http://hg/hg/archive/rev/c36b1c72fc6e [REDIRECT/302]
(5) RewriteCond URI (-U) check: path=/hg/repo1/rev/c36b1c72fc6e -> status=302
(4) RewriteCond: input='/hg/repo1/rev/c36b1c72fc6e' pattern='!-U' => not-matched
(1) pass through /hg/repo1/rev/c36b1c72fc6e
(2) init rewrite engine with requested uri /repo1/rev/c36b1c72fc6e
(3) applying pattern '^/hg/repo1/(.*)$' to uri '/repo1/rev/c36b1c72fc6e'
(1) pass through /repo1/rev/c36b1c72fc6e

It appears enjoy it modifies the URL correctly however it does not correctly redirect and I'm not sure why. Any ideas?

I'm using hgwebdir for everyone my Mercurial repos on Apache.

It isn't the solution you requested, but when the main reason is really simply to keep your hgwebdir page from getting overfull, and I understand how that goes we've 600+ lengthy done repos in ours, you could look at just putting

[web]
hidden=true

within the done repos .hg/hgrc files. That will prevent them from entering their email list, but keep your Web addresses for them valid with no slowness and need for redirects.

In the hgrc guy page:

   hidden

          Whether to hide the repository in the hgwebdir  index.   Default
          is False.