SVN Source Control Issues in Merging Changes

I saw where changes were made to one code file using two developer code as follows:

x++

Complete it as follows:

x++
x++

where, due to carriage return / deletion (I think), one line became silently merged as two lines of the same code (no conflicts). Everything compiles, but all of a sudden tests fail and strange behavior occurs.

If possible? How do I protect him?

+1
source share
4 answers

This should not be a problem if the developer performing the merge does not view the conflict as resolved without considering it. SVN will always warn of a conflict.

, , .

, , SVN , , .

(, , Unix- ) , .

# 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
+1
+2

, , . SVN- , . , .

You can protect yourself from this by checking the differences before the actual commit and automatic tests (as you already did).

Can you reproduce this behavior?

+1
source

I saw this when the merges went wrong and someone resolved the conflict, deleted the two versions of the merge and transferred the main file, which still has both versions merged together (since you have to tell SVN what is right.)

+1
source

Source: https://habr.com/ru/post/1733395/


All Articles