[darcs-users] post-hoc move

Eric Kow kowey at darcs.net
Fri Jul 31 15:40:54 UTC 2009

For the interested, here is an old bug about post-hoc moves:

Note it comes with a test case which now lives in our regression
suite as issue803.sh

On Fri, Jul 31, 2009 at 15:30:20 +0100, Hamish Allan wrote:
> After further experimentation, it seems the problem is caused by
> trying to "darcs move" a file to an as-yet-unadded directory:
> Is this a bug, or my misunderstanding?

Thanks for boiling this down to a minimal example!
(summarised below, see attached shell script for convenience)

I think I can be convinced that this a bug of the "unanticipated corner
case" variety.  The corner case in question being the combination of (a)
post-hoc (b) into directory where (c) target directory added between
physical mv and darcs move and (d) directory add not yet recorded.

My attached script simplifies Hamish's example to (a-c) by doing a darcs
record before the move so that the directory lives in the recorded state
and not just the pending patch.  This still fails.  I think if we
simplify it down to (a-b), we're back to Lele's issue803 test script.

I'll state (somewhat unhelpfully) that darcs mv has to grapple with a
fair number of variables:

 - is the destination a file or directory?
 - does the destination already exist?
 - does a filename already exist that differs only in case with the
 - is the destination in the pending patch?
 - is this a post-hoc move? [not clear on how we detect this;
   do we look for removes in the pending patch?]

The number of variables here leads to grumpiness-inducing complexity,
not to mention bugs.  For those of us who are happy to read Haskell:
I wonder if there is a way to keep darcs mv simple and yet still do
all the things people intuitively expect.

Also: perhaps a useful UI tweak in general would be for darcs mv to
announce when it is doing a post-hoc move, some variant of "Tracking the
move from foo to bar/foo, but not taking other action because you have
already physically moved the files"



> $ mkdir test
> $ cd test
> $ darcs init
> $ echo "contents" > file
> $ darcs add file
> $ darcs wh -l
> A ./file
> $ darcs record -a -m "first"
> Finished recording patch 'first'
> $ mkdir dir
> $ mv file dir/file


> $ darcs move file dir/file
> darcs failed:  The target directory dir isn't known in working
> directory, did you forget to add it?
> $ darcs add dir
> $ darcs move file dir/file
> darcs failed:  There is no file or dir named file in the repository.
> $ darcs wh -l
> A ./dir/
> R ./file
> a ./dir/file

Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: post-hoc-move.sh
Type: application/x-sh
Size: 272 bytes
Desc: not available
URL: <http://lists.osuosl.org/pipermail/darcs-users/attachments/20090731/9e34381f/attachment.sh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.osuosl.org/pipermail/darcs-users/attachments/20090731/9e34381f/attachment.pgp>

More information about the darcs-users mailing list