# HG changeset patch # User Idan Kamara # Date 1313272155 -10800 # Node ID ee8863882aae0e49e6370206bcc91da4893ccd9a # Parent b7042bb3dbfd73630688b596c12827a7c040072b client: add forget command diff -r b7042bb3dbfd -r ee8863882aae hglib/client.py --- 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): diff -r b7042bb3dbfd -r ee8863882aae tests/test-forget.py --- /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']))