简体   繁体   English

如何强制mercurial接受空提交

[英]How can I force mercurial to accept an empty commit

I'm trying to convert an SVN repo with hgsvn and I have some commits where SVN properties where modified, but since Mercurial doesn't use those, it sees this as an empty commit and aborts. 我正在尝试使用hgsvn转换SVN repo并且我有一些提交,其中SVN属性被修改,但由于Mercurial不使用它们,它将此视为空提交并中止。 Is there any way to force this hg commit to accept a commit that doesn't change anything? 有没有办法强制这个hg commit接受不改变任何东西的提交?

I'm not familiar enough with the internals of hgsvn to hack it to skip empty commits. 我对hgsvn的内部不熟悉,不能破解它以跳过空提交。

I think you can't do empty commit in mercurial. 我认为你不能在mercurial做空提交。 Here's a thread explaining why . 这是一个解释原因的线程

You can skip this commit if you add a local svn.$REVNUM tag to the head revision (=the revision which also has the svn.($REVNUM-1) tag now). 如果向头版本添加本地svn。$ REVNUM标记(=现在还具有svn。($ REVNUM-1)标记的版本),则可以跳过此提交。 Then you can continue with hgpullsvn. 然后你可以继续使用hgpullsvn。

Say your import is at this state (last imported rev is 15800, the property-only rev is 15801): 假设您的导入处于此状态(上次导入的rev为15800,仅属性的rev为15801):

$ hg log -l1
changeset:   1234:123456789abc
branch:      trunk
tag:         tip
tag:         svn.15800
parent:      1233:cba987654321
user:        Rudi <rudi@example.com>
date:        Tue Aug 24 11:42:23 2010 +0200
summary:     Foobar

$ svn info
Path: .
URL: svn+ssh://example.com/foobar/trunk
Repository Root: svn+ssh://example.com/foobar
Repository UUID: 26c7c274-8ed1-4e7f-bdc1-5c767a948b10
Revision: 15801
Node Kind: directory
Schedule: normal
Last Changed Author: rudi
Last Changed Rev: 15801
Last Changed Date: 2010-08-24 14:00:29 +0200 (Di, 24 Aug 2010)

Then you simply add the svn.15801 tag: 然后你只需添加svn.15801标签:

$ hg tag -l -r 123456789abc svn.15801

and contunie to import. 和contunie进口。

But make a backup before you try this. 但在尝试之前先做好备份。

When I've needed empty commits in p4 and hg before, I've simply used a file that was set aside to 'be' the empty commit. 当我之前在p4和hg中需要空提交时,我只是使用了一个被设置为“是”空提交的文件。 Just dump a random string of some sort (I usually use the time and date) into the throwaway file, and hg commit away.... 只需将一些随机字符串(我通常使用时间和日期)转储到一次性文件中,然后hg commit ....

As per @vorrtex's comment on the original question, the simplest method to force an empty commit in Mercurial is as follows: 根据@ vorrtex对原始问题的评论,在Mercurial中强制空提交的最简单方法如下:

  1. Add a new file (say, Dummy.txt ) and commit. 添加一个新文件(比如Dummy.txt )并提交。
  2. hg forget Dummy.txt
  3. hg commit --amend

This will remove Dummy.txt from the previous commit, leaving it empty. 这将从先前的提交中删除Dummy.txt ,将其留空。 (You can use eg TortoiseHg for step 1 but you'll need to use a command line tool for steps 2 and 3.) (您可以使用例如TortoiseHg执行步骤1,但您需要使用命令行工具执行步骤2和3。)

I'm adding this as a new answer because when scanning this thread originally I missed the comment, and the existing answers don't create a truly empty commit. 我正在添加这个作为一个新的答案,因为最初我扫描这个帖子时我错过了评论,而现有的答案并没有创建一个真正的空提交。

Perhaps, the following will not help you in the situation, but perheps other reader. 也许,以下情况对你不会有所帮助,但也会影响其他读者。

You can make an "empty" commit via import of a nearly empty patch. 您可以通过导入几乎空的补丁进行“空”提交。 I exported a patch, removed all changes in it, leaveing only 3 lines (diff..., ---... and +++ ...), and imported it with hg import --bypass --message ... 我导出了一个补丁,删除了它中的所有更改,只留下3行(diff ...,--- ...和+++ ...),并使用hg import --bypass --message ...导入它hg import --bypass --message ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM