[svn] SVN conflict resolution strategy (manual)

zccst translation

This tutorial is walkthough on how to resolve a conflict in svn (subversion)
First

I will make a
test.txt end), and enter the following content

test Now I will

commit the changes 2. Suppose we have 2 users. User1 and User2. Both of them will get and update from svn Suppose we have two people, User 1 and User 2, through the svn client to get the svn server-side file test.txt C:\workspace\test> svn up A test.txt At revision 2. Now User1 will change the file to:
















Now User1 changes the file test.txt as follows

User1 is making a conflict test

He then commits his changes
and then User1 commits his changes

C:\workspace\test>svn ci -m "User1 starting a conflict"
Sending .
Sending test .txt
Transmitting file data .
Committed revision 3.

User2 now comes along and changes his local copy of the file not knowing that it has already been updated by User1 on the server. User2
also made changes to the file test.txt, at this time He doesn't know that User 1 made changes and committed them.

test User2 making a conflict

When he tries to commit he will get and error from svn.
When User2 finishes modifying the file test.txt, there is an error when preparing to commit.

svn: Commit failed (details follow):
svn: File or directory 'test.txt' is out of date; try updating
svn: resource out of date; try updating

So User2 performs an update
According to the error message, User 2 updated the file test.txt (a conflict occurred at this time)

C:\workspace\test>svn up
Conflict discovered in 'test.txt' .Select :
(p) postpone, (df) diff-full, (e) edit,
        (mc) mine-conflict, (tc) theirs-conflict,
        (s) show all options:
svn detects that theres a conflict here and require you to take some kind of action. If you type 's' here you will get a list of the commands


and meaning - change merged file in an editor #Go directly to the editor (df) diff-full - show all changes made to merged file #Show all changes made to the target file




(r) resolved - accept merged version of file

(dc) display-conflict - show all conflicts (ignoring merged version) #Display all conflicts
(mc) mine-conflict - accept my version for all conflicts (same) #Conflicts are based on local Standard
(tc) theirs-conflict - accept their version for all conflicts (same) #Conflicts are subject to the server

(mf) mine-full - accept my version of entire file (even non-conflicts) #Completely subject to the local
(tf ) ) theirs-full - accept their version of entire file (same) #Completely subject to the server

(p) postpone - mark the conflict to be resolved later #Mark the conflict and resolve it later
(l) launch - launch external tool to resolve conflict
(s) show all - show this list


[Select processing method 1: df]

If you type ‘df’ it will show you a all the conflicts in the following format
选择选项df,则会按如下格式显示所有冲突

Select: (p) postpone, (df) diff-full, (e) edit,
        (mc) mine-conflict, (tc) theirs-conflict,
        (s) show all options: df
--- .svn/text-base/test.txt.svn-base    Tue Aug 10 10:59:38 2010
+++ .svn/tmp/test.txt.2.tmp     Tue Aug 10 11:33:24 2010
@@ -1 +1,3 @@
-test
\ No newline at end of file
+<<<<<<< .mine +test User2 making conflict======= +User1 is making a conflict test>>>>>>> .r3
‘e’ option will open the conflicted file in the text editor that you configured for svn to use. In this case it will show

<<<<<<< .mine test User2 making conflict======= User1 is making a conflict test>>>>>>> .r3


You can resolve the conflict here by changing the text to what you desire.
For example:
you can resolve the conflict by changing the file content, eg vim test.txt

User1 is making a conflict test User2 making conflict

save your changes and exit your text editor and it will give you the conflict options again. Now if you use the ' r' it will mark the file is merged with a 'G'. A status of 'G' means there was a conflict and it has been resolved.
Save the changes and the options just now appear. When you use the r option, the files will be merged. As follows:

Select: (p) postpone, (df) diff-full, (e) edit, (r) resolved,
        (mc) mine-conflict, (tc) theirs-conflict,
        (s) show all options: e
Select: (p) postpone, (df) diff-full, (e) edit, (r) resolved,
        (mc) mine-conflict, (tc) theirs-conflict,
        (s) show all options: r
G    test.txt
Updated to revision 3.

you can now check the status with svn status. You see that test.txt is marked as ‘M’ all thats left to do is commit.
检查svn状态,你会发现文件test.txt前面已变成M

C:\workspace\test2>svn st
M       test.txt

C:\workspace\test2>svn ci -m "conflict resolved"
Sending        test.txt
Transmitting file data .
Committed revision 4.


【选择处理方式二:p】


Sometimes the conflicts are a bit more extensive and it requires more time or better tools to resolve the conflict in these cases you can chose 'p' to postpone the resolution. You can use options p

Select: (p) postpone, (df) diff-full, (e) edit, (r) resolved,
        (mc) mine-conflict, (tc) theirs-conflict,
        (s) show all options : p
C test.txt
Updated to revision 3.
Summary of conflicts:
  Text conflicts: 1

Now if you look in your directory you will see that svn has created a few extra files for you.
At this point, look under the current folder, there appears I have the following files

08/10/2010 11:44 AM 94 test.txt
08/10/2010 11:44 AM 26 test.txt.mine
08/10/2010 11:44 AM 27 test.txt.r2
08/10/2010 11:44 AM 31 test.txt.r3

The test.txt file is now a file with both User2 and User1's changes but marked.
The file test.txt contains user1 and user2's changes.

<<<<<<< .mine test User2 making conflict======= User1 am making a conflict test>>>>>>> .r3

test.txt.mine is User2's copy.file.txt
. mine saves the content of

User2 test User2 making conflict

test.txt.r2 is the original base copy
file.txt.r2 is the content before the conflict

test

test.txt.r3 is the copy User1 committed
file.txt.r3 is saved User1 's content

User1 is making a conflict test

At this point you can choose your favorite merge tools to merge the differences in a file.
In this case, you can choose your favorite comparison tool and see the difference.

I suggest merging the differences into test.txt and the do a
:

C:\workspace\test>svn resolve --accept working test.txt

Resolved conflicted state of ' test.txt' You can also use any of the other files if you wanted to and just pass resolve –accept

a different argument. Here are the valid arguments
6 instances : svn resolve mail.sh --accept 'mine-conflict' #Resolve conflicts. svn resolved mail.sh # inform svn. The other 3 of the 4 files disappear (1) #svn resolve --accept base







Choose the file that was the BASE revision before you updated your working copy. That is, the file that you checked out before you made your latest edits.
使用1.txt.r2作为最后提交的版本

(2)#svn resolve –accept working
Assuming that you've manually handled the conflict resolution, choose the version of the file as it currently stands in your working copy.
使用当前拷贝即test.txt作为最后提交的版本

(3)#svn resolve –accept mine-full
Resolve all conflicted files with copies of the files as they stood immediately before you ran svn update.
使用test.txt.mine作为最后提交的版本

(4)#svn resolve –accept theirs-full
Resolve all conflicted files with copies of the files that were fetched from the server when you ran svn update.
Use test.txt.r3 as the last submitted version

(5)#svn resolve –accept mine-conflict
The conflicting part is subject to the local modification

(6)#svn resolve –accept theirs-conflict
The conflicting part is subject to the server-side modification

Execute it: svn resolved test.txt.


Now you are ready to commit.
Then submit

C:\workspace\test>svn ci -m "conflict resolved"
Sending test.txt
Transmitting file data .
Committed revision 4.


If you think the content of this article is helpful for your study, You can WeChat:

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327083581&siteId=291194637
svn