Since this patch intersects with my recent changes to Darcs.Commands.*
and is trivial, I'll review it.
A note on the patch name: as pointed out in
http://wiki.darcs.net/Development/GettingStarted#sending-your-patches,
it's a good practice to keep your patch names down to 72 characters or
less.
Nothing -> fail "Invalid destination directory."
Just to' -> do
xs <- nub . sort <$> fixSubPaths opts froms
- case xs of
- [] -> fail "Nothing to move."
- froms' -> moveFilesToDir opts froms' to'
+ if to' `elem` xs
+ then fail "Cannot rename a file or directory onto itself!"
+ else case xs of
+ [] -> fail "Nothing to move."
+ froms' -> moveFilesToDir opts froms' to'
moveFile :: [DarcsFlag] -> SubPath -> SubPath -> IO ()
moveFile opts old new = withRepoLock opts $ RepoJob $ \repository -> do
A check that the moved files do not include the target directory itself,
good. The error message is consistent with that of 2 aruments case (i.e.
darcs move x x).
This patch applies cleanly to both HEAD and screened, and doesn't break
any tests.
One thing that is usually has to be done is writing tests. But in this
case, the tests are already written (see tests/failing-issue1737-
move_args.sh in darcs repository). They are skipped because of the
"failing-" prefix in the filename. Could you send a followup patch
removing that prefix?
Overall, thanks for the patch! I'm marking it as "accepted", it will
appear in the repositories when someone from the Core Team will push it.
|