changeset 31:ee8863882aae

client: add forget command
author Idan Kamara <idankk86@gmail.com>
date Sun, 14 Aug 2011 00:49:15 +0300
parents b7042bb3dbfd
children a2fc0a7f648e
files hglib/client.py tests/test-forget.py
diffstat 2 files changed, 31 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hglib/client.py	Sun Aug 14 00:48:51 2011 +0300
+++ b/hglib/client.py	Sun Aug 14 00:49:15 2011 +0300
@@ -322,6 +322,24 @@
         self.rawcommand(args, eh=eh)
         return not warnings[0]
 
+    def forget(self, files, include=None, exclude=None):
+        if not isinstance(files, list):
+            files = [files]
+
+        args = cmdbuilder('forget', *files, 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 import_(self, patches, strip=None, force=False, nocommit=False,
                 bypass=False, exact=False, importbranch=False, message=None,
                 date=None, user=None, similarity=None):
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-forget.py	Sun Aug 14 00:49:15 2011 +0300
@@ -0,0 +1,13 @@
+import common
+
+class test_forget(common.basetest):
+    def test_basic(self):
+        self.append('a', 'a')
+        self.client.add(['a'])
+        self.assertTrue(self.client.forget('a'))
+
+    def test_warnings(self):
+        self.assertFalse(self.client.forget('a'))
+        self.append('a', 'a')
+        self.client.add(['a'])
+        self.assertFalse(self.client.forget(['a', 'b']))