changeset 913:5cc9594cc811

Add version info to hggit for "hg --version -v" getversion() also reports dulwich version
author anatoly techtonik <techtonik@gmail.com>
date Tue, 17 Mar 2015 15:05:00 +0300
parents 017db283e685
children b1b03873c9ad
files hggit/__init__.py setup.py
diffstat 2 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/__init__.py
+++ b/hggit/__init__.py
@@ -17,6 +17,15 @@
 For more information and instructions, see :hg:`help git`
 '''
 
+__version__ = '0.8.1'
+
+def getversion():
+    """return version with dependencies for hg --version -v"""
+    import dulwich
+    dulver = '.'.join(str(i) for i in dulwich.__version__)
+    return __version__ + (" (dulwich %s)" % dulver)
+
+
 from bisect import insort
 import os
 
--- a/setup.py
+++ b/setup.py
@@ -9,9 +9,19 @@
 except ImportError:
     extra_req = ['ordereddict>=1.1']
 
+
+from os.path import dirname, join
+def get_version(relpath):
+    root = dirname(__file__)
+    for line in open(join(root, relpath), 'rb'):
+        line = line.decode('utf-8')
+        if '__version__' in line:
+            return line.split("'")[1]
+
+
 setup(
     name='hg-git',
-    version='0.8.1',
+    version=get_version('hggit/__init__.py'),
     author='The hg-git Authors',
     maintainer='Augie Fackler',
     maintainer_email='durin42@gmail.com',