我们在Mercurial中有一个钩子,它发布变更集消息,并将变更集链接到我们的bug跟踪软件。我们为每个分支使用单独的回购。当我们完成分支时,我们希望将其推送到存档库并删除原始存储库,以便存储库的Mercurial页面不会被旧存储库弄得乱七八糟。我们还想收回旧存储库占用的空间。我想配置Apache,以便在无法找到更改集时重定向到现有的变更集。
例如,如果找不到http://hg/hg/repo1/rev/c36b1c72fc6e,它将按顺序尝试以下操作:
http://hg/hg/repo1/rev/c36b1c72fc6e
http://hg/hg/repo2/rev/c36b1c72fc6e
http://hg/hg/repo3/rev/c36b1c72fc6e
http://hg/hg/archive/rev/c36b1c72fc6e
直到找到现有的变更集。
我认为我应该能够使用mod_rewrite规则来执行此操作,但它不起作用。 这是我最近的尝试:
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
以下是使用上述配置尝试的日志:
(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
看起来它正确地修改了URL,但它没有正确地重定向,我不知道为什么。有什么想法吗?
我正在使用hgwebdir在Apache上提供我的Mercurial回购。
答案 0 :(得分:1)
这不是你要求的答案,但如果原因只是为了防止hgwebdir页面过度使用,而且我知道这是怎么回事,我们有600多个已完成的回购,我们可以考虑放
[web]
hidden=true
在完成的回购.hg/hgrc
文件中。这会使他们不在列表中,但保持URL的有效,而不会出现重定向的缓慢和麻烦。
来自hgrc手册页:
hidden
Whether to hide the repository in the hgwebdir index. Default
is False.