Patchwork [6,of,6,v3] hghave: add hg06..hg39

login
register
mail settings
Submitter timeless@mozdev.org
Date April 4, 2016, 2:20 a.m.
Message ID <6a048da8574029929bad.1459736454@waste.org>
Download mbox | patch
Permalink /patch/14317/
State Accepted
Headers show

Comments

timeless@mozdev.org - April 4, 2016, 2:20 a.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1459516847 0
#      Fri Apr 01 13:20:47 2016 +0000
# Node ID 6a048da8574029929badd9b01a2e57839d55023e
# Parent  6589202019dbd402d2b7fb6f8609ebba48c7f053
hghave: add hg06..hg39

hg output varies by version, this helps the hgbook

hg 0.6 did not have a version command, so special case it...
hg 0.7-0.8 had a version command which returned unknown...
hg 0.8 added a --date flag to annotate
hg 0.9 had a working version command!
Pierre-Yves David - April 4, 2016, 2:49 a.m.
On 04/03/2016 07:20 PM, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1459516847 0
> #      Fri Apr 01 13:20:47 2016 +0000
> # Node ID 6a048da8574029929badd9b01a2e57839d55023e
> # Parent  6589202019dbd402d2b7fb6f8609ebba48c7f053
> hghave: add hg06..hg39

Excellent, thanks for the clarification, pushed.

Patch

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -226,6 +226,36 @@ 
     except ImportError:
         return False
 
+def gethgversion():
+    m = matchoutput('hg --version --quiet 2>&1', r'(\d+)\.(\d+)')
+    if not m:
+        return (0, 0)
+    return (int(m.group(1)), int(m.group(2)))
+
+@checkvers("hg", "Mercurial >= %s",
+            list([(1.0 * x) / 10 for x in range(9, 40)]))
+def has_hg_range(v):
+    major, minor = v.split('.')[0:2]
+    return gethgversion() >= (int(major), int(minor))
+
+@check("hg08", "Mercurial >= 0.8")
+def has_hg08():
+    if checks["hg09"][0]():
+        return True
+    return matchoutput('hg help annotate 2>&1', '--date')
+
+@check("hg07", "Mercurial >= 0.7")
+def has_hg07():
+    if checks["hg08"][0]():
+        return True
+    return matchoutput('hg --version --quiet 2>&1', 'Mercurial Distributed SCM')
+
+@check("hg06", "Mercurial >= 0.6")
+def has_hg06():
+    if checks["hg07"][0]():
+        return True
+    return matchoutput('hg --version --quiet 2>&1', 'Mercurial version')
+
 @check("gettext", "GNU Gettext (msgfmt)")
 def has_gettext():
     return matchoutput('msgfmt --version', 'GNU gettext-tools')