cvs 到 Mercurial 的转换导致标签错误

发布于 2024-08-27 08:18:13 字数 642 浏览 6 评论 0原文

我已经尝试了所有推荐的转换技术

大多数他们设法获取最新版本这些文件是正确的,但是每一个都毁掉了我的历史记录。当我运行“hg up $tag”时,我的 cvs 项目中的许多(大多数?)标签至少有一个文件错误。

我的 cvs 存储库并没有那么复杂。为什么什么都不能转换它? 我想转储简历并转换为 Mercurial,但并非没有历史。

回顾一下我的挫败感:

我尝试了hg Convert (尝试过--branchsort,--timesort,fuzz = 0)

我尝试了cvs2svn然后hg转换。

tailor 不适用于最新版本的 Mercurial

fromcvs 从地球表面消失

hg-cvs-import 已被放弃 4 年,不适用于最新版本的 hg

我尝试使用两个最新版本的 Mercurial ( 1.5 和 1.5.1 )。

I've tried all the recommended conversion techniques

Mostly they manage to get the latest version of the files right, but every one of them trashes my history. Many (most?) of the tags from my cvs project have at least one file in error when I run "hg up $tag"

My cvs repo is not all that complicated. Why can't anything convert it?
I'd like to dump cvs and convert to mercurial, but not without history.

To recap my frustration:

I tried hg convert
(tried --branchsort,--timesort, fuzz=0)

I tried cvs2svn and then hg convert.

tailor does not work with recent versions of mercurial

fromcvs disappeared from the face of the earth

hg-cvs-import has been abandoned for 4 years and doesn't work with recent versions of hg

I have tried using the two most recent versions of mercurial ( 1.5 and 1.5.1 ).

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

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

发布评论

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

评论(4

话少情深 2024-09-03 08:18:13

马克,这是一个次优的解决方案,但是当我所在的一家公司进行了 CVS->Mercurial 迁移时,我们决定我们关心的只是标签快照,因此我们构建了一个小的 for 循环,例如

for thetag in $(cat LIST_OF_RELEASE_TAGS) ; do
   cvs update -r $thetag
   hg commit --addremove -m "snapshot $thetag" -u "import"
   hg tag $thetag
done

:标签,但我们只拉入主/生产分支。更复杂的循环将在每次提交之前调用“hg update”以获取反映 CVS 分支的起源。

这绝对不是“完整的历史”,但它足以让我们对继续使用 Mercurial 感觉良好,同时又不会失去说“1.1.11 版本到底是什么?!”的能力。我们总是可以回到 cvs,因为需要 cvs 责任级别历史记录。

Mark, it's a sub-optimal solution, but when a company I was with did a CVS->Mercurial migration we decided that all we cared about were tag snapshots, so we build a little for loop like:

for thetag in $(cat LIST_OF_RELEASE_TAGS) ; do
   cvs update -r $thetag
   hg commit --addremove -m "snapshot $thetag" -u "import"
   hg tag $thetag
done

That assumed a linear chain of tags, but we only pulled in the main/production branch. A more sophisticated loop would call 'hg update' before each commit to get parentage that reflects CVS branching.

It's definitely not "full history" but it was enough to make us feel good about continuing in Mercurial without loosing our ability to say "What the hell was in version 1.1.11?!" and we could always go back to cvs is cvs blame level history was needed.

终弃我 2024-09-03 08:18:13

fromcvs 回来了。我正在我们的一个非常大的存储库上对其进行测试,它的速度非常快并且可以处理增量转换。

fromcvs is back. I'm testing it out on a very large repo of ours, and it's extremely fast and handles incremental conversion.

む无字情书 2024-09-03 08:18:13

我找到了某种解决方案。我对此并不感到兴奋,但现在必须这样做。
我能够检测到导致问题的标签,并从转换中忽略这些标签。缺少标签比错误标签好得多(假设保留原始 cvs 存储库进行备份)

警告:以下内容假设您已经制作了 CVSROOT 的副本并且正在处理该副本。不要弄乱你的原件。

这是一个在我的 Linux 机器上适用的 bash 解决方案。它可能会烧毁你的房子,并邀请你小学的恶霸搬到你隔壁。你已被警告过。

它使用cvsps来识别问题标签,使用rcs来删除它们,然后从CVSROOT/历史记录中删除这些标签。删除 cvsps 缓存后,hg 转换按预期工作。

CVSROOT=/path/to/your/copy
MODULE=cvsmodule
rm -rf ~/.cvsps ~/.hg.cvsps # this cache is EVIL!

BADTAGS="`cvsps -q -x $MODULE |grep Tag: |grep -e FUNKY -e INVALID | awk '{print $2}' `"
while [ ! -z "$BADTAGS" ];do
    cd $CVSROOT/$MODULE
    for badtag in $BADTAGS;do
      echo removing tag $badtag
      grep -lr $badtag . | xargs --no-run-if-empty -l1 rcs -q -n$badtag
      grep -v "$badtag|$MODULE" < $CVSROOT/CVSROOT/history > $CVSROOT/CVSROOT/history_
      mv $CVSROOT/CVSROOT/history_  $CVSROOT/CVSROOT/history
    done
    BADTAGS="`cvsps -q -x $MODULE |grep Tag: |grep -e FUNKY -e INVALID | awk '{print $2}' `"
done
rm -rf ~/.cvsps ~/.hg.cvsps # this cache is EVIL!
mkdir ~/hgcvt
cd ~/hgcvt
cvs co $MODULE
hg convert $MODULE

I found a solution of sorts. I'm not thrilled with it, but it will have to do for now.
I was able to detect the tags that were causing trouble and omit those tags from the conversion. Missing tags are much better than wrong tags (assuming the original cvs repo is kept for backup)

WARNING: The following assumes you have made a copy of CVSROOT and are working on that. Do not muck with your original.

This is a bash solution that works for me on my linux box. It will probably burn your house down and invite your grade school bully to move next door to you. You've been warned.

It uses cvsps to identify the problem tags, rcs to delete them and then removes the tags from the CVSROOT/history. After removing the cvsps cache, the hg conversion works as expected.

CVSROOT=/path/to/your/copy
MODULE=cvsmodule
rm -rf ~/.cvsps ~/.hg.cvsps # this cache is EVIL!

BADTAGS="`cvsps -q -x $MODULE |grep Tag: |grep -e FUNKY -e INVALID | awk '{print $2}' `"
while [ ! -z "$BADTAGS" ];do
    cd $CVSROOT/$MODULE
    for badtag in $BADTAGS;do
      echo removing tag $badtag
      grep -lr $badtag . | xargs --no-run-if-empty -l1 rcs -q -n$badtag
      grep -v "$badtag|$MODULE" < $CVSROOT/CVSROOT/history > $CVSROOT/CVSROOT/history_
      mv $CVSROOT/CVSROOT/history_  $CVSROOT/CVSROOT/history
    done
    BADTAGS="`cvsps -q -x $MODULE |grep Tag: |grep -e FUNKY -e INVALID | awk '{print $2}' `"
done
rm -rf ~/.cvsps ~/.hg.cvsps # this cache is EVIL!
mkdir ~/hgcvt
cd ~/hgcvt
cvs co $MODULE
hg convert $MODULE
提笔书几行 2024-09-03 08:18:13

我现在意识到 cvs 标签和 hg 标签之间存在某些根本的不兼容性。

在 cvs 中,文件的一个版本具有与其不同版本相关联的标签。

在 hg 中,版本是变更集的别名。换句话说,工作文件在某个时间快照的状态

这种区别很微妙,但很重要。

可以在 cvs 中对不及时代表快照的版本进行标记发布。这在汞中是不可能的。

当然,可以应用补丁来获取副本。然而,这会在存储库上创建大量新头,但几乎没有什么好处(假设 cvs 存储库仍然保留给后代)。

恐怕从 cvs 到 Mercurial 的完美转换是不切实际的。 Ry4an 的解决方案适用于那些只关心重新创建版本的人。我对源文件的历史和演变更感兴趣。

我编写了以下脚本,以便在转换之前简单地清除 $CVSROOT 中的所有 cvs 标记。例如,标签“v321”变为“v321_prehg”。这样开发人员就会知道这些标签不具有权威性,他们必须返回到只读 cvs 树。

#!/usr/bin/python
import os
import sys
import stat

def die(msg):
    sys.stderr.write(msg)
    sys.exit(1)

cvsroot =os.getenv("CVSROOT")
if cvsroot is None:
    die("CVSROOT not defined" )

print "CVSROOT=%s" % cvsroot

for rcsfile in os.popen("find %s -name '*,v'" % cvsroot).xreadlines():
    rcsfile = rcsfile.replace('\n','')
    print "rcsfile:%s" % rcsfile
    st=os.stat(rcsfile)
    if  st.st_mode & stat.S_IWUSR == 0:
        os.chmod(rcsfile,st.st_mode | stat.S_IWUSR)

    f = open(rcsfile,"r")
    inlines=f.readlines()
    f.close()

    outlines=[]
    insymbols=False
    symbolsDone=False
    for l in inlines:
        if insymbols and not symbolsDone:
            if l.find('\t') == 0:#tag line
                l= l.replace(":","_prehg:",1)
            else:
                symbolsDone=True
        else:
            if l == "symbols\n":
                insymbols=True
        outlines.append(l)

    f = open(rcsfile,"w")
    f.writelines( outlines )
    f.close()

I realize now that there are certain fundamental incompatibilities between cvs tags and hg tags.

In cvs, a version of a file have tags associated with its different versions.

In hg, a version is an alias for a changeset . In other words the state of the working files at some snapshot in time

The distinction is subtle, but important.

It is possible to make a tagged release in cvs of a version that does not represent a snapshot in time. This is not possible in hg.

Of course one could apply patches to get replicas. However, this would create a lot of new heads on the repository with arguably little benefit (assuming the cvs repo is still kept around for posterity).

I'm afraid a perfect conversion from cvs to mercurial is not practical. Ry4an's solution would work for those who care only about recreating the versions. I am more interested in the history and evolution of the source files.

I wrote the following script to simply munge all the cvs tags in the $CVSROOT prior to the conversion. e.g tag "v321" becomes "v321_prehg". That way developers will know those tags are not-authoritative and they must go back to the read-only cvs tree.

#!/usr/bin/python
import os
import sys
import stat

def die(msg):
    sys.stderr.write(msg)
    sys.exit(1)

cvsroot =os.getenv("CVSROOT")
if cvsroot is None:
    die("CVSROOT not defined" )

print "CVSROOT=%s" % cvsroot

for rcsfile in os.popen("find %s -name '*,v'" % cvsroot).xreadlines():
    rcsfile = rcsfile.replace('\n','')
    print "rcsfile:%s" % rcsfile
    st=os.stat(rcsfile)
    if  st.st_mode & stat.S_IWUSR == 0:
        os.chmod(rcsfile,st.st_mode | stat.S_IWUSR)

    f = open(rcsfile,"r")
    inlines=f.readlines()
    f.close()

    outlines=[]
    insymbols=False
    symbolsDone=False
    for l in inlines:
        if insymbols and not symbolsDone:
            if l.find('\t') == 0:#tag line
                l= l.replace(":","_prehg:",1)
            else:
                symbolsDone=True
        else:
            if l == "symbols\n":
                insymbols=True
        outlines.append(l)

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