[PATCH 0 of 1] Introduction to the new --keep-dirs option for Mercurial's 'remove' command

jonny.dee at gmx.net jonny.dee at gmx.net
Fri Aug 28 12:15:44 CDT 2009


Mercurial normally deletes empty directories when removing files would leave them empty. This patch will add a new option --keep-dirs to the 'remove' command which, when specified on command line, will make Mercurial keep local empty directories. I'd decided to write this patch because I've been bitten by Mercurial's default behavior several too many times, because I stumble over the following workflow often enough:

mkdir -p a/b/c
touch a/b/c/file1
touch a/b/c/file2
hg ci -A -m added
# --------------------
hg rm a/b/c/*
#
# or
#
hg rm a/b/c/file1
# do other things
# ...
hg rm a/b/c/file2
# --------------------
touch a/b/c/file3
# Wonder where path a/b/c has gone... (no such file or directory)

Of course, one can make sure not to remove every file before creating and adding a new one, but you have to remember.

I've posted my first suggestion for a patch to the wrong list, but I'm glad to see someone forwarded it to the correct mercurial-devel list. This is my second approach which should contain all the hints I got from Greg and Dirkjan. 

In particular:
* the 'remove' command's docstring is updated
* the intendation is corrected
* the commit message is much more descriptive
* the option '--keepdirs' is renamed to '--keep-dirs'
* the one-letter short form is removed

Thank you Greg and Dirkjan for your feedback and your help :)

With respect to version 7345fa5e572e in 'crew' repository my patch passes the testsuite.

Best regards,
Jonny Dee


More information about the Mercurial-devel mailing list