summaryrefslogtreecommitdiff
path: root/tortoisehg/util/hgversion.py
blob: 93d57a1a7bbb6a4dfe1878349f07594030e9b13f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# hgversion.py - Version information for Mercurial
#
# Copyright 2009 Steve Borho <steve@borho.org>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2, incorporated herein by reference.

import re

try:
    # post 1.1.2
    from mercurial import util
    hgversion = util.version()
except AttributeError:
    # <= 1.1.2
    from mercurial import version
    hgversion = version.get_version()

testedwith = '4.6 4.7'

def checkhgversion(v):
    """range check the Mercurial version"""
    reqvers = testedwith.split()
    v = v.split('+')[0]
    if not v or v == 'unknown' or len(v) >= 12:
        # can't make any intelligent decisions about unknown or hashes
        return
    vers = re.split(r'\.|-|rc', v)[:2]
    if len(vers) < 2:
        return
    if '.'.join(vers) in reqvers:
        return
    return ('This version of TortoiseHg requires Mercurial version %s.n to '
            '%s.n, but found %s') % (reqvers[0], reqvers[-1], v)