我的困惑来自下面的语句:
当提取相互冲突的补丁(例如,更改文件的相同部分)时,Darcs检测冲突并在存储库内容中标记它。然后让用户解决问题。
这似乎与我所看到的不一致,所以我使用darcs 2.5.2创建了以下工作流程:
- 在foo中创建非空文件并记录;
- 将foo克隆为bar;
- 删除foo中的文件并记录;
- 在bar文件中添加另一行并记录;
- 从foo拖动到bar,获得冲突通知;
在完成这些步骤后,我在bar中运行darcs whatsnew
,并显示了两个'补丁原语':
- 删除所有"foo中的非空文件",但没有提到添加和记录在bar中的行;
- 删除文件的rmfile
我的问题是:为什么在bar中没有提到添加和记录的行?
如果我在bar中运行darcs revert
,那么一切都有意义:我看到"非空文件"没有受到冲突补丁的影响,正如下面的语句所示:
命令darcs revert将删除冲突标记并备份到冲突补丁之前的状态。
但是如果我运行darcs mark-conflicts
,我就会回到与拉后相同的状态,使用上面提到的两个"补丁原语",并且没有提到添加和记录在bar中的行。
作为参考/复制,这里是我从命令行完成的完整工作流程:
$ 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
如果您在bar中运行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
那么,让我们来解释一下"Remove myfile"的疯狂输出。存在"Remove 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行添加一个块并删除文件。
将"remove myfile"拉入bar中,我们通过引入特殊的"conflictor"原语来修改补丁内容,这些原语表示"remove myfile"中与bar中其他原语冲突的原语。注意,这里没有信息丢失——我们总是可以通过解拉冲突的更改返回到原始的原语——在本例中,解拉"change myfile"。
冲突是令人困惑的,但AFAICT本质上是分开的与当前补丁冲突,x分成2组:"ix"是一组补丁,包括:I)与x和其他一些补丁冲突的补丁Ii)与与x冲突的补丁冲突的补丁"xx"表示只与补丁x冲突的补丁序列。我认为这样做的原因是,冲突者有这样的效果"撤销"导致冲突的原语,但仅限于那些没有冲突的原语
我们看到的输出类似于:"conflictor" ix "[" xx "]" x
我在滥用符号,但希望你能在某种程度上破译它(参见src/Darcs/Patch/V2/(Real.hs|Non.hs)
在这种情况下,"Remove myfile"有2个原始补丁,并且(在这种情况下)2当拉入bar时对应的冲突
第一个原语(从myfile中删除第1行)只与"Change 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("|:"是一个标记,它将"Non"原语的上下文与原始本身-我不会尝试进一步解释它,只需阅读下面的|:to(参见所讨论的原语)
第二个原语(remove myfile)只稍微复杂一点Myfile)与(将'b'添加到Myfile的第2行)冲突,我们知道这是冲突的使用(从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.
我认为你所看到的是"Change myfile"one_answers"Remove myfile"的强制交换的结果,分别称为A
和B
。然后将两者合并,Darcs创建A^-1
并将A^-1
和B
交换为B'
和(A^-1)'
,其中B'
具有A^-1
的效果(因为我们正在强制交换工作),这意味着B'
的效果(即合并的"remove myfile")实际上只是撤消"Change myfile"所做的添加行。
我还没有时间看darcs mark-conflicts
是如何工作的,所以我还不能解释你在bar中看到的darcs changes
的工作变化。