# HG changeset patch # User Idan Kamara # Date 1313272131 -10800 # Node ID b7042bb3dbfd73630688b596c12827a7c040072b # Parent c072f525ea3ec9bbcc14cbbbd54759b24e0e21ba client: add remove command diff -r c072f525ea3e -r b7042bb3dbfd hglib/client.py --- 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() diff -r c072f525ea3e -r b7042bb3dbfd tests/test-remove.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-remove.py Sun Aug 14 00:48:51 2011 +0300 @@ -0,0 +1,12 @@ +import common + +class test_remove(common.basetest): + def test_basic(self): + self.append('a', 'a') + self.client.commit('first', addremove=True) + self.assertTrue(self.client.remove(['a'])) + + def test_warnings(self): + self.append('a', 'a') + self.client.commit('first', addremove=True) + self.assertFalse(self.client.remove(['a', 'b']))