当主干/分支/标签结构一团糟时,如何从 Subversion 迁移到 Mercurial? [英] How to migrate from Subversion to Mercurial when the trunk/branch/tag structure is a mess?

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

问题描述

我想将存储库从 Subversion 转换为 Mercurial,但是当我最初设置存储库时,我以最懒惰的方式进行了操作.随着时间的推移,该结构继续变形和恶化(此时它已有 5 年历史).尽管如此,我还是想尽可能多地保留历史,即使我必须弄脏并手动将它们重新拼接在一起.

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
        + ...

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

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).

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

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.

您的武器库中的另一个工具可能是 hg->hg 转换和 rebase 扩展.在 hg 存储库中有东西后,您可以使用它们来摆弄您的树,并在转换它们后移植到树枝上.或者在移动后移植你的树干历史的新片段.

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.

这里是 Mercurial rebase extension 文档的一个很好的链接.

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

基本上,这是您要遵循的策略...首先,使用 convert extensionhgsvn 转换部分存储库.这可能会导致多行主干,或在与主线不同的存储库中的分支.

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.

如果您在不同的存储库中有两个主干部分,并且目录中名为 second 的部分直接跟随目录中名为 first 的部分,则可以执行以下操作:

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.

这篇关于当主干/分支/标签结构一团糟时,如何从 Subversion 迁移到 Mercurial?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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