[darcs-users] token-replace commute behavior?

David Roundy droundy at jdj5.mit.edu
Mon Dec 22 14:51:31 UTC 2003


On Mon, Dec 22, 2003 at 10:23:03AM +0100, Marnix Klooster wrote:
> Compare the following three pairs of patches; which of these commutes, and
> why?
>  (1) insert line abc; replace all abc by xyz
>  (2) insert line pqr; replace all abc by xyz
>  (3) insert line xyz; replace all abc by xyz
> 
> What I think the current version of darcs (0.9.15) is doing, is:
>  (1) commutes to "replace all abc by xyz; insert line xyz"
>  (2) commutes to "replace all abc by xyz; insert line pqr"
>  (3) a conflict is reported, but I don't understand that.

That is correct.

> What I did for each of these cases is:
>  - create a fresh repo;
>  - 'darcs add' (and record) one empty file (called 'simple') to it;
>  - use 'darcs get' to create a second repo;
>  - do the 'darcs replace' (and record) in the first repo;
>  - insert one line (either abc, pqr, or xyz) (and record) in the second
>    repo;
>  - 'darcs pull' the 'replace' patch from the first into the second repo.
> 
> The last command gives the following results in the second repo:
>  (1) success, the line 'abc' has been replaced by 'xyz'
>  (2) success, no change.
>  (3) no change, but the following output:
> 
>        So far so good... the merge succeeded.
>        We have conflicts in the following files:
>        ./simple
>        Finished pulling.
> 
> So there are two questions I have:
>  - Why doesn't (1) give a conflict?  I mean, I added string 'abc', and
>    in a patched pulled from elsewhere somebody replaced 'abc' by 'xyz'.
>    This can very well be a conflict!

This may introduce a bug, but it is well-defined and reversible, and thus
not a conflict.  In fact, this is precisely the sort of thing that replace
is intended for, so that you can change all instances of a token, and have
the changes persist even when merging with other repos that don't have your
replace patch.

>  - What happens in case (3)?  I can understand why there is a conflict,
>    but why is it not visible in the merge result?  And why does it say
>    "the merge succeeded"?

It says "the merge succeeded" because it used to be possible for the merge
to "fail" (which is no longer true), and the success message never got
taken out... (i.e. it shouldn't say that).

The conflict isn't visible in the merge result because I haven't figured
out how to mark such a conflict.
-- 
David Roundy
http://www.abridgegame.org




More information about the darcs-users mailing list