CVS 和 Subversion 可以设置为忽略合并中的空格吗?
CVS 和 Subversion 都有一个方便的合并功能,因此当您更新已修改的源文件时,它会合并其他人对同一文件所做的更改。
但是,如果您的更改与其他更改不兼容(通常如果您都更改了代码的相同部分),则会产生冲突。 这两段源代码都将包含在合并的文件中,您需要手动找出要保留的更改。 到目前为止一切都很好。
我的问题是,我们中的一些人使用不同的开发环境(Netbeans 与 vi,如果您必须知道的话),并且 Netbeans 具有自动缩进功能,可以重新缩进代码。 因此,当我们合并更改时,有时会遇到巨大的冲突,这些冲突大多是由缩进的简单更改引起的,而不是对代码的真正更改。 通常,这些会产生数百行明显的冲突,必须手动解决,但通常它们会归结为只有几行实际更改。 当某人的编辑器将 UNIX 更改为 Windows 换行符或反之亦然时,会发生类似的情况。
那么 - 在比较两个版本时我可以设置合并来忽略这些“冲突”吗? Diff 有 --ignore-space-change 或 -b 选项,我希望在 cvs 或 svn 中具有基本相同的功能。 我们在不同的项目中使用每种工具,因此我很乐意获得其中一个或两者的答案。
最后两个注意事项:
- 显然,合并过程必须任意选择在合并文件中使用哪个版本的空白。 我对此很满意 - 我们以后可以随时重新格式化它。
- 我可以通过更加自律和更频繁地检查——承认和理解来避免这种情况。 但我并不完美。
CVS and Subversion both have a handy merge feature so that when you update a source file that you have modified, it merges in changes that others have made on the same file.
However, if your changes and the other ones are incompatible - generally if you have both changed the same parts of the code - it will create a conflict. Both stretches of source code will be included into the merged file and you need to manually sort out which changes to keep. All fine so far.
My problem is that some of us use different development environments (Netbeans versus vi if you must know) and Netbeans has an auto-indenting feature which re-indents the code. Therefore, when we merge changes, we sometimes get huge conflicts which are mostly caused by simple changes in indentation and are not genuine changes to code. Often these create hundreds of lines of apparent conflicts which have to be manually resolved, but usually they come down to just a few lines of real changes. A similar situation occurs when someone's editor changes unix to Windows newlines or vice versa.
So - can I set merge to ignore these "conflicts" when comparing the two versions? Diff has the --ignore-space-change or -b option and I would like to have essentially the same feature available in cvs or svn. We use each tool on different projects so I would be happy to have the answer for either or both.
Two final notes:
- clearly the merge process would have to make an arbitrary choice as to which version of the whitespace to use in the merged file. I'm fine with that - we can always reformat it again later.
- I could avoid some of this by being more disciplined and checking in more often - acknowledged and understood. But I am not perfect.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于 SVN:在命令行工具中,有一个选项 -x,您可以将其设置为“b”或“w”以忽略空间更改分别。 所有空格。
您还可以提供第三方工具来进行合并。 因此,如果您有一个忽略空格的合并,则可以使用这个。
TortoiseSVN 一如既往,是所有参数的前端,因此它也支持忽略空格。
svn merge 命令描述 在这里。 您需要的选项是--diff3-cmd
For SVN: In commandline tool, there is the option -x which you can set to "b" or "w" to ignore space changes resp. all spaces.
You can also supply a third party tool for doing the merges. So if you have a merger which ignores whitespaces, you can use this one.
TortoiseSVN, as always, is a frontend to all parameters, so it will support for ignoring whitespaces as well.
The svn merge command is described here. The option you need is --diff3-cmd
对于 Windows 用户,您可以使用 TortoiseSVN(Subversion 的 Windows 资源管理器 shell 扩展),它随 合并支持您所描述内容的功能:
For Windows users, you can use TortoiseSVN (a Windows Explorer shell extension for Subversion) which comes with merge features that support what you are describing:
TortoiseMerge 没有任何 CLA(命令行参数)来忽略空格并忽略大小写。 经过一番查找,似乎还是可以通过调整注册表值来实现。
TortoiseMerge doesn't have any CLA (Command Line Arguments) to ignore the whitespace and ignore the case. After searching a lot it seems that it can be achieved still by tweaking the registry values.