diff hglib/client.py @ 48:82d927ac1329

client: add addremove command
author Idan Kamara <idankk86@gmail.com>
date Thu, 18 Aug 2011 16:20:04 +0300
parents 94d2988e55b7
children bd7dfd94b0d9
line wrap: on
line diff
--- a/hglib/client.py	Thu Aug 18 14:29:29 2011 +0300
+++ b/hglib/client.py	Thu Aug 18 16:20:04 2011 +0300
@@ -167,6 +167,26 @@
         self.rawcommand(args, eh=eh)
         return not warnings[0]
 
+    def addremove(self, files=[], similarity=None, dryrun=False, include=None,
+                  exclude=None):
+        if not isinstance(files, list):
+            files = [files]
+
+        args = cmdbuilder('addremove', *files, s=similarity, n=dryrun, 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)
+
+        self.rawcommand(args, eh=eh)
+        return not warnings[0]
+
     def backout(self, rev, merge=False, parent=None, tool=None, message=None,
                 logfile=None, date=None, user=None):
         if message and logfile: