当trunk / branch / tag结构混乱时,如何从Subversion迁移到Mercurial? [英] How to migrate from Subversion to Mercurial when the trunk/branch/tag structure is a mess?

查看:100
本文介绍了当trunk / branch / tag结构混乱时,如何从Subversion迁移到Mercurial?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将一个版本库从Subversion转换为Mercurial,但是当我最初设置版本库时,我是以最懒惰的方式完成的。随着时间的推移,结构继续变形并恶化(此时已有5年)。尽管如此,我仍希望保留尽可能多的历史记录,即使我必须弄脏并手工缝合一些东西。



毫无疑问,当前的结构看起来像这样:

  svn://svn.example.com/示例
+主干
+ BigProject
+ BinaryDepedencies
+ branches
+ BigProject
+ branch1
+ feature1
+ maintenance1
+ ...
+标签
+ BigProject
+ tag1
+ tag2
+ ...
+项目
+ small_project1
+ small_project2
+ small_project3
+ ...

鉴于这只是最近的结构,有没有任何希望这个存储库?如果没有希望,任何人都有一个很好的方法来在Mercurial(或集市)手动重建历史。

另外,由于各种原因,我不会能够使用git,除非有一个防弹策略将这个特定的repo从Subversion转换为git到hg / bzr。

可能是转换主干。如果你的箱子已经移动,你可能需要玩一些游戏,但它不应该太难。



你的武器库中的另一个工具可能是hg-> hg转换和延期的延期。您可以使用这些工具在您将某个物品存放在hg存储库中并在您转换它们之后在分支上进行嫁接之后,使用它们来摆弄您的树。或者在移动之后将其移植到新的历史记录中。



以下链接指向 Mercurial rebase extension

基本上,您应遵循以下策略......首先,使用转换扩展名 hgsvn 来转换部分存储库。这可能会导致多行中继线,或在与主线分开存放的分支中。



如果在不同的存储库中有两段中继线,在名为 second 的目录中直接跟在名为 first 的目录下,你可以这样做:

  cd第二个
hg log -r 0
#请注意修订散列
cd ../first
hg tip
#再次注意修订哈希
hg pull -f ../second
hg rebase --source< hg log -r 0>修订哈希> - 来自hg tip的最新修订散列>

这将把一段干线接到另一段干线上。



如果您在单独的存储库中有一个分支,则该过程稍微复杂一些:

  cd branch 
hg log -r 0
#注意修订散列
cd ../trunk
#查找分支从其分支并注意其散列的修订。
#我们将此修订称为分支基础。
hg pull -f ../branch
hg rebase --source< hg log中的修订散列-r 0> - 最新<分支基础的修订散列>

这会将分支移植到主树上。


I'd like to convert a repository from Subversion to Mercurial, but when I initially set up the repository, I did it in the laziest way possible. Over time, the structure continued to morph and deteriorate (it's 5 years old at this point). Nevertheless, I'd like to preserve as much history as possible, even if I have to get dirty and manually stitch things back together.

Without further ado, the current structure looks like so:

svn://svn.example.com/Example
    + trunk
        + BigProject
        + BinaryDepedencies
    + branches
        + BigProject
            + branch1
            + feature1
            + maintenance1
            + ...
    + tags
        + BigProject
            + tag1
            + tag2
            + ...
    + projects
        + small_project1
        + small_project2
        + small_project3
        + ...

Given that this is just the most recent structure, is there any hope for this repository? If there is no hope, anyone have a good approach for rebuilding the history by hand in Mercurial (or bazaar).

Also, for various reasons, I won't be able use git unless there is a bulletproof strategy to convert this specific repo from Subversion to git to hg/bzr.

解决方案

One strategy might be to convert the trunk. You might have to play some games if your trunk has moved, but it shouldn't be too hard.

Another tool in your arsenal might be hg->hg conversion and the rebase extension. You can use those to fiddle around with your tree after you have things in an hg repository and graft on branches after you've converted them. Or graft in new pieces of your trunk history after its moved.

Here is a nice link to documentation on the Mercurial rebase extension.

Basically, here's the strategy you would follow... First, use the convert extension or hgsvn to convert parts of the repository. This may result in multiple lines of trunk, or in branches that are in a separate repository from the mainline.

If you have two sections of trunk in separate repositories and the one in the directory called second directly follows the one in the directory called first, you can do this:

cd second
hg log -r 0
# Note the revision hash
cd ../first
hg tip
# Again, note the revision hash
hg pull -f ../second
hg rebase --source <revision hash from hg log -r 0> --dest <revision hash from hg tip>

That will graft one section of trunk onto another section of trunk.

If you have a branch in a separate repository, the procedure is slightly trickier:

cd branch
hg log -r 0
# Note the revision hash
cd ../trunk
# Find the revision that the branch branches off from and note its hash.
# We will call this revision the 'branch base'.
hg pull -f ../branch
hg rebase --source <revision hash from hg log -r 0> --dest <revision hash of branch base>

That will graft the branch onto the main tree.

这篇关于当trunk / branch / tag结构混乱时,如何从Subversion迁移到Mercurial?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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