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

后端 未结 3 1708
你的背包
你的背包 2021-02-07 02:51

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.

相关标签:
3条回答
  • 2021-02-07 03:12

    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();
        }
    }
    
    0 讨论(0)
  • 2021-02-07 03:20

    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.

    0 讨论(0)
  • 2021-02-07 03:28

    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

    0 讨论(0)
提交回复
热议问题