Hg delete directory from repo?

I would like to remove the directory and all files from it from the repo.

I deleted all the files using "hg remove", but how to delete the directory itself?

Will it just automatically disappear after I complete all deleted files?

thank!

+17
mercurial
Oct 12 2018-10-12
source share
3 answers

Yes. Since mercurial does not track directories at all, only files, it creates only directories in which there are files, and if someone hg updates to a revision, all directories that become empty are automatically deleted. So if you do this:

 hg remove directory/* hg commit -m 'removed all files in directory' hg update -r 0 # updates to a different revision hg update tip # jump back to the tip 

The latest update will delete the directory. For everyone else, it's even easier. When they hg update to your new changes, their directory will simply disappear (if it does not have an uncommitted file).

+21
Oct 12 2018-10-12
source share
 hg remove dir 

If you run out of empty directories, and you want to get rid of them, then a simple way is to expand the purge. (add purge = under the [extensions] group to your .hrgc file to unlock).

Then you can use

 hg purge 

to clean up empty disks ... you have to be careful with the cleanup command as it removes everything that is not tracked in your repositories. I highly recommend you run

 hg purge -p 

to see what the command will do (-p will print a β€œtest run” without doing anything.) Never forget the --help option ;;)

edit: I prefer to use purge to update hg sequentially since trigger updates are restored in my IDE if it is open (and this is a good bet when I do this). hg brushing is likely to be smoother. And you can use -all to include ignored files (should be careful).

+9
Oct 13 '10 at 23:40
source share

To delete a directory just do

 hg remove <dir> hg commit -m "..." 

This will delete the directory and all files under it.

+2
Oct 12 2018-10-12
source share



All Articles