用Mercurial执行空提交 [英] Perform an empty commit with mercurial

查看:84
本文介绍了用Mercurial执行空提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

借助Mercurial队列扩展,我可以使用一些提交消息进行空提交,如下所示:

With with Mercurial queues extension, I can make an empty commit with some commit message like so:

hg qnew patch_name -m "message"

有没有Mercurial队列的方法吗?我简单地尝试过:

Is there a way to do this without Mercurial queues? I tried simply:

hg commit -m "message"

但是hg只是说什么都没有改变"并且不执行提交,而且我看不到任何可以覆盖该内容的强制"选项.

but hg just says "nothing changed" and doesn't do the commit, and I don't see any "force" option that would override that.

如果您想知道我这样做的动机:我们拥有测试基础架构,您可以在其中推送到特殊的存储库,它将触发自动测试的运行.您需要在最前端的提交消息中放入一个特殊的字符串,以表明要运行哪些测试.显然,当我推送到实际存储库时,我不想在此字符串.与其修改提交两次(一次添加特殊字符串,再一次删除它),不如将它添加到一个空的提交,然后回滚,这是更干净的事情.我可以使用mq来做到这一点,但我想找到一种不用mq就能做到的方法.

If you're wondering about my motivation for doing this: we have testing infrastructure where you push to a special repository and it will trigger automated tests to run. You need to put a special string into the commit message of the tipmost commit that says which tests to run. Obviously, I don't want this string in there when I push to the actual repository. Rather than amending the commit twice (once to add the special string, and a second time to remove it), I would find it cleaner to just add an empty commit, and then roll it back -- and I can do this with mq, but I'd like to find a way to do it without mq.

推荐答案

您可以使用hg commit --amend创建空的提交.

You can use hg commit --amend to create empty commits.

只需创建一个任意提交并撤消更改.然后将两个提交折叠在一起.

Just create an arbitrary commit and backout the change. Afterwards fold both commits together.

示例:

touch tmp                               # create dummy file
hg add tmp                              # add file and...
hg commit -m "tmp"                      # ... commit
hg rm tmp                               # remove the file again and ...
hg commit --amend -m "empty commit"     # ... commit

这篇关于用Mercurial执行空提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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