如何插入或更改 Mercurial 修订版

发布于 2024-09-16 04:57:53 字数 443 浏览 6 评论 0原文

如何更改 r0 使其看起来像是在创建存储库时添加了 .hgignore 或在当前的 r0 之前插入提交?

我刚刚使用 hgsvn 将一个巨大的 SVN 存储库转换为 Mercurial。花了几个小时,并且必须经过大约十几个分行才能拿到整个东西。我现在的问题是 .hgignore 没有提交,所以当我 hgimportsvn 分支时,.hgignore 似乎没有附带它。我想将该文件作为 r0 的一部分插入或在其之前插入(并将所有内容移 1)。我也尝试在我的 Mercurial 主干结帐结束时提交它,但似乎 hgimportsvn 总是从我的 SVN 分支创建的同一个 Mercurial 版本克隆(分支?),所以 .hgignore 又丢失了。

How can I alter r0 so it looks like I added .hgignore when I created my repository or insert a commit before my current r0?

I just converted a huge SVN repo using hgsvn to mercurial. It took several hours and had to go through about a dozen branches to get the whole thing. My problem now is that .hgignore isn't committed, so when I hgimportsvn a branch, the .hgignore doesn't seem to come with it. I would like to insert that file as part of r0 or insert it before that (and shift everything by 1). I've also tried committing it at the end of my Mercurial trunk checkout, but it seems hgimportsvn always clones (branches?) from the same Mercurial revision my SVN branch was created from so .hgignore is lost again.

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

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

发布评论

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

评论(2

我不是你的备胎 2024-09-23 04:57:53

您可能需要类似 ConvertExtension 的东西。查看 --splicemap 选项。

要使用添加为第一个修订版的 .hgignore 文件创建新历史记录:

  1. 创建一个新存储库,其唯一修订版是 .hgignore 提交。
  2. 创建一个包含两个 40 字符哈希值的 splicemap 文件:当前数据库的 rev 0 和新数据库的 rev 0。
  3. 运行 hg Convert; --splicemap splice_filename

这会将当前数据库中的每个修订添加到新数据库中。 splicemap 指定对父级的编辑,因此如果当前数据库的修订版 0 将其父级设置为新数据库的修订版 0。

下面是一个 Windows 批处理文件,它创建一个 3 修订版数据库和一个 1 修订版数据库,其中包含 .hgignore 文件,并将它们拼接在一起。结果应该是您正在寻找的结果。如果您有一个大型原始数据库,则可能需要一段时间,因为源数据库的整个历史记录都会被重写到目标数据库。

@echo off

@REM Create a 3-revision database
hg init current
cd current
echo >file1
hg add
hg ci -m file1
echo >file2
hg add
hg ci -m file2
echo >file3
hg add
hg ci -m file3

@REM Add the first revision to the splice map
hg log -r 0 --template "{node} " > ..\map

@REM Display the result
hg log
cd ..

@REM Create a 1-revision database
hg init ignore
cd ignore
echo glob:*.txt>.hgignore
hg add
hg ci -m ignore

@REM Specify this node as the parent of the other
@REM database's first revision in the splice map
hg log -r 0 --template "{node}\n" >> ..\map
hg log
cd ..

@REM Here's the resulting splice map
type map

@REM Make a copy to store the result
hg clone ignore result

@REM Add revisions from "current" to "result" honoring
@REM the splice map
hg convert current result --splicemap map

@REM Display the result
cd result
hg log

You probably need something like the ConvertExtension. Check out the --splicemap option.

To create a new history with a .hgignore file added as the first revision:

  1. Create a new repository whose only revision is the .hgignore commit.
  2. Create a splicemap file containing two 40-char hashes: rev 0 of your current database, and rev 0 of your new database.
  3. Run hg convert <current_db_dir> <new_db_dir> --splicemap splice_filename

This adds each revision in the current database to the new database. The splicemap specifies editing of parents, so if revision 0 of the current database gets its parent set to revision 0 of the new database.

Below is a Windows batch file that creates a 3-revision database and a 1-revision database with an .hgignore file in it, the splices them together. The result should be what you are looking for. If you have a large original database it could take a while, since the entire history of the source database is re-written to the destination database.

@echo off

@REM Create a 3-revision database
hg init current
cd current
echo >file1
hg add
hg ci -m file1
echo >file2
hg add
hg ci -m file2
echo >file3
hg add
hg ci -m file3

@REM Add the first revision to the splice map
hg log -r 0 --template "{node} " > ..\map

@REM Display the result
hg log
cd ..

@REM Create a 1-revision database
hg init ignore
cd ignore
echo glob:*.txt>.hgignore
hg add
hg ci -m ignore

@REM Specify this node as the parent of the other
@REM database's first revision in the splice map
hg log -r 0 --template "{node}\n" >> ..\map
hg log
cd ..

@REM Here's the resulting splice map
type map

@REM Make a copy to store the result
hg clone ignore result

@REM Add revisions from "current" to "result" honoring
@REM the splice map
hg convert current result --splicemap map

@REM Display the result
cd result
hg log
雅心素梦 2024-09-23 04:57:53

也许您可以提交 .hgignore,然后将提交重新设置为历史记录的开头(请参阅 https:// www.mercurial-scm.org/wiki/RebaseProject)。

Maybe you could commit .hgignore and then rebase the commit to the beginning of history (see https://www.mercurial-scm.org/wiki/RebaseProject).

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