[PATCH 7 of 9 hglib] client: add version command
Idan Kamara
idankk86 at gmail.com
Mon Aug 15 14:20:48 CDT 2011
# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1313435643 -10800
# Node ID 5b26529cdeeec3d7075792cf46c511ded8a1e893
# Parent 94c2138e465513b8a20e220b6fa51446d1f95e3b
client: add version command
diff -r 94c2138e4655 -r 5b26529cdeee hglib/client.py
--- a/hglib/client.py Mon Aug 15 22:12:54 2011 +0300
+++ b/hglib/client.py Mon Aug 15 22:14:03 2011 +0300
@@ -26,6 +26,7 @@
stdout=subprocess.PIPE, env=env)
self._readhello()
+ self._version = None
def _readhello(self):
""" read the hello message the server sends when started """
@@ -645,3 +646,20 @@
counters = out.rstrip().split(', ')
return tuple(int(s.split(' ', 1)[0]) for s in counters)
+
+ @property
+ def version(self):
+ if self._version is None:
+ v = self.rawcommand(cmdbuilder('version', q=True))
+ v = list(re.match(r'.*?(\d+)\.(\d+)\.?(\d+)?(\+[0-9a-f-]+)?',
+ v).groups())
+
+ for i in range(3):
+ try:
+ v[i] = int(v[i])
+ except TypeError:
+ v[i] = 0
+
+ self._version = tuple(v)
+
+ return self._version
More information about the Mercurial-devel
mailing list