从Mercurial prechangegroup钩子读取命令行参数 [英] Reading command line arguments from Mercurial prechangegroup hook

查看:107
本文介绍了从Mercurial prechangegroup钩子读取命令行参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果某些条件成立,我试图禁止推送到Mercurial存储库.但是,必不可少的是,如果用户使用push --force,则无论如何推送都会通过.

I'm attempting to disallow pushes to a Mercurial repository if a certain condition holds true. However, it is essential that if the user uses push --force, the push goes through regardless.

我知道使用pre-push钩子在执行推送的机器上执行此操作非常容易,该钩子将命令行参数传递给该钩子.但是,由于没有传播钩子,所以我不得不以某种方式将钩子分发到存储库的每个用户,并依靠它们不会弄乱它.

I know that it's easy enough to do this on the machine that's doing the push by using the pre-push hook, which passes in the command line arguments to the hook. However, since hooks aren't propagated, I'd have to somehow distribute the hook to every single user of the repository and rely on them not messing with it.

因此,我认为应该采取的方法是在存储库服务器上具有一个prechangegroup钩子,该钩子检查条件并在必要时中止推入操作,但是我想不出一种方法来获取命令行参数用户在从此挂钩中推动时使用.有没有一种方法可以通过使用存储库服务器上的钩子来实现?

Therefore, I thought the way to go would be to have a prechangegroup hook on the repository server which checked the condition and aborted the push if necessary, but I can't figure out a way to obtain the command line arguments the user used while pushing from this hook. Is there a way to accomplish this just by using a hook on the repository server?

我知道一个可能的解决方法是改用pretxnchangegroup钩子,如果最新变更集的提交消息遵循某种模式,则允许推送.但是,从存储库用户的角度来看,--force选项似乎容易得多,因为它不会强迫他们潜在地进行虚拟提交以使消息正确.

I know that a possible workaround would be using the pretxnchangegroup hook instead and allowing the push if the commit message of the latest changeset follows a certain pattern. However, the --force option seems much easier from a repository user's perspective, since it wouldn't force them to potentially do a dummy commit to get the message right.

推荐答案

对不起,--force命令行选项从来没有通过网络发送,因此它根本不会在服务器端使用.您需要找出某种方式来表示我的意思是真的!"带外,无论是特殊的用户名,特殊的提交消息还是类似的内容.

Sorry, the --force command line option isn't ever sent on the wire, so it won't be available on the server side at all. You'll need to figure out some way to signal "I really mean it!" out of band, be it special usernames, special commit messages, or the like.

请考虑仅具有第二个服务器端存储库,该存储库没有禁止钩子,而仅当推送器真正需要它时,才使推送器使用它.像这样:

Consider just having a 2nd server side repo that dosn't have the banning hook and have pushers use it only when they really mean it. Something like:

hg push http://your-server/repo
.. rejected due to hook failure
hg push http://your-server/repo-and-I-really-mean-it

在服务器端,"re-and-i-really-it-it-it-repo"没有钩子,并自动推送到普通仓库.

where on the server side the repo-and-I-really-mean-it repo doesn't have the hook and automatically pushes to the plain repo.

这篇关于从Mercurial prechangegroup钩子读取命令行参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆