[PATCH] purge: add --ignored-only/-i option to delete only ignored files

Matt Mackall mpm at selenic.com
Thu Apr 5 16:45:27 CDT 2012


On Thu, 2012-04-05 at 09:43 +0200, Patrick Mézard wrote:
> Le 22/03/12 20:22, Matt Mackall a écrit :
> > On Wed, 2012-03-21 at 21:49 -0400, Greg Ward wrote:
> >> On 21 March 2012, Matt Mackall said:
> >>> On Tue, 2012-03-20 at 21:50 -0400, Greg Ward wrote:
> >>>> # HG changeset patch
> >>>> # User Greg Ward <greg at gerg.ca>
> >>>> # Date 1332294424 14400
> >>>> # Node ID bfde5bbbc3bb0d804a70cad737f0bf95086a448c
> >>>> # Parent  12e3f93b1cbc7c930e941f0adfe632c8ad70b73d
> >>>> purge: add --ignored-only/-i option to delete only ignored files
> >>>>
> >>>> This is handy when you trust .hgignore to specify all of your build
> >>>> products, but you do not trust yourself to always remember to "hg add"
> >>>> new files. This treats unknown files as valuable, since they might
> >>>> become added files soon.
> > 
> > Ignored files may also be valuable. Config files are a common example of
> > things you never want to commit, but that you don't want Mercurial to
> > clobber. I think maybe half of projects have one or more of these.
> > 
> >>> Does this work?
> >>>
> >>>  hg purge "set:ignored()"
> >>
> >> No, but
> >>
> >>   hg purge --all "set:ignored()" 
> > 
> > Hmm, perhaps we should fix that.
> 
> By detecting the "ignored()" fileset in the match object and implicitely enabling --all in that case?

Dunno. There are some related use cases that ought to work like:

 hg add 'set:ignored()'
 hg locate 'set:ignored()'

..but it's not clear that ignored() should always be respected.

> >> Also, this does not remove empty directories.
> > 
> > Seems buggy.
> 
> purge behaviour with match objects is unique, it applies them to directories as well. The code looks like:
> 
> - Call repo.status(match) and collect directory trees with match.dir().
> - Remove unknown and possibly ignored files
> - Remove collected directory entries *matched* by the matcher object.
> 
> For instance:
> 
>   $ hg init repo
>   $ cd repo
>   $ mkdir -p dir/subdir
>   $ touch dir/subdir/file
>   $ hg purge -v dir/subdir
>   Removing file dir/subdir/file
>   Removing directory dir/subdir
> 
> Note that "dir" was not removed because it is not matched by "dir/subdir".
> 
> Looking at the code history, this behaviour is at least partially by
> design, to let people ignore empty directories using --exclude.

Meh, since when have we cared about empty directories?

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list