changeset 2369:9da3dd62c827

Purge.from_command is now a function called purge
author demian@gaudron.lan
date Tue, 16 May 2006 13:37:48 +0200
parents eb1ec13e3b0d
children de893ad6bd17
files purge.py
diffstat 1 files changed, 33 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- 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'),
                  ],