Skip to main content
 首页 » 编程设计

svn之从svn更新而不自动合并

2025年05月04日185thcjp

我的同事对 svn update 的工作方式有疑问,但我不确定为什么,所以这个问题有两个方面。首先,如何以他想要的方式解决他的问题,其次,我是否应该尝试让他相信 TortoiseSVN 现在做事的方式是最好的方式(如果是,如何)?

他的理想用例

  • 右键->SVN更新
  • 只要文件在工作副本中没有更改,SVN 就会从存储库中提取更改
  • 如果工作副本和 HEAD 都发生了变化,他希望在发生任何事情之前得到提示,并自己进行合并(即使这是 svn 很容易解决的情况)。

  • 我想这是一个足够合理的要求,但他不想信任 SVN 的事实困扰着我,尽管这并没有真正影响我或我的工作。他对版本控制并不陌生,之前使用过 CVS、SVN 和 ClearCase。他声称他以前能够在 svn 中做到这一点(而且,他比我大很多年)。

    请您参考如下方法:

    TortoiseSVN 常见问题解答:“prevent subversion from doing automatic merges”。

    编辑 :我正在复制常见问题解答中的链接答案,以保护此答案免受链接腐烂:

    Some people don't like the fact that Subversion merges changes from others with their own local working copy changes automatically on update. Here's how to force those files into a conflicted state so you can merge manually at your convenience.

    In TortoiseSVN->Settings->Subversion configuration file, click on the edit button. Change the [helpers] section by adding

    diff-cmd = "C:\\false.bat" 
    diff3-cmd = "C:\\false.bat"  
    

    (note the double backslash) Create the file C:\false.bat which contains two lines

    @type %9 
    @exit 1  
    

    This effectively makes auto-merge fail every time, forcing the file into conflict.

    The reason for the curious type %9 line is that the diff3-cmd sends the merged output to stdout. Subversion then takes this and overwrites your local file with the merge results. Adding this line avoids getting an empty local file.