合并更改时的SVN源代码控制问题 [英] SVN Source control issues when merging changes

查看:84
本文介绍了合并更改时的SVN源代码控制问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到两个开发人员的代码在一个代码文件上进行了更改,如下所示:

I have seen where changes have been made on one code file by two developers code like this:

x++

最终像这样:

x++
x++

由于要插入/删除回车符(我认为),其中一行已悄无声息地合并为两条相同代码的行(没有冲突),所有内容都可以编译,但突然测试失败,随后出现奇怪的行为.

where due to carriage returns being inserted/removed (I think) one line has become silently merged as two lines of the same code (no conflicts) Everything compiles but suddenly tests are failing and weird behaviour ensues.

这可能吗?我该如何防范呢?

Should this be possible? How do I guard against it?

推荐答案

这应该不是问题,除非进行合并的开发人员将冲突标记为已解决而无需检查冲突. SVN会始终警告冲突.

This shouldn't be a problem, unless the developer doing the merge marks the conflict as resolved without reviewing it. SVN will always warn about a conflict.

无论如何都必须进行仔细的合并跟踪,以免出现任何问题.

Careful merge tracking, which is required anyway, should avoid any problems.

此外,一项小型测试表明,如果已应用合并的更改,SVN足够聪明,可以避免发生冲突.

Also, a small test shows that SVN is smart enough to avoid conflicting if the changes being merged have been already applied already.

以下示例(警告,弄乱了当前目录;需要类似Unix的工具)模拟了您刚刚描述的情况.

The following example (warning, messes up with the current directory; requires Unix-like tools) simulates the situation you just described.

# Initialize repository
svnadmin create repo
REPO_URL="file:///$PWD/repo"
svn mkdir "$REPO_URL/trunk" "$REPO_URL/branches" -m "Initialize repository structure"

# Add main program
svn co "$REPO_URL" wc1
cd wc1/trunk
cat > main.pl << "EOF"
my $x=0;
print("$x\n");
EOF
svn add main.pl
svn ci -m "Add main.pl"
cd ../..

# Create branch
svn cp "$REPO_URL/trunk" "$REPO_URL/branches/exp" -m "Create \"exp\" branch"

# Branch developer makes a change
svn co "$REPO_URL" wc2
cd wc2/branches/exp
perl -i -wpe 'print("\$x++;\n") if $. == 2' main.pl
svn ci -m "Increment x"
cd ../../..

# Trunk developer makes the same change
cd wc1/trunk
perl -i -wpe 'print("\$x++;\n") if $. == 2' main.pl
svn ci -m "Increment x"

# Merge changes from branch
svn up
svn merge --reintegrate "$REPO_URL/branches/exp" .
cat main.pl

这篇关于合并更改时的SVN源代码控制问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆