[PATCH hglib] client: add purge command

Victor Garcia bravejolie at gmail.com
Tue Oct 2 18:24:22 UTC 2012


# HG changeset patch
# User victor
# Date 1349202168 -7200
# Node ID 6172601e7f7b3d7c8c3539e2758cfba8ab0784a4
# Parent  e5d3b0aa48e6ab79531204f61e25ee335b306df3
client: add purge command

Adding the purge command to hglib. Since it's an extension, appending '--config extensions.hgext.purge=' to enable it

diff -r e5d3b0aa48e6 -r 6172601e7f7b hglib/client.py
--- a/hglib/client.py	Tue Jan 17 17:15:47 2012 -0600
+++ b/hglib/client.py	Tue Oct 02 20:22:48 2012 +0200
@@ -1511,6 +1511,29 @@
         counters = out.rstrip().split(', ')
         return tuple(int(s.split(' ', 1)[0]) for s in counters)
 
+    def purge(self, files, all=False, include=None, exclude=None):
+        """
+        Purge the files specified by parameters. It physically removes the non-tracked files from the file system.
+        
+        Return True on success
+
+        all - revert all changes when no arguments given
+        include - include names matching the given patterns
+        exclude - exclude names matching the given patterns
+
+        """
+        if not isinstance(files, list):
+            files = [files]
+        
+        args = cmdbuilder('purge',
+                all=all, I=include, X=exclude, *files)
+        args.extend(['--config', 'extensions.hgext.purge='])
+
+        eh = util.reterrorhandler(args)
+        self.rawcommand(args, eh=eh)
+
+        return bool(eh)
+
     @property
     def version(self):
         """



More information about the Mercurial-devel mailing list