diff hglib/client.py @ 43:77ebb51f5f36

client: add tags command
author Idan Kamara <idankk86@gmail.com>
date Mon, 15 Aug 2011 22:46:45 +0300
parents b6b75c71ac58
children 3a661f63107e
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
@@ -623,6 +623,24 @@
 
         self.rawcommand(args)
 
+    def tags(self):
+        """
+        Return a list of repository tags as: (name, rev, node, islocal)
+        """
+        args = cmdbuilder('tags', v=True)
+
+        out = self.rawcommand(args)
+
+        t = []
+        for line in out.splitlines():
+            taglocal = line.endswith(' local')
+            if taglocal:
+                line = line[:-6]
+            name, rev = line.rsplit(' ', 1)
+            rev, node = rev.split(':')
+            t.append((name.rstrip(), int(rev), node, taglocal))
+        return t
+
     def tip(self):
         args = cmdbuilder('tip', template=templates.changeset)
         out = self.rawcommand(args)