Use the command line SVN resolve conflicts tree (tree conflict)

Foreword


Many people do not know the deal with conflict long, long time do not want to update the code, and some people just willy-nilly on the election "theirs conflict" or "mine conflict", sometimes tree conflicts simply these two options, they is forced resolve, in the end a new code to submit the code to put the others covered. this gives team cause great inconvenience, and even lead to malfunction version.
this paper summarizes the most difficult to deal with conflict disgust tree, so you no longer fear code violations.

A tree conflict of


If a file in a different end have been modified, they had their differences, svn update or merge when will attempt to automatically merge, in most cases will be successful, but sometimes fail, this time will prompt the conflict from locally conflict because the two ends of the same object is modified, the tree conflict it is because the two changes resulted in directory structure is inconsistent enough, the phenomenon of tree conflicts are end modified, the other end of the Missing . directory tree not only to solve conflict structural conflict, and may need to address the general contents of the file conflict.

In the event of a conflict, use these commands before you can view it states:

What a view file conflicts with svn status (st):

 

$ svn st
M       code/foo.c
A  +  C code/bar.c
      >   local edit, incoming delete upon update
Summary of conflicts:
  Tree conflicts: 1

info view conflict information with svn:

 

$ svn info code/bar.c
Path: code/bar.c
Name: bar.c
URL: http://svn.example.com/svn/repo/trunk/code/bar.c
…
Tree conflict: local edit, incoming delete upon update
  Source  left: (file) ^/trunk/code/bar.c@4
  Source right: (none) ^/trunk/code/bar.c@5

Svn log look can also be used when changed:

 

$ svn log -r14 ^/trunk
------------------------------------------------------------------------
r14 | harry | 2011-09-06 10:38:17 -0400 (Tue, 06 Sep 2011) | 1 line
Changed paths:
   M /Makefile
   D /code/bar.c
   A /code/baz.c (from /code/bar.c:13)

Rename bar.c to baz.c, and adjust Makefile accordingly.

Conflict management


We reasons and by file missing or need a classification process

1. The file has been deleted, it is no longer needed

This situation is handled well, using the relevant SVN command to delete it.

  1. Server modified, local missing, the file do not. This situation does not exist the local file, called directly resolve it.

 

#标记冲突已解决(使用本地的状态, 本地该文件的状态是Delete, 提交后服务端对应的文件就会被删除)
$ svn resolve --accept=working file_old.c
  1. Local modified, the server missing, the file is not the presence of documents this situation locally, forced deleted locally, and then call the resolve

 

#强制删除本地的文件(发生的文件不加--force是删不掉的)
$ svn delete --force file_old.c
#标记冲突已解决(使用服务器状态)
$ svn resolve --accept=theirs-conflict file_old.c
#或者使用本地状态也可以, 应该本地的状态跟服务一致了(都是Delete)
$ svn resolve --accept=working file_old.c

2. The file is deleted, but also need to

This may be because the file is accidentally deleted, added back svn on it.

  1. Server modified, local missing, will be able to choose their conflict

 

svn resolve --accept=theirs-conflict file.c
  1. Local modified, the server missing

 

svn resolve --accept=working file.c

3. The files are moved or renamed

This is a specific scenario modify a file A side, B side move or rename (the changed path) of the file. This condition requires a two-step process, namely the content of the file and directory structure conflict conflict handling process.
for convenience of description, we end a modified file becomes an old file, called a B-side to change the path of the new file. we eventually have to file a new or old files, only slight differences in dealing with, so we assume that we here to the new file.
Because after the B-side path may also be changed and made changes, we have no modification into the following two cases to deal with.

  1. After the file path change without modification . This situation handled well, as long as the modified A-side you can redo it again, which would be, will modify the A-side to make a patch, then the patch applied to the new file.
  • A local side is assumed (the modified file --bar.c), B is a server side (the File Transfer -> baz.c).
    The content processing:

 

$ svn diff bar.c > PATCHFILE  #创建补丁文件
$ vi PATCHFILE  #编辑补丁文件
...
---bar.c    (working copy)  #将这行的bar.c改成baz.c
+++bar.c    (working copy)  #将这行的bar.c也改成baz.c
...
svn patch PATCHFILE .    #应用补丁到当前目录(补丁只能应用到目录)

Structure process:

 

svn delete --force bar.c    #将已经missing的文件状态改为D
svn resolve --accept=working bar.c    #标记已解决(此处也可用theirs-conflict)
  • If the server end is A modified files, local B-side is the transfer of files, create a patch methods are slightly different
    content processing:

 

$ svn info bar.c #先使用svn info查看详情
Tree conflict: local file moved away, incoming file edit upon update
  Source  left: (file) bar.c@1485
  Source right: (file) bar.c@1486
$ svn diff -r1485:1486 bar.c > PATCHFILE  #根据详情创建补丁文件
$ vi PATCHFILE  #编辑补丁文件
...
---bar.c    (working copy)  #将这行的bar.c改成baz.c
+++bar.c    (working copy)  #将这行的bar.c也改成baz.c
...
svn patch PATCHFILE .    #应用补丁到当前目录(补丁只能应用到目录)

Structure process:

 

svn resolve --accept=working bar.c   #标记已解决
  1. Edit the file to change the path . This situation is similar to the directory structure of the conflict with the above process, described here is not tired, but the contents of the file conflict handling more trouble, there is no automatic way to find consolidation, you need to manually merge, here only is able to give suggestions, suggestion is to first check with the svn diff to change the old file as an index:

 

$ svn info bar.c #找到旧文件变化的版本
Tree conflict: local file moved away, incoming file edit upon update
  Source  left: (file) bar.c@1485
  Source right: (file) bar.c@1486
$ svn diff -r1485:1486 bar.c #查看变化的内容
Index: bar.c
===================================================================
--- bar.c   (revision 1485)
+++ bar.c   (revision 1486)
@@ -3,4 +3,5 @@
void main()
{
printf("hello")
+printf("world")
}

After that, using a graphical interface tool (such as beyond compare) than the old files with the new files, svn diff changes in a point of a manually applied to the new file.

other instructions


* The phenomenon of conflict arising due to the conflict merge and update produced and processing methods are the same, so we are dealing here only for the update, when the merge conflict, as long as the source branch as a server in a consistent way to deal with it.



Author: climb and telescopic
link: https: //www.jianshu.com/p/e3cc83ca512d
Source: Jane books
are copyrighted by the author. Commercial reprint please contact the author authorized, non-commercial reprint please indicate the source.

Published 141 original articles · won praise 204 · Views 1.18 million +

Guess you like

Origin blog.csdn.net/qq_36838191/article/details/103800465