当主干/分支/标签结构混乱时,如何从 Subversion 迁移到 Mercurial?

发布于 2024-08-18 17:15:09 字数 755 浏览 5 评论 0原文

我想将存储库从 Subversion 转换为 Mercurial,但是当我最初设置存储库时,我以尽可能最懒的方式完成了它。随着时间的推移,该结构不断变形和恶化(此时已有 5 年历史)。尽管如此,我还是想保留尽可能多的历史,即使我必须弄脏并手动将东西缝合在一起。

言归正传,当前的结构如下所示:

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(或 bazaar)中手工重建历史的好方法。

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

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.

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

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

发布评论

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

评论(2

旧情别恋 2024-08-25 17:15:09

一种策略可能是转换主干。如果你的躯干移动了,你可能需要玩一些游戏,但这应该不会太难。

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

这里有一个很好的链接,指向 Mercurial rebase 扩展 的文档。

基本上,这是您要遵循的策略...首先,使用 转换扩展hgsvn 转换存储库的部分内容。这可能会导致多行主干,或者分支位于与主线不同的存储库中。

如果您在不同的存储库中有两个主干部分,并且名为 second 的目录中的部分直接位于名为 first 的目录中的部分,您可以这样做

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>

:将树干的一部分粘贴到树干的另一部分上。

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

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>

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

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.

负佳期 2024-08-25 17:15:09

根据转换扩展程序的文档,类似以下内容应该有效。

$ cat > ~/.hgrc <<EOF
[extensions]
hgext.convert=
EOF
$ hg convert --config convert.svn.trunk trunk/BigProject --config convert.svn.branches branches/BigProject --config convert.svn.tags tags/BigProject svn://svn.example.com/Example newhgrepo

According to the convert extension's docs, something like the following should work.

$ cat > ~/.hgrc <<EOF
[extensions]
hgext.convert=
EOF
$ hg convert --config convert.svn.trunk trunk/BigProject --config convert.svn.branches branches/BigProject --config convert.svn.tags tags/BigProject svn://svn.example.com/Example newhgrepo
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文