# HG changeset patch # User demian@gaudron.lan # Date 1147779468 -7200 # Node ID 9da3dd62c82741fb99d335fe41d40edd46452760 # Parent eb1ec13e3b0d05080d3a8ff032508fdd3769b0b1 Purge.from_command is now a function called purge diff -r eb1ec13e3b0d -r 9da3dd62c827 purge.py --- a/purge.py Sat May 13 14:57:16 2006 +0200 +++ b/purge.py Tue May 16 13:37:48 2006 +0200 @@ -23,30 +23,6 @@ import os class Purge(object): - '''removes files not tracked by mercurial - - Delete files not known to mercurial, this is useful to test local and - uncommitted changes in the otherwise clean source tree. - - This means that purge will delete: - - Unknown files: files marked with "?" by "hg status" - - Ignored files: files usually ignored by Mercurial because they match a - pattern in a ".hgignore" file - - Empty directories: infact Mercurial ignores directories unless they - contain files under source control managment - But it will leave untouched: - - Unmodified tracked files - - Modified tracked files - - New files added to the repository (with "hg add") - - If names are given, only files matching the names are considered, else - all files in the repository directory are considered. - - Be careful with purge, you could irreversibly delete some files you - forgot to add to the repository. If you only want to print the list of - files that this program would delete use the -vn options. - ''' - def __init__(self, act=True, abort_on_err=False): self._repo = None self._ui = None @@ -135,26 +111,45 @@ ret = part return ret - def from_command(ui, repo, *paths, **opts): - act = True - if opts['nothing']: - act = False + +def purge(ui, repo, *paths, **opts): + '''removes files not tracked by mercurial + + Delete files not known to mercurial, this is useful to test local and + uncommitted changes in the otherwise clean source tree. + + This means that purge will delete: + - Unknown files: files marked with "?" by "hg status" + - Ignored files: files usually ignored by Mercurial because they match a + pattern in a ".hgignore" file + - Empty directories: infact Mercurial ignores directories unless they + contain files under source control managment + But it will leave untouched: + - Unmodified tracked files + - Modified tracked files + - New files added to the repository (with "hg add") - abort_on_err = True - if not opts['abort_on_err']: - abort_on_err = False + If names are given, only files matching the names are considered, else + all files in the repository directory are considered. - p = Purge(act, abort_on_err) - p.purge(ui, repo, paths) + Be careful with purge, you could irreversibly delete some files you + forgot to add to the repository. If you only want to print the list of + files that this program would delete use the -vn options. + ''' + act = True + if opts['nothing']: + act = False - # The docstring of from_command() is used by hg to print the help - # of the command. - from_command.__doc__ = __doc__ - from_command = staticmethod(from_command) + abort_on_err = True + if not opts['abort_on_err']: + abort_on_err = False + + p = Purge(act, abort_on_err) + p.purge(ui, repo, paths) cmdtable = { - 'purge': (Purge.from_command, + 'purge': (purge, [('a', 'abort-on-err', None, 'abort if an error occurs'), ('n', 'nothing', None, 'do nothing on files, useful with --verbose'), ],