Mercurial > python-hglib
changeset 63:939d1d763bb1
client: add resolve command
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Fri, 19 Aug 2011 22:52:59 +0300 |
parents | d1f57f162274 |
children | a7d98dc798c5 |
files | hglib/client.py tests/test-resolve.py |
diffstat | 2 files changed, 51 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hglib/client.py Fri Aug 19 22:24:14 2011 +0300 +++ b/hglib/client.py Fri Aug 19 22:52:59 2011 +0300 @@ -678,6 +678,28 @@ return bool(eh) + def resolve(self, file=[], all=False, listfiles=False, mark=False, unmark=False, + tool=None, include=None, exclude=None): + """ + redo merges or set/view the merge status of files + + When listfiles is True, returns a list of (code, file path) of resolved + and unresolved files. Code will be 'R' or 'U' accordingly. + """ + if not isinstance(file, list): + file = [file] + + args = cmdbuilder('resolve', *file, a=all, l=listfiles, m=mark, u=unmark, + t=tool, I=include, X=exclude) + + out = self.rawcommand(args) + + if listfiles: + l = [] + for line in out.splitlines(): + l.append(tuple(line.split(' ', 1))) + return l + def revert(self, files, rev=None, all=False, date=None, nobackup=False, dryrun=False, include=None, exclude=None): if not isinstance(files, list):
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-resolve.py Fri Aug 19 22:52:59 2011 +0300 @@ -0,0 +1,29 @@ +import common, hglib + +class test_resolve(common.basetest): + def setUp(self): + common.basetest.setUp(self) + + self.append('a', 'a') + self.append('b', 'b') + rev, self.node0 = self.client.commit('first', addremove=True) + + self.append('a', 'a') + self.append('b', 'b') + rev, self.node1 = self.client.commit('second') + + def test_basic(self): + self.client.update(self.node0) + self.append('a', 'b') + self.append('b', 'a') + rev, self.node3 = self.client.commit('third') + + self.assertRaises(hglib.error.CommandError, self.client.merge, self.node1) + self.assertRaises(hglib.error.CommandError, self.client.resolve, all=True) + + self.assertEquals([('U', 'a'), ('U', 'b')], + self.client.resolve(listfiles=True)) + + self.client.resolve('a', mark=True) + self.assertEquals([('R', 'a'), ('U', 'b')], + self.client.resolve(listfiles=True))