# HG changeset patch # User Idan Kamara # Date 1313783579 -10800 # Node ID 939d1d763bb11e83c33f05b04d6fbc3b25a68d85 # Parent d1f57f162274478090a7de2b3be2dc940cdf3501 client: add resolve command diff -r d1f57f162274 -r 939d1d763bb1 hglib/client.py --- 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): diff -r d1f57f162274 -r 939d1d763bb1 tests/test-resolve.py --- /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))