当 PC 程序员更新 Mac 程序员最近提交的文件时,SVN diff 将所有代码行标记为新代码
这是我当前遇到的场景:
- 程序员 A(使用 Mac 版本的 Dreamweaver)编辑文件 client.php 并将该文件提交到 Project Foo 存储库的生产分支
- 程序员 B(使用 Windows 版本的 Dreamweaver)编辑文件 client .php 修复该文件中的错误。然后,他执行 cp clientInfo.php ../prod-branch/clientInfo.php 来将该错误修复从他的工作副本转移到生产分支。
- 然后程序员 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:
- 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
- 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. - 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要在所有文本文件上使用“svn:eol-style”属性。通常将其设置为“native”就足够了
You need to use the "svn:eol-style" property on all text files. Usually setting it to "native" will suffice
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.
svn:eol-style
是一个可以在存储库中集中设置的属性,应该可以解决您的问题。查看 有关新行序列的章节。
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.