diff hglib/client.py @ 30:b7042bb3dbfd

client: add remove command
author Idan Kamara <idankk86@gmail.com>
date Sun, 14 Aug 2011 00:48:51 +0300
parents c072f525ea3e
children ee8863882aae
line wrap: on
line diff
--- a/hglib/client.py	Sun Aug 14 00:48:40 2011 +0300
+++ b/hglib/client.py	Sun Aug 14 00:48:51 2011 +0300
@@ -456,6 +456,24 @@
             out = self.rawcommand(args)
             return out.rstrip()
 
+    def remove(self, files, after=False, force=False, include=None, exclude=None):
+        if not isinstance(files, list):
+            files = [files]
+
+        args = cmdbuilder('remove', *files, A=after, f=force, I=include, X=exclude)
+
+        # we could use Python 3 nonlocal here...
+        warnings = [False]
+
+        def eh(ret, out, err):
+            if ret == 1:
+                warnings[0] = True
+            else:
+                raise error.CommandError(args, ret, out, err)
+
+        out = self.rawcommand(args, eh=eh)
+        return not warnings[0]
+
     def root(self):
         return self.rawcommand(['root']).rstrip()