4

我的困惑,當標誌混亂源於下面的語句taken from here衝突拉動已刪除的文件用的darcs

當拉動補丁相互衝突(例如,更改文件的同一部分)的darcs檢測到衝突並將其標記在存儲庫內容中。然後它讓用戶解決問題。

這似乎與我所看到的不一致,所以我創建使用的darcs 2.5.2以下工作流程:

  1. 創建回購FOO;
  2. 在foo中創建一個非空文件並記錄它;
  3. 克隆foo吧;
  4. 刪除foo中的文件並記錄下來;
  5. 將另一行添加到bar中的文件並記錄它;
  6. 從foo拉入欄中,獲取衝突通知;

採取這些步驟後,我跑了吧darcs whatsnew,顯示出兩個「補丁原語」:

  1. 一大塊刪除所有「foo中的非空文件」,但沒有提到添加並記錄在欄中的行;
  2. 刪除文件的rmfile。

我的問題是:爲什麼沒有提及添加和記錄在欄中的行?

如果我跑在酒吧darcs revert,那麼一切都有道理:我看「非空文件」受既不衝突的修補程序,按照這種說法taken from here

的darcs恢復該命令將刪除衝突標記並在衝突補丁之前備份。

不過,如果我跑darcs mark-conflicts我回到同一狀態後拉,與上述兩個「補丁元」,並增加了無行的提及,並記錄在酒吧。


僅供參考/再現這裏是在命令行中我的完整工作流程:

$ mkdir foo 
$ cd foo/ 
foo$ darcs initialize 

foo$ touch shopping 
foo$ vi shopping   <-- add a couple of lines 
foo$ darcs add shopping 

foo$ darcs record 
addfile ./shopping 
Shall I record this change? (1/2) [ynW...], or ? for more options: y 
hunk ./shopping 1 
+cake 
+pie 
Shall I record this change? (2/2) [ynW...], or ? for more options: y 
What is the patch name? Added shopping 
Do you want to add a long comment? [yn]n 
Finished recording patch 'Added shopping' 

foo$ cd .. 
$ darcs get foo/ bar 
$ cd bar/ 

bar$ vi shopping <-- add another line 
bar$ darcs record 
hunk ./shopping 2 
+beer 
Shall I record this change? (1/1) [ynW...], or ? for more options: y 
What is the patch name? Added beer 
Do you want to add a long comment? [yn]n 
Finished recording patch 'Added beer' 

bar$ cd ../foo 
foo$ rm shopping 
foo$ darcs record 
hunk ./shopping 1 
-cake 
-pie 
Shall I record this change? (1/2) [ynW...], or ? for more options: y 
rmfile ./shopping 
Shall I record this change? (2/2) [ynW...], or ? for more options: y 
What is the patch name? Removed shopping 
Do you want to add a long comment? [yn]n 
Finished recording patch 'Removed shopping' 

foo$ cd ../bar 
bar$ darcs pull 
Pulling from "../foo"... 
Mon Nov 14 19:26:44 GMT 2011 [email protected] 
    * Removed shopping 
Shall I pull this patch? (1/1) [ynW...], or ? for more options: y 
Backing up ./shopping(-darcs-backup0) 
We have conflicts in the following files: 
./shopping 
Finished pulling and applying. 

bar$ darcs whatsnew 
hunk ./shopping 1 
-cake 
-pie 
rmfile ./shopping 
+0

雖然測試這個,我發現了一個錯誤,因爲在拉出衝突的補丁之後嘗試'在'還原'之前'標記衝突'。我[爲它創建了一個bug](http://bugs.darcs.net/issue2104)。 – dukedave

回答

7

如果你運行darcs changes -v裏面吧,你會看到你的 變化的歷史,其中包括由於您拉動 相沖突的修補程序而導致衝突問題。

我總結你的榜樣的東西everso稍短:

DARCS=/usr/bin/darcs 

$DARCS init --repo foo 
cd foo 

echo 'a' > myfile 
$DARCS add myfile && $DARCS record -am 'Add myfile' 

$DARCS get . ../bar 

rm myfile 
$DARCS record -am 'Remove myfile' 

cd ../bar 

echo 'b' >> myfile 
$DARCS record -am 'Change myfile' 

$DARCS pull -a ../foo 

$DARCS changes -v 

現在,在這之後,我看到darcs changes -v

Tue Nov 15 19:44:38 GMT 2011 Owen Stephens <[email protected]> 
    * Remove myfile 
    conflictor [ 
    hunk ./myfile 2 
    +b 
    ] 
    |: 
    hunk ./myfile 1 
    -a 
    conflictor {{ 
    |: 
    hunk ./myfile 2 
    +b 
    |: 
    hunk ./myfile 1 
    -a 
    }} [] 
    |hunk ./myfile 1 
    |-a 
    |: 
    rmfile ./myfile 

Tue Nov 15 19:44:38 GMT 2011 Owen Stephens <[email protected]> 
    * Change myfile 
    hunk ./myfile 2 
    +b 

Tue Nov 15 19:44:38 GMT 2011 Owen Stephens <[email protected]> 
    * Add myfile 
    addfile ./myfile 
    hunk ./myfile 1 
    +a 

所以這個輸出,讓我們解釋的「瘋狂輸出刪除myfile「。 「刪除文件MyFile」存在 如FOO以下:

Tue Nov 15 19:44:38 GMT 2011 Owen Stephens <[email protected]> 
    * Remove myfile 
    hunk ./myfile 1 
    -a 
    rmfile ./myfile 

所以,位於第1行和移除該文件的一大塊。

將「刪除myfile」拉入欄中,我們通過引入特殊的「衝突」原語來修改補丁內容,這些原語代表了「刪除我的文件」中與其他原始文件相沖突的原語。注:這裏沒有信息丟失 - 我們總是可以通過取消衝突更改來恢復原始原語 - 在這種情況下,可以取消「更改myfile」。

Conflictors是混亂,但AFAICT基本上單獨的更改 衝突與當前補丁,X爲2臺: 「IX」,它是包括補丁集: ⅰ)修補x和一些其他衝突補丁與補丁相沖突的補丁與x 「xx」衝突,該補丁是僅與補丁x衝突的補丁序列。 我認爲這樣做的原因是衝突者具有 「撤銷」引起衝突的原語的效果,但只有那些未被另一個衝突器取消的原語。

我們看到的輸出是一樣的東西:

"conflictor" ix "[" xx "]" x 

我濫用符號,但希望你能有所破譯(見 的src /的darcs /補丁/ V2 /(Real.hs |非。 hs)在darcs.net回購中的全文)

在這種情況下,「刪除myfile」有2個原始補丁,並且(在這種情況下)當被拉入到相應的衝突中時。

第一原語(刪除MYFILE線1)只與 原始的 「更改文件MyFile」 內部的衝突(添加 'B' 到線路MYFILE的2)和所以這是 第一conflictor:

conflictor [ <--- The start of xx (no ix here) 
hunk ./myfile 2 
+b 
]    <--- The end of xx 
|: 
hunk ./myfile 1 <--- x 
-a 

NB(「|:」是界定從 原始本身就是一個「非」 primitve的上下文的標誌 - 我不會嘗試,並進一步解釋,下面只是閱讀|:到 看到原始的問題)

第二個基元(刪除myfile)只是稍微更復雜因爲我們知道衝突 與(刪除myfile中的第1行),所以他們都進入「ix」,沒有補丁 「(文件 myfile)衝突與(添加'b'到myfile的第2行) XX」。我會刪除不必要的「|」分隔符和空間的事情了:

conflictor {{ 

hunk ./myfile 2 
+b 

hunk ./myfile 1 
-a 

}} 
[]    <--- no xx 

|hunk ./myfile 1 <--- start of x 
|-a 
|: 
rmfile ./myfile <--- end of x 

最後(rmfile MYFILE)具有一定的上下文indentify是我們指的是確切的原始 (我不是真的確定爲什麼/如何這是必需的,但我們在那裏是 ),它由領先的'|'標記並用「|:」分隔。

最後,試圖解釋foo中darcs whatsnew的輸出;當 多個補丁發生衝突時,我認爲衝突者的實際效果是 「撤消」任何衝突的補丁,並不產生效果; 給出了一些解釋的開始:http://en.wikibooks.org/wiki/Understanding_Darcs/Patch_theory_and_conflicts

我想你所看到的是「Change myfile」和「Remove myfile」的強制換向的結果,分別稱它們爲AB。然後合併兩個,創造的darcs和A^-1通勤A^-1BB'(A^-1)'其中B'A^-1效果(因爲我們強迫換工作),這意味着的B'(效果即合併後的「刪除myfile「)實際上就是撤消添加」Change myfile「所做的行。

我沒有時間看darcs mark-conflicts是如何工作的,所以我還無法解釋您在darcs changes中看到的工作變化。

+0

非常感謝您的回答,不幸的是,我對您在以_開頭的段落中的措詞感到困惑 - 「衝突者很容易混淆」(適當地)。 如果你有時間可以嘗試重新措辭嗎? – dukedave