[darcs-users] post-hoc move

Hamish Allan hamish at gmail.com
Thu Jul 30 15:15:13 UTC 2009


On Thu, Jul 30, 2009 at 3:34 PM, Zooko Wilcox-O'Hearn<zooko at zooko.com> wrote:

> Wait a minute, that's strange.  Why does darcs think that the file has been
> removed?  It isn't just that you mv'ed it aside and then mv'ed it back.  If
> that was all, then from darcs's perspective the file would never have moved.
>
> Did you tell darcs to do something to the file while it was mv'ed aside,
> such as by calling "darcs mv $LOC1 $LOC2" when the file was not currently
> physically present in $LOC1?

I did indeed. Like Max, I expected that to "just work" -- i.e. darcs
to realise that a file identical to the one it thought was located at
$LOC1 was located at $LOC2, so it should do everything it would have
done for a "darcs mv $LOC1 $LOC2" except the actual physical move.

For identical files, that's a no-brainer. And if the file at $LOC2 was
not identical to the one darcs thinks is at $LOC1, it could still ask
the user whether their intention is to darcs-move the file post-hoc
the physical-mv.

Even doing nothing whatsoever would be better than the current
outcome, which is to have a file in the state of "R" and "a" at the
same time. I did try reverting the changes but I still ended up with
files in a state of both "R" and "a", and even so, making a user step
through potentially hundreds of changes to pick out those reverts is
not a great user experience.

Here's a minimal test case:

# First I create a new repo:

kai:~ hamish$ mkdir darcs_test
kai:~ hamish$ cd darcs_test/
kai:darcs_test hamish$ darcs init
kai:darcs_test hamish$ echo "test1" > test1.txt
kai:darcs_test hamish$ echo "test2" > test2.txt
kai:darcs_test hamish$ darcs add test1.txt test2.txt
kai:darcs_test hamish$ darcs wh -l
A ./test1.txt
A ./test2.txt
kai:darcs_test hamish$ darcs record -a
What is the patch name? test
Do you want to add a long comment? [yn]n
Finished recording patch 'test'

# Then I physically mv a file into a subfolder without doing a "darcs move":

kai:darcs_test hamish$ mkdir test3
kai:darcs_test hamish$ mv test1.txt test3
kai:darcs_test hamish$ darcs wh -l
R ./test1.txt
a ./test3/
a ./test3/test1.txt

# Fair enough, to darcs that looks like a remove and an add. So I try
to tell darcs it's a move:

kai:darcs_test hamish$ darcs move test1.txt test3
kai:darcs_test hamish$ darcs wh -l
 ./test1.txt -> ./test3
R ./test3
a ./test3

# AAAAAARGH please, especially if you're going to call the command
'mv', make it check whether the destination is an existing directory
like unix 'mv' does!

kai:darcs_test hamish$ darcs revert
move ./test1.txt ./test3
Shall I revert this change? (1/3)  [ynWvplxdaqjk], or ? for help: y
hunk ./test3 1
-test1
Shall I revert this change? (2/3)  [ynWsfvplxdaqjk], or ? for help: y
Skipped revert of 1 patch.
Do you really want to revert these changes? y
Backing up ./test3(-darcs-backup0)
Finished reverting.
kai:darcs_test hamish$ darcs wh -l
No changes!
kai:darcs_test hamish$ ls -l
total 16
drwxr-xr-x  10 hamish  staff  340 30 Jul 15:50 _darcs
-rw-r--r--   1 hamish  staff    6 30 Jul 15:50 test1.txt
-rw-r--r--   1 hamish  staff    6 30 Jul 15:47 test2.txt
drwxr-xr-x   3 hamish  staff  102 30 Jul 15:48 test3-darcs-backup0

# Okay, we're pretty much back to where we started. Let's try that
again, giving "darcs move" the whole path this time:

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

# We have a single file in a state of both R and a. Not good.

kai:darcs_test hamish$ darcs revert -a
Backing up ./test2.txt(-darcs-backup0)
Finished reverting.
kai:darcs_test hamish$ ls -l
total 24
drwxr-xr-x  10 hamish  staff  340 30 Jul 16:03 _darcs
-rw-r--r--   1 hamish  staff    6 30 Jul 15:50 test1.txt
-rw-r--r--   1 hamish  staff    6 30 Jul 16:03 test2.txt
-rw-r--r--   1 hamish  staff    6 30 Jul 15:47 test2.txt-darcs-backup0
drwxr-xr-x   3 hamish  staff  102 30 Jul 15:48 test3-darcs-backup0

# Why has darcs taken it upon itself to physically delete my "test4" directory?!

Is there any reason why "darcs move" couldn't be fixed so that it Just
Works? If there is, could we have a "darcs posthocmv" command instead?

Hamish


More information about the darcs-users mailing list