Mercurial > python-hglib
changeset 37:5506a241c826
client: add diff command
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Mon, 15 Aug 2011 22:46:45 +0300 |
parents | 00bb0701323a |
children | 32f6a2bbf63e |
files | hglib/client.py tests/test-diff.py |
diffstat | 2 files changed, 56 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hglib/client.py Mon Aug 15 22:46:45 2011 +0300 +++ b/hglib/client.py Mon Aug 15 22:46:45 2011 +0300 @@ -340,6 +340,22 @@ out = self.rawcommand(args, eh=eh) return not warnings[0] + def diff(self, files=[], revs=[], change=None, text=False, + git=False, nodates=False, showfunction=False, reverse=False, + ignoreallspace=False, ignorespacechange=False, ignoreblanklines=False, + unified=None, stat=False, subrepos=False, include=None, exclude=None): + if change and revs: + raise ValueError('cannot specify both change and rev') + + args = cmdbuilder('diff', *files, r=revs, c=change, + a=text, g=git, nodates=nodates, + p=showfunction, reverse=reverse, + w=ignoreallspace, b=ignorespacechange, + B=ignoreblanklines, U=unified, stat=stat, + S=subrepos, I=include, X=exclude) + + return self.rawcommand(args) + def import_(self, patches, strip=None, force=False, nocommit=False, bypass=False, exact=False, importbranch=False, message=None, date=None, user=None, similarity=None):
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-diff.py Mon Aug 15 22:46:45 2011 +0300 @@ -0,0 +1,40 @@ +import common + +class test_diff(common.basetest): + def test_basic(self): + self.append('a', 'a\n') + self.client.add('a') + diff1 = """diff -r 000000000000 a +--- /dev/null ++++ b/a +@@ -0,0 +1,1 @@ ++a +""" + self.assertEquals(diff1, self.client.diff(nodates=True)) + self.assertEquals(diff1, self.client.diff(['a'], nodates=True)) + rev0, node0 = self.client.commit('first') + diff2 = """diff -r 000000000000 -r %s a +--- /dev/null ++++ b/a +@@ -0,0 +1,1 @@ ++a +""" % node0[:12] + self.assertEquals(diff2, self.client.diff(change=rev0, nodates=True)) + self.append('a', 'a\n') + rev1, node1 = self.client.commit('second') + diff3 = """diff -r %s a +--- a/a ++++ b/a +@@ -1,1 +1,2 @@ + a ++a +""" % node0[:12] + self.assertEquals(diff3, self.client.diff(revs=[rev0], nodates=True)) + diff4 = """diff -r %s -r %s a +--- a/a ++++ b/a +@@ -1,1 +1,2 @@ + a ++a +""" % (node0[:12], node1[:12]) + self.assertEquals(diff4, self.client.diff(revs=[rev0, rev1], nodates=True))