Mercurial > python-hglib
changeset 32:a2fc0a7f648e
client: add move command
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Sun, 14 Aug 2011 00:49:28 +0300 |
parents | ee8863882aae |
children | d74a5891d9d1 |
files | hglib/client.py tests/test-move.py |
diffstat | 2 files changed, 35 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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):
--- /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'))