[tahoe-dev] the good thing about "darcs replace"

David-Sarah Hopwood david-sarah at jacaranda.org
Tue Aug 2 00:18:52 UTC 2011


On 02/08/11 01:10, Zooko O'Whielacronx wrote:
> Folks:
> 
> darcs has its problems (mainly to do with performance, and also the
> lack of a short secure efficiently-checkable identifier for a
> filesystem state), but one good thing about it is "darcs replace".
> 
> If you're going to rename a bunch of instances of one word to another
> word, then if you do that with "darcs replace" instead of by editing
> the file it can avoid merge conflicts. Here is an example in the form
> of the notes I took while merging #1363 and #1382. These two branches
> are classic examples of this, because in #1363 Brian renamed a few
> variables, and in #1382 Kevan rewrote some of the code that used those
> variables. Neither was aware of the other's branch when they were
> doing this.
> 
> David-Sarah helped me with part of this process and they said that
> their opinion of using "darcs replace" was changed by doing this
> experiment.

Since then, I've refined my opinion to say that "darcs replace" is useful
as long as the "--force" option is not used. If --force is used then it
produces hunks that are confusing and difficult to read.
(The 'darcs replace' command will suggest using --force whenever the
replacement token already exists in the file. I recommend that you ignore
that suggestion and use a plain patch in that case instead.)

> If the thing being renamed
> was a common token, like "name", then darcs replace might also change
> some instances of it that shouldn't be changed (such as in comments or
> string literals, or unrelated variables that are also named "name").
> In that case, I counted, for each file, how many hunks it would take
> to put back all the bogus changes after darcs replace versus how many
> hunks it would take to make the desired changes without using darcs
> replace. Whichever approach yielded the fewest hunks is the one I
> took. This is because I regarded every additional hunk as threatening
> to cause later merge conflicts.

I'd prefer to be more conservative and avoid using 'darcs replace'
whenever it would make any bogus changes.

[...]
> P.S. The weird hunks that confused David-Sarah and Zancas in a recent
> "darcs replace" patch (ticket #1120) do not occur if you don't use
> "darcs replace --force" to go ahead with a darcs replace even when the
> new token already appears somewhere in the file. Maybe I should use
> darcs replace only when the new token doesn't appear in the file in
> order to avoid those confusing hunks.

Right, exactly.

-- 
David-Sarah Hopwood ⚥ http://davidsarah.livejournal.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 294 bytes
Desc: OpenPGP digital signature
URL: <http://tahoe-lafs.org/pipermail/tahoe-dev/attachments/20110802/e53fa79d/attachment.asc>


More information about the tahoe-dev mailing list