【问题标题】:Subversion freaking out on me!颠覆吓到我了!
【发布时间】:2010-05-14 18:11:18
【问题描述】:

我有一个站点的两个副本,一个是生产副本,另一个是开发副本。我最近将生产中的所有内容添加到托管在我们的 linux 备份服务器上的 subversion 存储库中。我创建了当前版本的标签,我已经完成了。

然后,我将开发副本复制到生产副本之上(在我已检查所有内容的本地计算机上)。只更改了 10-20 个文件,但是,当我使用 tortoise SVN 进行提交时,它说每个文件都已更改。生成的 diff 文件显示 subversion 删除了所有内容,并将其替换为新版本(完全相同)。

发生了什么事?我该如何解决?

一个示例差异:

Index: C:/Users/jhollon/Documents/Visual Studio 2008/Projects/saloon/trunk/components/index.html
===================================================================
--- C:/Users/jhollon/Documents/Visual Studio 2008/Projects/saloon/trunk/components/index.html   (revision 5)
+++ C:/Users/jhollon/Documents/Visual Studio 2008/Projects/saloon/trunk/components/index.html   (working copy)
@@ -1,4 +1,4 @@
-<html>
-<body bgcolor="#FFFFFF">
-</body>
+<html>
+<body bgcolor="#FFFFFF">
+</body>
 </html>
\ No newline at end of file

【问题讨论】:

  • 这听起来像是newlines 的问题:也许他们以某种方式转换为 CRLF?
  • 我猜这是行尾问题。使用显示行尾标记的工具查看差异,您会发现它们是不同的。 :)
  • 确定是否存在行尾问题的最快方法是通过od -c 管道输出,然后寻找提示\r

标签: svn


【解决方案1】:

这可能是行尾不匹配。为所有文件设置属性svn:eol-style=native

http://svnbook.red-bean.com/en/1.5/svn.advanced.props.file-portability.html#svn.advanced.props.special.eol-style

默认情况下,您可以让 Subversion 为所有新文件设置此属性:

http://svnbook.red-bean.com/en/1.5/svn.advanced.props.html#svn.advanced.props.auto

这是我的 ~/.subversion/config 中的内容:

enable-auto-props = yes

### Section for configuring automatic properties.
[auto-props]
### The format of the entries is:
###   file-name-pattern = propname[=value][;propname[=value]...]
### The file-name-pattern can contain wildcards (such as '*' and
### '?').  All entries which match will be applied to the file.
### Note that auto-props functionality must be enabled, which
### is typically done by setting the 'enable-auto-props' option.
*.c = svn:eol-style=native
*.cpp = svn:eol-style=native
*.h = svn:eol-style=native
# *.dsp = svn:eol-style=CRLF
# *.dsw = svn:eol-style=CRLF
*.sh = svn:eol-style=native;svn:executable=*
*.txt = svn:eol-style=native
*.png = svn:mime-type=image/png
*.jpg = svn:mime-type=image/jpeg
*.jpeg = svn:mime-type=image/jpeg
Makefile = svn:eol-style=native
*.tmpl = svn:eol-style=native
*.gif = svn:mime-type=image/gif
*.t = svn:eol-style=native;svn:executable=*
*.pm = svn:eol-style=native
*.pl = svn:eol-style=native;svn:executable=*
*.cgi = svn:eol-style=native;svn:executable=*
*.js = svn:eol-style=native;svn:mime-type=application/x-javascript
*.dtd = svn:eol-style=native;svn:mime-type=application/xml-dtd
*.txt = svn:eol-style=native;svn:mime-type=text/plain
*.html = svn:eol-style=native;svn:mime-type=text/html
*.yicf = svn:eol-style=native
*.xml = svn:eol-style=native;svn:mime-type=text/xml
*.sgml = svn:eol-style=native;svn:mime-type=text/sgml
*.xul = svn:mime-type=application/vnd.mozilla.xul+xml
*.tt = svn:eol-style=native

【讨论】:

  • 就是这样,新版有/n,旧版有/r/n
【解决方案2】:

我看到您使用的是 Visual Studio,所以可能与文件编码有关?我在两台不同的机器上对源文件进行不同的 VS 编码时遇到了奇怪的问题,即使这些机器具有相同的语言和文化设置。在 VS 中,源代码看起来完全一样,但 SVN 看到的是原始文件...

在对 Unicode 或编码一无所知的编辑器中打开这两个修订版(我想我用的是记事本?),看看它们是否不同。该文件的第一行包含一个代码,该代码指示正在使用的编码类型。我不知道如何解释该代码,但至少您可以分辨它们是否不同。

工具 -> 选项 -> 环境 -> 控制编码的文档中有选项。

【讨论】:

  • 实际上,我没有使用 Visual Studio,它只是被放入该目录,因为这是我保存所有项目的地方。它实际上与 Dreamweaver 一起使用
【解决方案3】:

听起来这个问题已经得到很好的回答(EOL 风格)。我只是想添加另一件事可能会引发这样的问题:Tabs vs Spaces。如果您的文本编辑器或 IDE 使用空格进行缩进,而您团队中的其他人使用制表符,则 SVN 会看到大量文件更改,但您不会“看到”这些更改。

【讨论】:

    【解决方案4】:

    短期解决方案(检查两个版本之间的差异):检查两个版本以在两个单独的目录中进行比较,并使用外部差异工具比较目录(linux中的meld,windows中的winmerge)。这些工具可以配置为忽略行尾差异。

    编辑:对于其余的,使用 David M 的解决方案(不知道 SVN 可以管理...)

    【讨论】:

    • 是的,不要创建 Subversion 挂钩来欺骗 EOL 字符。你可以明确你想要什么。 svn:eol-style=native 是正确的选择,除非您有充分的理由去做其他事情。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-09
    相关资源
    最近更新 更多