将旧变更集重定向到其他存储库

发布于 2024-08-14 11:21:13 字数 2042 浏览 5 评论 0原文

我们在 Mercurial 中有一个钩子,用于发布变更集消息以及将变更集链接到我们的错误跟踪软件。我们为每个分支使用单独的存储库。当我们完成一个分支时,我们希望将其推送到存档存储库并删除原始存储库,以便存储库的 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 存储库提供服务。

We have a hook in Mercurial that posts the changeset message and a link the changeset to our bug tracking software. We are using separate repos for each branch. When we are done with a branch we would like to push it to an archive repository and delete the original repo so that the Mercurial page of repositories doesn't get cluttered with old repositories. We would also like to reclaim the space that the old repositories take up. I would like to configure Apache so that it redirects to an existing changeset if the changeset cannot be found.

For example, if it can't find http://hg/hg/repo1/rev/c36b1c72fc6e, it would try the following in order:

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 an existing changeset.

I think I should be able to use mod_rewrite rules to do this but it didn't work.
This 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 

Here are is the log of an an attempt using the above configuration:

(2) init rewrite engine with requested uri /hg/repo1/rev/c36b1c72fc6e
(3) applying pattern '^/hg/repo1/(.*)

It looks like it modifies the URL properly but it doesn't properly redirect and I don't know why. Any ideas?

I am using hgwebdir to serve my Mercurial repos on Apache.

to uri '/hg/repo1/rev/c36b1c72fc6e' (2) init rewrite engine with requested uri /hg/repo1/rev/c36b1c72fc6e (3) applying pattern '^/hg/repo1/(.*)

It looks like it modifies the URL properly but it doesn't properly redirect and I don't know why. Any ideas?

I am using hgwebdir to serve my Mercurial repos on Apache.

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/(.*)

It looks like it modifies the URL properly but it doesn't properly redirect and I don't know why. Any ideas?

I am using hgwebdir to serve my Mercurial repos on Apache.

to uri '/repo1/rev/c36b1c72fc6e' (1) pass through /repo1/rev/c36b1c72fc6e

It looks like it modifies the URL properly but it doesn't properly redirect and I don't know why. Any ideas?

I am using hgwebdir to serve my Mercurial repos on Apache.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

魂牵梦绕锁你心扉 2024-08-21 11:21:13

这不是您要求的答案,但如果原因确实只是为了防止 hgwebdir 页面过满,而且我知道我们有 600 多个长期完成的存储库,您可以考虑只放入

[web]
hidden=true

已完成的存储库 < code>.hg/hgrc 文件。这会将它们排除在列表之外,但保持它们的 URL 有效,而不会出现重定向的缓慢和麻烦。

从 hgrc 手册页:

   hidden

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

It's not the answer you asked for, but if the reason really is just to keep the hgwebdir page from getting overfull, and I know how that goes we have 600+ long done repos in ours, you could consider just putting

[web]
hidden=true

in the done repos .hg/hgrc files. That would keep them out of the list, but keep the URLs to them valid without the slowness and hassle of redirects.

From the hgrc man page:

   hidden

          Whether to hide the repository in the hgwebdir  index.   Default
          is False.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文