Version.py revision cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0
080575042aba2197b425ebfd52061dea061a9aa1xy#
080575042aba2197b425ebfd52061dea061a9aa1xy# This program is free software; you can redistribute it and/or modify
080575042aba2197b425ebfd52061dea061a9aa1xy# it under the terms of the GNU General Public License version 2
080575042aba2197b425ebfd52061dea061a9aa1xy# as published by the Free Software Foundation.
080575042aba2197b425ebfd52061dea061a9aa1xy#
080575042aba2197b425ebfd52061dea061a9aa1xy# This program is distributed in the hope that it will be useful,
080575042aba2197b425ebfd52061dea061a9aa1xy# but WITHOUT ANY WARRANTY; without even the implied warranty of
080575042aba2197b425ebfd52061dea061a9aa1xy# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d5c3073dbbd835e1e9b7dca0c6c770cf3cc20afachenlu chen - Sun Microsystems - Beijing China# GNU General Public License for more details.
080575042aba2197b425ebfd52061dea061a9aa1xy#
080575042aba2197b425ebfd52061dea061a9aa1xy# You should have received a copy of the GNU General Public License
080575042aba2197b425ebfd52061dea061a9aa1xy# along with this program; if not, write to the Free Software
080575042aba2197b425ebfd52061dea061a9aa1xy# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
080575042aba2197b425ebfd52061dea061a9aa1xy#
080575042aba2197b425ebfd52061dea061a9aa1xy
080575042aba2197b425ebfd52061dea061a9aa1xy#
080575042aba2197b425ebfd52061dea061a9aa1xy# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
080575042aba2197b425ebfd52061dea061a9aa1xy# Use is subject to license terms.
080575042aba2197b425ebfd52061dea061a9aa1xy#
080575042aba2197b425ebfd52061dea061a9aa1xy# ident "%Z%%M% %I% %E% SMI"
080575042aba2197b425ebfd52061dea061a9aa1xy
3fb4efef75bbb3a06a68d5ff59c33df03c73f6c9changqing li - Sun Microsystems - Beijing China'''
29fd2c1627adafbe0a83726c224e60b5514c7736David HöppnerMinimal amount of code to check the version of Mercurial in use
49b7860084dbba18bc00b29413d6182197f9fe93Robert Mustacchiagainst our expectations.
080575042aba2197b425ebfd52061dea061a9aa1xy'''
080575042aba2197b425ebfd52061dea061a9aa1xy
080575042aba2197b425ebfd52061dea061a9aa1xy#
080575042aba2197b425ebfd52061dea061a9aa1xy# It is important that this rely on as little of Mercurial as is possible.
080575042aba2197b425ebfd52061dea061a9aa1xy#
080575042aba2197b425ebfd52061dea061a9aa1xy
080575042aba2197b425ebfd52061dea061a9aa1xyfrom mercurial import version
080575042aba2197b425ebfd52061dea061a9aa1xy
080575042aba2197b425ebfd52061dea061a9aa1xy
080575042aba2197b425ebfd52061dea061a9aa1xyclass VersionMismatch(Exception):
080575042aba2197b425ebfd52061dea061a9aa1xy "Exception used to indicate a mis-match between Scm tools and Mercurial"
080575042aba2197b425ebfd52061dea061a9aa1xy pass
080575042aba2197b425ebfd52061dea061a9aa1xy
080575042aba2197b425ebfd52061dea061a9aa1xy#
080575042aba2197b425ebfd52061dea061a9aa1xy# List of versions that are explicitly acceptable to us
080575042aba2197b425ebfd52061dea061a9aa1xy#
080575042aba2197b425ebfd52061dea061a9aa1xyGOOD_VERSIONS = ['1.0']
080575042aba2197b425ebfd52061dea061a9aa1xy
080575042aba2197b425ebfd52061dea061a9aa1xy
080575042aba2197b425ebfd52061dea061a9aa1xydef check_version():
080575042aba2197b425ebfd52061dea061a9aa1xy '''Check that we're running on a suitable version of Mercurial'''
080575042aba2197b425ebfd52061dea061a9aa1xy
080575042aba2197b425ebfd52061dea061a9aa1xy def versionstring(versions):
080575042aba2197b425ebfd52061dea061a9aa1xy '''return the list, versions, as a vaguely grammatical string'''
080575042aba2197b425ebfd52061dea061a9aa1xy if len(versions) > 1:
080575042aba2197b425ebfd52061dea061a9aa1xy return "%s or %s" % (', '.join(versions[0:-1]), versions[-1])
080575042aba2197b425ebfd52061dea061a9aa1xy else:
080575042aba2197b425ebfd52061dea061a9aa1xy return versions[0]
080575042aba2197b425ebfd52061dea061a9aa1xy
080575042aba2197b425ebfd52061dea061a9aa1xy if version.get_version() not in GOOD_VERSIONS:
080575042aba2197b425ebfd52061dea061a9aa1xy raise VersionMismatch("Scm expects Mercurial version %s, "
080575042aba2197b425ebfd52061dea061a9aa1xy "actual version is %s" %
080575042aba2197b425ebfd52061dea061a9aa1xy (versionstring(GOOD_VERSIONS),
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng version.get_version()))
080575042aba2197b425ebfd52061dea061a9aa1xy