Can CVS and Subversion be set to ignore whitespace in merging?

流过昼夜 提交于 2019-12-03 04:44:59

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

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:

Ignore line endings excludes changes which are due solely to difference in line-end style.

Compare whitespaces includes all changes in indentation and inline whitespace as added/removed lines.

Ignore whitespace changes excludes changes which are due solely to a change in the amount or type of whitespace, eg. changing the indentation or changing tabs to spaces. Adding whitespace where there was none before, or removing a whitespace completely is still shown as a change.

Ignore all whitespaces excludes all whitespace-only changes.

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.

/* DisableWhitespaceDifferences and DisableCaseDifferences. 
* The settings for TortoiseMerge is stored in Registry in CurrentUser\Software\TortoiseMerge\
* DWORDS stored the property values.
* 
* IgnoreWS         :   Set to 1 to ignore the whitespace differences. 
*                      Set to 0 to allow the whitespace differences.             
* IgnoreEOL        :   Set to 1 to ignore the End of Line differences. 
*                      Set to 0 to allow the End of Line differences.             
* CaseInsensitive  :   Set to 1 to ignore the Case differences. 
*                      Set to 0 to allow the Case differences.             
*/

// Get the key from the registry
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\TortoiseMerge", true))
{
   if (key != null)
   {
        // Set the IgnoreWS and IgnoreEOL DWORDs based on DisableWhitespaceDifferences is set or not
        key.SetValue("IgnoreWS", DisableWhitespaceDifferences ? 1 : 0, RegistryValueKind.DWord);
        key.SetValue("IgnoreEOL", DisableWhitespaceDifferences ? 1 : 0, RegistryValueKind.DWord);

        // Set the CaseInsensitive DWORD based on DisableCaseDifferences is set or not
        key.SetValue("CaseInsensitive", DisableCaseDifferences ? 1 : 0, RegistryValueKind.DWord);

        // close key
        key.Close();
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!