From patchwork Mon Jun 19 00:00:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1, of, 2, fix-old-git, V2] hghave: add has_git_range for testing if git understands ext::sh From: Sean Farley X-Patchwork-Id: 21495 Message-Id: <8e8e4eb5d74ec4ed2ea5.1497830431@1.0.0.127.in-addr.arpa> To: mercurial-devel@mercurial-scm.org Cc: sean@farley.io Date: Sun, 18 Jun 2017 17:00:31 -0700 # HG changeset patch # User Sean Farley # Date 1497572003 25200 # Thu Jun 15 17:13:23 2017 -0700 # Branch fix-old-git # Node ID 8e8e4eb5d74ec4ed2ea59db3defa9819ddc0db8b # Parent 07d5a503124caed05e1300a5208240764882c831 hghave: add has_git_range for testing if git understands ext::sh Even on CentOS 7, git is at version 1.8. It seems git 1.9 is when ext::sh was introduced so we a check for that. The way these functions are written follows the same style and format for the way we check svn and bzr versions. diff --git a/tests/hghave.py b/tests/hghave.py index 09b8dbe..2cb0d1f 100644 --- a/tests/hghave.py +++ b/tests/hghave.py @@ -276,10 +276,21 @@ def has_gettext(): @check("git", "git command line client") def has_git(): return matchoutput('git --version 2>&1', br'^git version') +def getgitversion(): + m = matchoutput('git --version 2>&1', br'git version (\d+)\.(\d+)') + if not m: + return (0, 0) + return (int(m.group(1)), int(m.group(2))) + +@checkvers("git", "git client (with ext::sh support) version >= %s", (1.9,)) +def has_git_range(v): + major, minor = v.split('.')[0:2] + return getgitversion() >= (int(major), int(minor)) + @check("docutils", "Docutils text processing library") def has_docutils(): try: import docutils.core docutils.core.publish_cmdline # silence unused import