hg purge

Thomas Arendsen Hein thomas at intevation.de
Tue May 16 06:06:22 CDT 2006


* Marco Barisione <barisione at gmail.com> [20060516 11:15]:
> When using CVS I always use cvspurge (from the CVS Utilities package) to 
> delete the auto generated files that are not deleted by make distclean. 
> This is useful to test local and uncommitted changes in the otherwise 
> clean source tree.
>
> Mercurial does not have a similar feature so I wrote an extension for it 
> that behaves like cvspurge.

Currently you would have to use
$ hg status -uin0 | xargs -0 rm --
And then use find to remove empty dirs.

Cumbersome, error prone and not portable to Windows.

> This means that hg purge will delete:
>  - Unknown files
>  - Ignored files
>  - Empty directories
> 
> My extension can be found at http://www.barisione.org/apps.html#hg-purge
> 
> Can this be useful for other people?

Some comments:

        act = True
        if opts['nothing']:
            act = False
could be written as:
        act = opts['nothing']
(as it doesn't matter if it is None or False)
or if you really want to have True/False:
        act = bool(opts['nothing'])

Additionally I'm not sure why you made from_command a static method
of Purge instead of just putting it in the module's namespace.

Instead of:
        if self._ui.verbose:
            self._ui.status(name + '\n')
you can simply use:
        self._ui.note(name + '\n')

And all this _relative_name/_split_path/_join_path is confusing me.
Maybe look at localrepo.py or dirstate.py what you can reuse?

Did you test all this on Windows?


If nobody objects I want to put this into Mercurial's hgext when the
code is ok, as I'd like to have this feature, too.

Thomas

-- 
Email: thomas at intevation.de
http://intevation.de/~thomas/


More information about the Mercurial mailing list