cvs2svn 失败并显示“xxx 不是有效的 ,v 文件”

发布于 2024-07-18 16:55:31 字数 197 浏览 6 评论 0原文

当我想发帖的时候终于找到了我的问题的答案! 不过,我仍然会发布它,包括我的答案,以防它对其他人有帮助:

当从 CVS 转换为 Subversion cvs2svn 在某些文件上失败时,并显示消息

"xxx is not a valid ,v file"

What's the Problem?

I finally found an answer to my question when I wanted to post it! However I'll still post it, including my answer, in case it helps someone else:

When converting from CVS to Subversion cvs2svn failed on some files with the message

"xxx is not a valid ,v file"

What's the problem?

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

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

发布评论

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

评论(4

一人独醉 2024-07-25 16:55:31

事实证明,CVSNT 忽略了 cvs2svn 需要的某些文件中的最后一个 0xa。 使用以下 C# 代码可以轻松修复此问题:

static void Main(string[] args)
{
  foreach (string file in Directory.GetFiles(args[0], "*,v", SearchOption.AllDirectories))
  {
    using (FileStream sin=File.Open(file, FileMode.Open, FileAccess.ReadWrite))
    {
      sin.Position=sin.Length-1;
      if (sin.ReadByte()==0x40)
      {
        Console.WriteLine("fixed "+file);
        sin.WriteByte(0xa);
      }
    }
  }
}

As it turns out CVSNT omits the last 0xa from some files where cvs2svn needs them. This can be easily fixed with the following c# code:

static void Main(string[] args)
{
  foreach (string file in Directory.GetFiles(args[0], "*,v", SearchOption.AllDirectories))
  {
    using (FileStream sin=File.Open(file, FileMode.Open, FileAccess.ReadWrite))
    {
      sin.Position=sin.Length-1;
      if (sin.ReadByte()==0x40)
      {
        Console.WriteLine("fixed "+file);
        sin.WriteByte(0xa);
      }
    }
  }
}
花开雨落又逢春i 2024-07-25 16:55:31

就我而言,xxx,v 文件的 symbols 部分已损坏。 预期格式为 tag_name:tag_rev,但存在以下情况:

  • 缺少 :tag_rev
    例如tag_name
    通过删除该行来修复。
  • 多个tag_name
    例如tag_name1:tag_name2:tag_rev< /code>
    通过删除第二个标签名称来修复(您删除的标签名称可能取决于它们是什么)。
  • 名称/修订分隔符无效。 在我的例子中,无效字符始终是 z (ASCII :z 之间只有 1 位差异)。
    eg < code>tag_nameztag_rev
    通过将 z 替换为 : 进行修复。

为了在调查过程中提供帮助,我在 cvs2svn_rcsparse\common.py 中添加了 print 行。 如果解析符号失败,则原因是最后打印的标签。

def _parse_admin_symbols(self, token):
while 1:
  tag_name = self.ts.get()
  # WileCau print the token and tag_name
  print 'token=|%s| tag_name=|%s|' % (token, tag_name)
  if tag_name == ';':
    break
  self.ts.match(':')
  tag_rev = self.ts.get()
  self.sink.define_tag(tag_name, tag_rev)

额外的打印会给输出添加相当多的噪音,因此仅在发生异常时打印可能会更好,但这足以满足我的需求。


我还发现这个链接,结果不是我的问题,但可能对其他人有帮助。 感谢 Christian Haarmann 对其进行了记录。

http://tigris-scm.10930.n7.nabble.com/suggestions-for-cvs2svn-fix-for-error-quot-myfile-txt-v -is-not-a-valid-v-file-quot-td54240.html

如果链接无效,摘要是有人编辑了 xxx,v 文件及其编辑器已将 0x0A (LF) 替换为 0x0D/0x0A (CR/LF),附加字符导致解析器认为文件已损坏。

In my case there was corruption in the symbols section of the xxx,v file. The expected format is tag_name:tag_rev, but there were instances of:

  • Missing :tag_rev
    e.g. tag_name
    Fixed by deleting the line.
  • Multiple tag_name
    e.g. tag_name1:tag_name2:tag_rev
    Fixed by removing the second tag name (which one you remove probably depends on what they are).
  • Invalid name/revision delimiter. In my case the invalid character was always z (there is only 1-bit difference between ASCII : and z).
    e.g. tag_nameztag_rev
    Fixed by replacing the z with :.

To help during my investigation I added a print line to cvs2svn_rcsparse\common.py. If parsing the symbols fails, the last tag printed is the cause.

def _parse_admin_symbols(self, token):
while 1:
  tag_name = self.ts.get()
  # WileCau print the token and tag_name
  print 'token=|%s| tag_name=|%s|' % (token, tag_name)
  if tag_name == ';':
    break
  self.ts.match(':')
  tag_rev = self.ts.get()
  self.sink.define_tag(tag_name, tag_rev)

The additional print adds quite a lot of noise to the output so it might be nicer to only print if an exception happens, but this was good enough for my needs.


I also found this link which turned out to not be my problem but may help someone else. Credit to Christian Haarmann for documenting it.

http://tigris-scm.10930.n7.nabble.com/suggestions-for-cvs2svn-fix-for-error-quot-myfile-txt-v-is-not-a-valid-v-file-quot-td54240.html

In case the link becomes invalid, the summary is that someone had edited the xxx,v file and their editor had replaced 0x0A (LF) with 0x0D/0x0A (CR/LF), and the additional character caused the parser to think the file was corrupt.

在你怀里撒娇 2024-07-25 16:55:31

我也有这样的错误。 当我使用 cvs2git 将 cvs 存储库迁移到 git 时,多个文件都会出现此错误。 我检测到文件末尾缺少结束 0x40 (@)

所以我的解决方案是:

1. Open the corrupted cvs-history-file e.g. with vim (maybe in binary mode)
2. Add the missing @

如果这不能解决问题,则将损坏文件的内容与 RCS 文件格式进行比较: rcs_man_page

I've also such an error. When I use cvs2git in order to migrate a cvs repository to git, this error occurs for several files. I have detected that there is missing a closing 0x40 (@) at the end of file.

So my solution is:

1. Open the corrupted cvs-history-file e.g. with vim (maybe in binary mode)
2. Add the missing @

If this doesn't fix the problem, then compare the content of the corrupted file with the RCS-file format: rcs_man_page

彻夜缠绵 2024-07-25 16:55:31

解决此问题的一种方法是运行 rcs log *file,v* ,这可能会为您提供一些见解。

就我而言,我有一些文件缺少@,一些文件缺少分号,并且我用来将旧存储库导入到 cvspserver 的工具已抛出未引用的版本。

祝你好运!

One way to troubleshoot this is to run rcs log *file,v*, which may provide you some insight.

In my case, I had some files missing @'s, some files missing a semicolon, and the tool I used to import my old repository onto the cvspserver had thrown in an unreferenced version.

Good luck!

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