Branching and Merging of svn

Keywords: MyEclipse svn Eclipse

First, let's talk about why we need branch-merge. For example, there are two groups under project demo, and there is a trunk version under svn. Due to the sudden change of customer requirements, the project needs to make major changes. At this time, the project team decided to continue to complete half of the original work [a module] by team 1, and team 2 to develop new requirements. At this point, we can build a branch for Group 2. The branch is actually a copy version of Trunk, but the branch also has version control function and is independent of the trunk. In the end, of course, we can merge the branches into trunk through the merge function, and finally merge them into a project.

The following is a detailed use of the subeclipse plug-in under eclipse:
First, build a project called Facebook.
1. Establish branches and specify access URL s for new branches: Facebook 3 [Notes Don't Forget]






2. After the establishment of good points, use the "switch" function to switch to the branch for development.  



I created a new FB3.html file and submitted it under the branch.  




3. Switch back to the trunk version (that is, the URL is Facebook version)

You will find that the FB3.html we just submitted does not appear in the trunk version, because FB3.html belongs to the branch, and the next thing we need to do is "merge". By merging, we can merge the changes made under the branch into the trunk version.




The following are the main configurations for merging:
Start path: Trunk version of the path [if you need to incorporate trunk version changes into branches, the opposite is true]
Target path: Where to get changes [here is the branch path]
You can use the specified version number, here the latest revision.  



4. Click Merge and you will find a new file FB3.html added to the trunk version.
So we merged the changes made under the branch into the trunk version.  


It is noteworthy that:
1. It's best to add comments when building branches.  
2. Before merging, it's best to ensure that both versions are clean [i.e., no uncommitted or conflicting documents exist].
3. Target path when merging: fill in the URL of whoever changes need to be merged into other versions.  


The SVN command line output of the whole process is as follows:
  1. copy -rHEAD svn://192.168.1.192/placii/staggingarea/xiangqi/Facebook svn://192.168.1.192/placii/staggingarea/xiangqi/Facebook3   
  2. propset subclipse:tags "1538,Facebook2,/Facebook2,branch   
  3. 1540,Facebook3,/Facebook3,branch" E:/myeclipse/workspace/Facebook   
  4. switch svn://192.168.1.192/placii/staggingarea/xiangqi/Facebook3 E:/myeclipse/workspace/Facebook -rHEAD   
  5.     At revision 1541.   
  6. add -N E:\myeclipse\workspace\Facebook\WebRoot\FB3.html   
  7.     A         E:/myeclipse/workspace/Facebook/WebRoot/FB3.html   
  8. commit -m "" E:/myeclipse/workspace/Facebook/WebRoot/FB3.html   
  9.     Adding         E:/myeclipse/workspace/Facebook/WebRoot/FB3.html   
  10.     Transmitting file data ...   
  11.     Committed revision 1542.   
  12. switch svn://192.168.1.192/placii/staggingarea/xiangqi/Facebook E:/myeclipse/workspace/Facebook -rHEAD   
  13.     D  E:/myeclipse/workspace/Facebook/WebRoot/FB3.html   
  14.     Updated to revision 1542.  
  15.     ===== File Statistics: =====   
  16.     Deleted: 1   
  17. merge svn://192.168.1.192/placii/staggingarea/xiangqi/Facebook@HEAD svn://192.168.1.192/placii/staggingarea/xiangqi/Facebook3@HEAD E:/myeclipse/workspace/Facebook   
  18.     A  E:/myeclipse/workspace/Facebook/WebRoot/FB3.html   
  19.     Merge complete.  
  20.     ===== File Statistics: =====   
  21.     Added: 1  
  1. <span style="font-size:12px;">copy -rHEAD svn://192.168.1.192/placii/staggingarea/xiangqi/Facebook svn://192.168.1.192/placii/staggingarea/xiangqi/Facebook3  
  2. propset subclipse:tags "1538,Facebook2,/Facebook2,branch  
  3. 1540,Facebook3,/Facebook3,branch" E:/myeclipse/workspace/Facebook  
  4. switch svn://192.168.1.192/placii/staggingarea/xiangqi/Facebook3 E:/myeclipse/workspace/Facebook -rHEAD  
  5.     At revision 1541.  
  6. add -N E:\myeclipse\workspace\Facebook\WebRoot\FB3.html  
  7.     A         E:/myeclipse/workspace/Facebook/WebRoot/FB3.html  
  8. commit -m "" E:/myeclipse/workspace/Facebook/WebRoot/FB3.html  
  9.     Adding         E:/myeclipse/workspace/Facebook/WebRoot/FB3.html  
  10.     Transmitting file data ...  
  11.     Committed revision 1542.  
  12. switch svn://192.168.1.192/placii/staggingarea/xiangqi/Facebook E:/myeclipse/workspace/Facebook -rHEAD  
  13.     D  E:/myeclipse/workspace/Facebook/WebRoot/FB3.html  
  14.     Updated to revision 1542.  
  15.     ===== File Statistics: =====  
  16.     Deleted: 1  
  17. merge svn://192.168.1.192/placii/staggingarea/xiangqi/Facebook@HEAD svn://192.168.1.192/placii/staggingarea/xiangqi/Facebook3@HEAD E:/myeclipse/workspace/Facebook  
  18.     A  E:/myeclipse/workspace/Facebook/WebRoot/FB3.html  
  19.     Merge complete.  
  20.     ===== File Statistics: =====  
  21.     Added: 1  
  22. </span>  


I hope this article can be helpful.  
Other references:
http://www.iteye.com/wiki/subclipse/1626-subclipse-getting-started-guide-and-reference-c



=========================== On merger==========================
When I merged, I found that the merged file was directly overwritten without any conflict. After careful study, it was found that it was an operational problem.  


Suppose my original project was placii and a branch was established as placiiStore. Now we need to merge the branch placiiStore onto the trunk line. That configuration should look like this.
1. [Initial Path]: Here we need to fill in the branching path.  
2. The first revision number: the version number when the branch is established. Record the console of svn when building branches
Mine is
  1. copy -rHEAD svn://192.168.1.192/placii/trunk/code/server/source%20code/placii svn://192.168.1.192/placii/trunk/code/server/source%20code/placiiStore   
  2. propset subclipse:tags "1527,placiiStore,/source code/placiiStore,branch   
  3. 1549,placiiStore,/source%20code/placiiStore,branch" E:/myeclipse/workspace/placii   
  4. switch svn://192.168.1.192/placii/trunk/code/server/source code/placiiStore E:/myeclipse/workspace/placii -rHEAD   
  5.     At revision 1550.  
  1. <span style="font-size:12px;">copy -rHEAD svn://192.168.1.192/placii/trunk/code/server/source%20code/placii svn://192.168.1.192/placii/trunk/code/server/source%20code/placiiStore  
  2. propset subclipse:tags "1527,placiiStore,/source code/placiiStore,branch  
  3. 1549,placiiStore,/source%20code/placiiStore,branch" E:/myeclipse/workspace/placii  
  4. switch svn://192.168.1.192/placii/trunk/code/server/source code/placiiStore E:/myeclipse/workspace/placii -rHEAD  
  5.     At revision 1550.</span>  

3. Target path: Start path is used here.  
4. Target version number: use the latest version, HEAD.

Click Merge. If someone changes the backbone version and you change the file on the branch, there will be a conflict. Then we merge the conflicting code manually and right-click it to resolve it, which achieves our goal.

Posted by Cerebral Cow on Tue, 02 Apr 2019 14:42:29 -0700