Add version number (add_version_option.diff)

this patch closes 3 1/2 tickets : #259572, my duplicate #259595, #105330 & #7316 and addresses #205487 ...

download
# HG changeset patch
# Parent 9c4fb900402c65b8f733120aa4ec69223c820dab
# User "Emile Anclin" <emile.anclin@laposte.net>
[option] add a version option (closes #259595, #259572, #105330, #7316)

diff -r 9c4fb900402c hgviewlib/application.py
--- a/hgviewlib/application.py	Wed Jul 30 10:18:51 2014 +0200
+++ b/hgviewlib/application.py	Wed Jul 30 10:46:45 2014 +0200
@@ -122,6 +122,11 @@
            'raw': _curses_application,
            'curses': _curses_application}
 
+def hgview_version():
+    """print Hgview and Python version"""
+    from hgviewlib.__pkginfo__ import version
+    sys.stdout.write('Hgview %s\nPython %s\n' % (version, sys.version))
+    return 0
 
 def start(repo, opts, args, fnerror):
     """
@@ -206,9 +211,13 @@
     parser.add_option('-n', '--navigate', dest='navigate', default=False,
                       action="store_true",
                       help='(with filename) start in navigation mode')
+    parser.add_option('--version', default=False, action="store_true",
+                      help='Print the version of Hgview and exit.')
+
 
     opts, args = parser.parse_args()
-
+    if opts.version:
+        sys.exit(hgview_version())
     if opts.repo:
         dir_ = opts.repo
     else: