0
votes

I made some exploratory changes to my code in a project under mercurial version control, so afterwards I wanted to discard all changes and go back to the last version in the remote repo.

hg pull
hg update -r default -C
hg --config "extensions.purge=" purge --all

What I didn't realize is that this will delete any untracked file, including those ignored. In particular eclipse directories like .settings. Obviously I don't want to delete those.

I know I can use patterns with the purge command, and most of the time I will want to use it only with changes under the source code directory, but if I had made changes not only under src, but also config, added a file at project directory level and whatnot, is there any way that purge could automatically pull files and directories from the .hgignore file to be excluded so I don't have to think all that directories and files in which I have untracked files?

1

1 Answers

1
votes

Well... you explicitly used a flag which means "delete everything, even if ignored". From hg help purge:

--all                 purge ignored files too

So it should work, if you skip the '--all' parameter to purge.