cvs2svn 包括单分支和头吗?

发布于 2024-08-02 08:17:29 字数 206 浏览 5 评论 0原文

我正在使用 cvs2svn 来转换我的存储库。我已经在一个存储库中成功完成了这一任务,现在我的新问题是第二个存储库。

在我的新转换中,我只想转换 HEAD 和一个分支。 cvs2svn 对于分支只有“排除”功能,但没有“包含”功能。我有很多分支,排除每一个分支都需要大量工作......

有什么方法可以只转换主干(HEAD)和一个分支?

谢谢, 奥德

I'm using cvs2svn to convert my repository. I've done it with success in one repository, and now my new problem is a second repository.

In my new conversion, I want to convert only the HEAD and one branch. cvs2svn only have "exclude" function for branches, but not "include". I have many many branches and excluding each and every one of them will take A LOT of work....

is there any way to convert only the trunk (HEAD) and only one branch?

thanks,
Oded

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

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

发布评论

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

评论(2

北渚 2024-08-09 08:17:29

如果您只想保留一个分支而不保留任何标签,那么这很简单。使用与符号匹配的第一个规则,因此指定要包含的分支,然后排除其他所有内容:

cvs2svn --force-branch=mybranch --exclude='.*' ...

如果您不仅想包含分支,还想包含尽可能多的标签,那么这就有点棘手了。您不仅不必知道所有标记的名称,而且也不能包含依赖于排除分支的标记。在这种情况下,最简单的方法是使用 --write-symbol-info 和 --symbol-hints 选项:

cvs2svn --write-symbol-info=symbol-info.out --passes=1:3 ...

这将创建一个名为“symbol-info.out”的文件,其中包含有关所有 CVS 符号的信息。在编辑器中,打开此文件,找到与要排除的分支相对应的所有行,并将这些行的第三列更改为单词“排除”。确保要包含的分支所在行的第三列包含单词“branch”,第四列是您希望其结束的路径。

现在再次运行 cvs2svn,从第 3 步开始,并使用编辑后的符号信息文件作为符号提示文件:

cvs2svn --symbol-hints=symbol-info.out --passes=3 ...

您将收到很多错误,例如:

ERROR: ExcludedSymbol('FOO_BRANCH') cannot be excluded because the following symbols depend on it:
    BAR_TAG
    BAZ_TAG

现在返回编辑器并更改列出的标签(示例)也被排除,然后尝试再次运行 pass3。此过程可能需要迭代几次,但应该不会很麻烦,因为 pass3 运行得非常快。

当 pass3 顺利完成后,运行剩余的转换:

cvs2svn --symbol-hints=symbol-info.out --passes=4: ...

If you only want to retain the one branch and no tags, then this is easy. The first rule that matches a symbol is used, so specify the branch that you want to be included then exclude everything else:

cvs2svn --force-branch=mybranch --exclude='.*' ...

If you want to include not only the branch but also as many tags as possible, then it is a little bit trickier. Not only don't you necessarily know the names of all of the tags, but you also cannot include tags that are dependent on excluded branches. In this case, it is easiest to work with the --write-symbol-info and --symbol-hints options:

cvs2svn --write-symbol-info=symbol-info.out --passes=1:3 ...

This will create a file called "symbol-info.out" containing information about all CVS symbols. In your editor, open this file, find all of the lines corresponding to branches that you want to exclude, and change the third column of those lines to the word "exclude". Make sure that the third column of the line for the branch that you want to include contains the word "branch" and its fourth column is the path where you want it to end up.

Now run cvs2svn again, starting at pass 3, and using the edited symbol-info file as a symbol hints file:

cvs2svn --symbol-hints=symbol-info.out --passes=3 ...

you will get a lot of errors like:

ERROR: ExcludedSymbol('FOO_BRANCH') cannot be excluded because the following symbols depend on it:
    BAR_TAG
    BAZ_TAG

Now go back into the editor and change the listed tags (BAR_TAG and BAZ_TAG in the example) to be excluded too, then try running pass3 again. This procedure might need to be iterated a couple of times, but it should not be cumbersome because pass3 runs very quickly.

When you have gotten pass3 to complete without errors, run the rest of the conversion:

cvs2svn --symbol-hints=symbol-info.out --passes=4: ...
_畞蕅 2024-08-09 08:17:29

一个问题是 cvs2svn 不仅需要确定是否包含分支,还需要(同时)首先确定符号是分支还是标签。因此,如果您想包含该一个分支以及一些标签,那么比仅仅说“仅包含该分支”更困难 - 这样做会杀死所有标签。

IOW,cvs2svn 并不真正支持这一点。您可以通过编辑其源代码来解决此问题。在cvs2svn_lib.symbol_strategy.BranchIfCommits中,将其返回Branch(symbol)的情况更改为

   if symbol.name == 'my_branch':
       return Branch(symbol)
   else:
       return ExcludedSymbol(symbol)

IIUC,默认情况下应使用BranchIfCommits。

就我个人而言,我会使用不同的策略:

 1. convert the repository once, with all branches.
 2. do a "svn ls" on branches, and redirect that into a file.
 3. edit the file to construct an exclude regex out of it, of the form `b1|b2|...|bn`

我不会称之为大量工作......

One problem is that cvs2svn not only needs to determine whether to include a branch or not, but (simultaneously) whether a symbol is a branch or a tag in the first place. So if you want to include that one branch, and also some tags, it's more difficult than just saying "include only that branch" - doing so would kill all tags.

IOW, cvs2svn doesn't really support that. You can work around by editing its source code. In cvs2svn_lib.symbol_strategy.BranchIfCommits, change the case where it returns Branch(symbol) to

   if symbol.name == 'my_branch':
       return Branch(symbol)
   else:
       return ExcludedSymbol(symbol)

IIUC, BranchIfCommits should be used by default.

Personally, I would use a different strategy:

 1. convert the repository once, with all branches.
 2. do a "svn ls" on branches, and redirect that into a file.
 3. edit the file to construct an exclude regex out of it, of the form `b1|b2|...|bn`

I wouldn't call that a LOT of work...

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