2015-01-13 65 views
4

我試圖按照在http://svnbook.red-bean.com/en/1.7/svn.branchmerge.commonpatterns.html描述的版本分支模型,但試圖進行合併時,我得到合併衝突。SVN合併和樹衝突「本地添加,傳入添加合併」

# Normal SVN Structure 
svn-testing2> ls -l 
total 12K 
drwxrwxr-x 3 xxx yyy 4.0K Jan 13 17:28 branches/ 
drwxrwxr-x 3 xxx yyy 4.0K Jan 13 17:28 tags/ 
drwxrwxr-x 3 xxx yyy 4.0K Jan 13 17:28 trunk/ 

# Create & commit some data 
svn-testing2> echo "line1" > trunk/file1; svn add trunk/file1; svn commit -m "created file1 " trunk/file1 
Adding   trunk/file1 
Transmitting file data . 
Committed revision 2. 

# Create the release branch 
svn-testing2> svn copy trunk branches/release 
A   branches/release 
svn-testing2> svn commit -m "created release branch" branches/release 
Adding   branches/release 
Adding   branches/release/file1 

Committed revision 3. 

# Make & commit a change to trunk 
svn-testing2> echo "line1-file2" > trunk/file2; svn add trunk/file2; svn commit -m "created file2" trunk/file2 
A   trunk/file2 
Adding   trunk/file2 
Transmitting file data . 
Committed revision 4. 

# Attempt to merge the change to trunk: 
svn-testing2> cd branches/release/ 
svn-testing2/branches/release> svn merge ^/trunk 
--- Merging r2 through r4 into '.': 
    C file1 
A file2 
Summary of conflicts: 
    Tree conflicts: 1 
[email protected]:~/svn-testing/svn-testing2/branches/release> svn st 
M  . 
     C file1 
     > local add, incoming add upon merge 
A + file2 

我可以

svn-testing2> svn resolve --accept=working * 

解決這個問題,但似乎錯了,我必須這樣做。

如果我然後對我的發佈分支應用「hotfix」(例如創建「release/file3」),我該如何將它移回到trunk?如果我將「release」合併到「trunk」中,它將合併成OK,但是當將「trunk」合併回「release」時,我會遇到另一個local add, incoming add upon merge衝突。 「file3」

我不想「重新集成」一個功能分支,因爲這些都是長時間運行的分支。

令人沮喪的是,SVN紅皮書(通常很棒)描述了這種常見的分支模式,沒有任何可以運行的命令的實例。

究竟我需要運行遵循這種分支模式,沒有所有這些不正確的合併衝突?或者有沒有這種分支模式的任何工作的例子 - 我找不到任何!

+0

我想一個你評論關閉。 '試圖合併到trunk'的變化應該說'...釋放',而不是,對吧? –

回答

2

這是由於您的copy操作完全在客戶端完成。此操作不包含任何合併跟蹤信息,因此當您嘗試合併時,它會嘗試在其本身之上添加file1。這種行爲在聲明中幫助描述爲copy命令:

 
> svn help copy 

copy (cp): Copy files and directories in a working copy or repository. 
usage: copy SRC[@REV]... DST 

    SRC and DST can each be either a working copy (WC) path or URL: 
    WC -> WC: copy and schedule for addition (with history) 
    WC -> URL: immediately commit a copy of WC to URL 
    URL -> WC: check out URL into WC, schedule for addition 
    URL -> URL: complete server-side copy; used to branch and tag 
    All the SRCs must be of the same type. When copying multiple sources, 
    they will be added as children of DST, which must be a directory. 

    WARNING: For compatibility with previous versions of Subversion, 
    copies performed using two working copy paths (WC -> WC) will not 
    contact the repository. As such, they may not, by default, be able 
    to propagate merge tracking information from the source of the copy 
    to the destination. 

如果你改變了copy到服務器端副本,合併會成功:

# This is the difference, the copy happens on the server 
> svn copy ^/trunk ^/branches/release2 -m "Creating release2" 
Committed revision 5. 

# Update our working copy to get the new release 
> svn update branches 
Updating 'branches': 
A branches\release2 
A branches\release2\file1 
A branches\release2\file2 
Updated to revision 5. 

> echo blah>trunk\file3; svn add trunk\file3; svn commit -m "created file3" 
A   trunk\file3 
Adding   trunk\file3 
Transmitting file data . 
Committed revision 6. 

> cd branches\release2 
> svn merge ^/trunk 
--- Merging r5 through r6 into '.': 
A file3 
--- Recording mergeinfo for merge of r5 through r6 into '.': 
U . 
+0

ARGH謝謝!我正在閱讀svn紅皮書,我沒有閱讀「複製」的幫助。 – Mark