# HG changeset patch # User Idan Kamara # Date 1313272168 -10800 # Node ID a2fc0a7f648ea229517c84bfef2185c56cff2b12 # Parent ee8863882aae0e49e6370206bcc91da4893ccd9a client: add move command diff -r ee8863882aae -r a2fc0a7f648e hglib/client.py --- a/hglib/client.py Sun Aug 14 00:49:15 2011 +0300 +++ b/hglib/client.py Sun Aug 14 00:49:28 2011 +0300 @@ -417,6 +417,27 @@ return self._parserevs(out) + def move(self, source, dest, after=False, force=False, dryrun=False, + include=None, exclude=None): + if not isinstance(source, list): + source = [source] + + source.append(dest) + args = cmdbuilder('move', *source, A=after, f=force, 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 outgoing(self, revrange=None, path=None, force=False, newest=False, bookmarks=False, branch=None, limit=None, nomerges=False, subrepos=False): diff -r ee8863882aae -r a2fc0a7f648e tests/test-move.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-move.py Sun Aug 14 00:49:28 2011 +0300 @@ -0,0 +1,14 @@ +import common, os + +class test_move(common.basetest): + def test_basic(self): + self.append('a', 'a') + self.client.add('a') + self.assertTrue(self.client.move('a', 'b')) + + # hg returns 0 even if there were warnings + #def test_warnings(self): + # self.append('a', 'a') + # self.client.add('a') + # os.mkdir('c') + # self.assertFalse(self.client.move(['a', 'b'], 'c'))