我决定最好的工作流程是将项目直接创建到 subversion 中,完全不知道 mercurial 的存在,然后用 hgsubversion 克隆。
这不仅是最好的,而且只有一种可能。Init'ed hg repo with added later extension and Subversion repo in [path]将不适用于拉/推
补充(回复@bigh_29的评论)
是的,从 Mercurial 开始使用空的 Subversion 存储库(仅创建默认 dirmap)也会给我带来意想不到和不可预测的结果。
初始状态:
- 使用 TSVN 创建本地 (file:///) SVN-repo 和trunk/branches/tags 树(工具无关紧要)
svn log file:///Z:/SVN
------------------------------------------------------------------------
r1 | Badger | 2013-01-09 12:00:10 +0600 (Ср, 09 янв 2013) | 1 line
Imported folder structure
------------------------------------------------------------------------
- 克隆 repo(从 repo-root)到 Mercurial
hg clone file:///Z:/SVN z:\HG
[r1] Badger: Imported folder structure
no changes found
updating to branch default
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
(好的,Mercurial 不跟踪空目录,所以我们没有任何东西可以存储在变更集中)
hg log -R z:\hg
产生空输出
常规工作流程测试 - 添加、提交、推送(TortoiseHG 最新)
% hg add --repository Z:\HG Z:\HG\Intro.txt
[command completed successfully Wed Jan 09 12:17:31 2013]
% hg commit ...
Intro.txt
committed changeset 0:0a3fc4a9213d
[command completed successfully Wed Jan 09 12:17:31 2013]
% hg --repository Z:\HG push file:///Z:/SVN
pushing to file:///Z:/SVN
searching for changes
no changes found
[command completed successfully Wed Jan 09 12:18:02 2013]
“没有发现变化” - 坏消息,非常坏的消息。在 Mercurial 和上游 Subversion 中有不同的历史
>hg log
changeset: 0:0a3fc4a9213d
summary: Added file
svn log file:///Z:/SVN
------------------------------------------------------------------------
r1 | Badger | 2013-01-09 12:00:10 +0600 (Ср, 09 янв 2013) | 1 line
Imported folder structure
------------------------------------------------------------------------
- 尝试将文件从 SVN WC 添加到 Subversion,添加
>svn log file:///Z:/SVN
------------------------------------------------------------------------
r2 | Badger | 2013-01-09 12:22:38 +0600 (Ср, 09 янв 2013) | 1 line
Added main file
------------------------------------------------------------------------
r1 | Badger | 2013-01-09 12:00:10 +0600 (Ср, 09 янв 2013) | 1 line
Imported folder structure
------------------------------------------------------------------------
hg --repository Z:\HG fetch --verbose file:///Z:/SVN
pulling from file:///Z:/SVN
[r2] Badger: Added main file
A trunk/Topic.txt
Topic.txt
committed to "default" as fc8bf55ea98f
pulled 1 revisions
updating to 1:fc8bf55ea98f
resolving manifests
removing Intro.txt
getting Topic.txt
1 files updated, 0 files merged, 1 files removed, 0 files unresolved
merging with 0:0a3fc4a9213d
resolving manifests
getting Intro.txt
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
Intro.txt
new changeset 2:98c16d1829d8 merges remote changes with local
并且仍然无法推送(“抱歉,找不到合并修订的 svn 父级。”):我们的 0 在原点上没有父级
但是,如果我将文件添加到 SVN 中的树(空 .hgignore,无论如何它必须出现在 Mercurial repo 中)
> svn log file:///Z:/SVN -q -v
------------------------------------------------------------------------
r2 | Badger | 2013-01-09 13:44:47 +0600 (Ср, 09 янв 2013)
Changed paths:
A /trunk/.hgignore
------------------------------------------------------------------------
r1 | Badger | 2013-01-09 13:43:27 +0600 (Ср, 09 янв 2013)
Changed paths:
A /branches
A /tags
A /trunk
------------------------------------------------------------------------
克隆后我得到
>hg log
changeset: 0:71c7bc7bce68
tag: tip
user: Badger@1d57b098-00df-af47-a2e3-c1451e4b2f8d
date: Wed Jan 09 07:44:47 2013 +0000
summary: Added needed for successful cloning hgignore
并且添加|提交的文件被推送到 Subversion 没有任何头痛
% hg --repository Z:\HG push file:///Z:/SVN
pushing to file:///Z:/SVN
searching for changes
[r3] Badger: File from Mercurial
pulled 1 revisions
nothing to rebase
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
svn log file:///Z:/SVN -q -v -r "HEAD"
------------------------------------------------------------------------
r3 | Badger | 2013-01-09 13:59:15 +0600 (Ср, 09 янв 2013)
Changed paths:
A /trunk/Test.txt
------------------------------------------------------------------------
注意:我在使用带有 SVN 来源的 Mercurial 分支的测试中失败:创建的(命名的)分支保存在这个分支变更集中在推送到 Subversion 后消失了(变更集出现在主干而不是预期的 /branches/BRANCHNAME)