diff hglib/client.py @ 57:2657fd6fef04

client: add heads command
author Idan Kamara <idankk86@gmail.com>
date Fri, 19 Aug 2011 20:08:13 +0300
parents 9bd819da245a
children d0b9215180a4
line wrap: on
line diff
--- a/hglib/client.py	Fri Aug 19 20:08:13 2011 +0300
+++ b/hglib/client.py	Fri Aug 19 20:08:13 2011 +0300
@@ -434,6 +434,24 @@
 
         return util.grouper(fieldcount, out)
 
+    def heads(self, rev=[], startrev=[], topological=False, closed=False):
+        """
+        Return a list of current repository heads or branch heads
+        """
+        if not isinstance(rev, list):
+            rev = [rev]
+
+        args = cmdbuilder('heads', *rev, r=startrev, t=topological, c=closed,
+                          template=templates.changeset)
+
+        def eh(ret, out, err):
+            if ret != 1:
+                raise error.CommandError(args, ret, out, err)
+            return ''
+
+        out = self.rawcommand(args, eh=eh).split('\0')[:-1]
+        return self._parserevs(out)
+
     def diff(self, files=[], revs=[], change=None, text=False,
              git=False, nodates=False, showfunction=False, reverse=False,
              ignoreallspace=False, ignorespacechange=False, ignoreblanklines=False,