Mercurial > python-hglib
changeset 16:943aff89b068
client: add missing options to commit()
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Wed, 10 Aug 2011 20:33:08 +0300 |
parents | f1af31960414 |
children | b68c444d42bb |
files | hglib/client.py tests/test-commit.py |
diffstat | 2 files changed, 42 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/hglib/client.py Wed Aug 10 19:59:08 2011 +0300 +++ b/hglib/client.py Wed Aug 10 20:33:08 2011 +0300 @@ -180,9 +180,17 @@ args = cmdbuilder('clone', source, dest, b=branch, u=updaterev, r=revrange) self.rawcommand(args) - def commit(self, message, addremove=False): + def commit(self, message=None, logfile=None, addremove=False, closebranch=False, + date=None, user=None, include=None, exclude=None): + if message is None and logfile is None: + raise ValueError("must provide at least a message or a logfile") + elif message and logfile: + raise ValueError("cannot specify both a message and a logfile") + # --debug will print the committed cset - args = cmdbuilder('commit', debug=True, m=message, A=addremove) + args = cmdbuilder('commit', debug=True, m=message, A=addremove, + close_branch=closebranch, d=date, u=user, l=logfile, + I=include, X=exclude) out = self.rawcommand(args) rev, node = out.splitlines()[-1].rsplit(':')
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-commit.py Wed Aug 10 20:33:08 2011 +0300 @@ -0,0 +1,32 @@ +import common, hglib + +class test_commit(common.basetest): + def test_user(self): + self.append('a', 'a') + rev, node = self.client.commit('first', addremove=True, user='foo') + rev = self.client.log(node)[0] + self.assertEquals(rev.author, 'foo') + + def test_no_user(self): + self.append('a', 'a') + self.assertRaises(hglib.error.CommandError, self.client.commit, 'first', user='') + + def test_close_branch(self): + self.append('a', 'a') + rev0, node0 = self.client.commit('first', addremove=True) + self.client.branch('foo') + self.append('a', 'a') + rev1, node1 = self.client.commit('second') + revclose = self.client.commit('closing foo', closebranch=True) + rev0, rev1, revclose = self.client.log([node0, node1, revclose[1]]) + + self.assertEquals(self.client.branches(), + [(rev0.branch, int(rev0.rev), rev0.node[:12])]) + + self.assertEquals(self.client.branches(closed=True), + [(revclose.branch, int(revclose.rev), revclose.node[:12]), + (rev0.branch, int(rev0.rev), rev0.node[:12])]) + + def test_message_logfile(self): + self.assertRaises(ValueError, self.client.commit, 'foo', logfile='bar') + self.assertRaises(ValueError, self.client.commit)