[PATCH 6 of 8 hglib] client: add version command
Idan Kamara
idankk86 at gmail.com
Mon Aug 15 14:54:14 CDT 2011
# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1313437605 -10800
# Node ID 025cfded765ca8df1966c8edd16c78b3a6d96c93
# Parent dedaa2e9eefe610be347c943bad9da6e901353de
client: add version command
diff -r dedaa2e9eefe -r 025cfded765c hglib/client.py
--- a/hglib/client.py Mon Aug 15 22:46:45 2011 +0300
+++ b/hglib/client.py Mon Aug 15 22:46:45 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