当 PC 程序员更新 Mac 程序员最近提交的文件时,SVN diff 将所有代码行标记为新代码

发布于 2024-08-20 21:14:05 字数 668 浏览 6 评论 0原文

这是我当前遇到的场景:

  1. 程序员 A(使用 Mac 版本的 Dreamweaver)编辑文件 client.php 并将该文件提交到 Project Foo 存储库的生产分支
  2. 程序员 B(使用 Windows 版本的 Dreamweaver)编辑文件 client .php 修复该文件中的错误。然后,他执行 cp clientInfo.php ../prod-branch/clientInfo.php 来将该错误修复从他的工作副本转移到生产分支。
  3. 然后程序员 B 执行 svn diff ../prod-branch/clientInfo.php 来查看 svn 所说的他的更改,结果却发现 svn 说他更改了文件中的每一行!

现在,我相信正在发生这样的事情:

当 Mac 编辑文件时,Mac 上的 Dreamweaver 会将所有 Windows 换行符替换为 Mac 换行符,以便在 Dreamweaver 中可读。简而言之,Dreamweaver 更改了文件中的每一行。现在,一旦提交完成,svn 就会发现文件的每一行都发生了变化,并标记了这一事实。当 Windows 程序员进行更改并且换行符再次更改时,svn 再次认为每一行都已更改。

我的问题是:我们怎样才能防止这种情况发生?我知道已经无法挽回已经造成的损害,但我想防止这种情况再次发生。

Here's the scenario I'm currently running into:

  1. Programmer A (Using a Mac Version of Dreamweaver) edits file client.php and commits that file to the production branch of Project Foo's repository
  2. Programmer B (Using a Windows Version of Dreamweaver) edits file client.php to fix a bug in the that file. He then does a cp clientInfo.php ../prod-branch/clientInfo.php to take that bug-fix from his working copy to the production branch.
  3. Programmer B then does an svn diff ../prod-branch/clientInfo.php to see what svn says his changes were only to discover that svn says he's changed every line in the file!

Now, this is what I believe is happening:

When the file gets edited by Mac, Dreamweaver on Mac replaces all the Windows newline characters with Mac newline characters so that it's readable in Dreamweaver. In short, Dreamweaver has altered every line in the file. Now, once the commit is done, svn sees that every line of the file has changed and marks this fact down. When the windows programmer makes a change and the newline characters get changed again, svn thinks that, again, every line has changed.

My question is this: How can we prevent this from happening? I know there's no way to undo the damage that's already been done, but I want to prevent this from happening in the future.

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

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

发布评论

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

评论(3

[旋木] 2024-08-27 21:14:05

您需要在所有文本文件上使用“svn:eol-style”属性。通常将其设置为“native”就足够了

You need to use the "svn:eol-style" property on all text files. Usually setting it to "native" will suffice

千仐 2024-08-27 21:14:05

Dreamweaver 可以选择设置它使用的换行符类型。编辑(在 Mac 上:Dreamweaver)->首选项、代码格式、换行符类型。

让您的用户拥有相同的设置,这样事情应该会更好一些。当然,如果您可以将源代码管理设置为忽略换行符差异,那就更好了。

Dreamweaver has an option to set which line break type it uses. Edit (on Mac: Dreamweaver ) -> Preferences, Code Format, Line break type.

Get your users to have the same setting, and things should play a little better together. It would be better, of course, if you can set your source control to ignore line break differences.

绝不放开 2024-08-27 21:14:05

svn:eol-style 是一个可以在存储库中集中设置的属性,应该可以解决您的问题。

查看 有关新行序列的章节

这个问题的解决方案是svn:eol-style属性。当此属性设置为有效值时,Subversion 使用它来确定对文件执行哪些特殊处理,以便文件的行结束样式不会随着来自不同操作系统的每次提交而翻转。有效值为:

svn:eol-style is a property that can be set centrally in the repository and should sort out your problem.

Check out the chapter on New Line Sequences in the Subversion book.

The solution to this problem is the svn:eol-style property. When this property is set to a valid value, Subversion uses it to determine what special processing to perform on the file so that the file's line ending style isn't flip-flopping with every commit that comes from a different operating system. The valid values are:

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