1N/A# This program is free software; you can redistribute it and/or modify 1N/A# it under the terms of the GNU General Public License version 2 1N/A# as published by the Free Software Foundation. 1N/A# This program is distributed in the hope that it will be useful, 1N/A# but WITHOUT ANY WARRANTY; without even the implied warranty of 1N/A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1N/A# GNU General Public License for more details. 1N/A# You should have received a copy of the GNU General Public License 1N/A# along with this program; if not, write to the Free Software 1N/A# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 2N/A# Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. 1N/A# Copyright 2008, 2010, Richard Lowe 1N/ADeal with Mercurial versioning. 1N/AAt a basic level, code to verify that the version of Mercurial in use 1N/Ais suitable for use with Cadmium, and compare that version for the 1N/Asake of adapting to Mercurial API changes. 1N/A# It is important that this module rely on as little of Mercurial as 1N/A# Mercurial >= 1.2 has util.version(), prior versions 1N/A# version.get_version() We discover which to use this way, rather than 1N/A# via ImportError to account for mercurial.demandimport delaying the 1N/A# ImportError exception. 1N/A "Exception used to indicate a mismatch between SCM tools and Mercurial" 1N/A# List of versions that are explicitly acceptable to us 2N/A '1.8.1',
'1.8.2',
'1.8.4',
'2.2.1']
1N/A '''Check that we're running on a suitable version of Mercurial''' 1N/A '''return the list, versions, as a vaguely grammatical string''' 1N/A "actual version is %s." %
1N/A '''Return the Mercurial version as a list [MAJOR, MINOR, MICRO], 1N/A if this is not a released Mercurial return None.''' 1N/A # If there's only one element, it's not really a tagged version 1N/A '''Return boolean indicating if the running version is greater 1N/A than or equal to, the version specified by major, minor, micro''' 1N/A # If _split_version() returns None, we're running on a Mercurial that 1N/A # has not been tagged as a release. We assume this to be newer 1N/A # than any released version. 1N/A # Pad our versions to the same overall length, appending 0's