使用darcs删除已删除文件时的冲突标记混淆

时间:2011-11-15 18:32:48

标签: version-control haskell dvcs merge-conflict-resolution darcs

我的混淆来自以下陈述taken from here

  

当拉出彼此冲突的补丁(例如,更改文件的相同部分)时,Darc会检测冲突并将其标记在存储库内容中。然后让用户解决问题。

这似乎与我所看到的不一致,因此我使用darcs 2.5.2创建了以下工作流程:

  1. 创建repo foo;
  2. 在foo中创建一个非空文件并记录下来;
  3. 克隆foo到bar;
  4. 删除foo中的文件并记录下来;
  5. 在条形图中添加另一行并记录下来;
  6. 从foo拉入栏,获取冲突通知;
  7. 执行这些步骤后,我在栏中运行了darcs whatsnew,并显示了两个“补丁基元”:

    1. 一个hunk删除了foo中的所有“非空文件”,但没有提到添加并记录在栏中的行;
    2. 删除文件的rmfile。
    3. 我的问题是:为什么没有提到在栏中添加和记录的行?

      如果我在栏中运行darcs revert,那么一切都有意义:根据此声明taken from here,我看到“非空档案”不受任何冲突补丁的影响:

        

      命令darcs revert将删除冲突标记并在冲突补丁之前恢复到状态。

      但是如果我运行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  dukedave@gmail.com
        * 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
      

1 个答案:

答案 0 :(得分:7)

如果你在栏内运行darcs changes -v,你会看到你的历史记录 更改,包括由于您拉动而引入的冲突者 相互矛盾的补丁。

我已将您的示例概括为略微缩短的内容:

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 <darcs@owenstephens.co.uk>
  * 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 <darcs@owenstephens.co.uk>
  * Change myfile
    hunk ./myfile 2
    +b

Tue Nov 15 19:44:38 GMT 2011  Owen Stephens <darcs@owenstephens.co.uk>
  * Add myfile
    addfile ./myfile
    hunk ./myfile 1
    +a

所以,让我们解释一下“删除myfile”的疯狂输出。 “删除myfile”存在 如foo中的以下内容:

Tue Nov 15 19:44:38 GMT 2011  Owen Stephens <darcs@owenstephens.co.uk>
  * Remove myfile
    hunk ./myfile 1
    -a
    rmfile ./myfile

所以,第1行的一个大块并删除了文件。

将“删除myfile”拉入栏中,我们通过引入特殊的“conflicttor”原语来修改补丁内容,这些原语表示“删除myfile”中与“bar”中其他原语冲突的原语。注:这里没有信息丢失 - 我们总是可以通过取消冲突的变更来回到原始基元 - 在这种情况下,取消“改变myfile”。

冲突者感到困惑,但AFAICT基本上将这些变化分开 与当前补丁冲突,x成2组: “ix”是一组补丁,包括:   i)与x和补仓中的其他补丁冲突的补丁   ii)与与x冲突的补丁冲突的补丁 “xx”,它是仅与补丁x冲突的补丁序列。 我认为这样做的原因是冲突者的影响 “撤消”导致冲突的原语,但只包括那些没有冲突的原语 被另一个冲突者撤消。

我们看到的输出类似于:

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

我正在滥用符号,但希望你能解读一下(见 完整故事中的darcs.net repo中的src / Darcs / Patch / V2 /(Real.hs | Non.hs))

在这种情况下,“删除myfile”有2个原始补丁,并且(在本例中)为2 相应的冲突者被拉入酒吧。

第一个原语(从myfile中删除第1行)只与 “更改myfile”中的原语(将“b”添加到myfile的第2行),这样就可以了 第一个冲突者:

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

N.B(“|:”是一个标记,用于界定“非”原始的上下文 原始本身 - 我不会尝试进一步解释它,只需阅读下面的|:to 看到有问题的原语)

第二个原语(删除myfile)只是稍微复杂一些:(rmfile myfile)与我们知道冲突的(将'b'添加到myfile的第2行)冲突 with(从myfile中删除第1行),所以它们都进入“ix”,没有补丁 “XX”。我将删除不必要的“|:”分隔符和空格:

conflictor {{

hunk ./myfile 2
+b

hunk ./myfile 1
-a

}} 
[]               <--- no xx

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

final(rmfile myfile)有一些上下文来识别确切的原语 我们指的是(我不确定为什么/如何这需要,但是 在那里我们是),它由前导'|'标记,并以“|:”分隔。

最后,尝试解释foo中darcs whatsnew的输出;什么时候 多个补丁冲突,我认为冲突者的实际效果是 “撤销”任何冲突的补丁,不会产生任何效果; 给出了一些解释的开头:http://en.wikibooks.org/wiki/Understanding_Darcs/Patch_theory_and_conflicts

我认为您所看到的是“更改myfile”和“删除myfile”强制转换的结果,分别称它们为AB。然后合并两者,Darcs创建A^-1并通勤A^-1B以提供B'(A^-1)' B' A^-1的效果{ {1}}(因为我们强迫换向工作),这意味着B'(即合并的“删除myfile”)的效果实际上只是撤消添加由“更改myfile”所做的行”

我没有时间查看darcs mark-conflicts的工作原理,所以我还不能解释您在栏中darcs changes看到的工作变化。

相关问题