[PATCH 2 of 3] subrepo: extend git version check to 3 digits
Mathias De Maré
mathias.demare at gmail.com
Wed Dec 10 09:48:47 UTC 2014
# HG changeset patch
# User Mathias De Maré <mathias.demare at gmail.com>
# Date 1418197281 -3600
# Mit Dez 10 08:41:21 2014 +0100
# Node ID 239ccaaed78095a128fde4b1421de3d997068c6f
# Parent 5a05303a5e4753fb21e99c08635284c25dc8569f
subrepo: extend git version check to 3 digits
This allows more flexibility when a version check is required.
Some git features are introduced in a version where only
the 3rd digit changes.
diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -1131,19 +1131,23 @@ class gitsubrepo(abstractsubrepo):
self._ui.warn(_('cannot retrieve git version\n'))
elif versionstatus == 'abort':
raise util.Abort(_('git subrepo requires at least 1.6.0 or later'))
elif versionstatus == 'warning':
self._ui.warn(_('git subrepo requires at least 1.6.0 or later\n'))
@staticmethod
def _gitversion(out):
+ m = re.search(r'^git version (\d+)\.(\d+)\.(\d+)', out)
+ if m:
+ return (int(m.group(1)), int(m.group(2)), int(m.group(3)))
+
m = re.search(r'^git version (\d+)\.(\d+)', out)
if m:
- return (int(m.group(1)), int(m.group(2)))
+ return (int(m.group(1)), int(m.group(2)), 0)
return -1
@staticmethod
def _checkversion(out):
'''ensure git version is new enough
>>> _checkversion = gitsubrepo._checkversion
@@ -1167,19 +1171,19 @@ class gitsubrepo(abstractsubrepo):
'unknown'
'''
version = gitsubrepo._gitversion(out)
# git 1.4.0 can't work at all, but 1.5.X can in at least some cases,
# despite the docstring comment. For now, error on 1.4.0, warn on
# 1.5.0 but attempt to continue.
if version == -1:
return 'unknown'
- if version < (1, 5):
+ if version < (1, 5, 0):
return 'abort'
- elif version < (1, 6):
+ elif version < (1, 6, 0):
return 'warning'
return 'ok'
def _gitcommand(self, commands, env=None, stream=False):
return self._gitdir(commands, env=env, stream=stream)[0]
def _gitdir(self, commands, env=None, stream=False):
return self._gitnodir(commands, env=env, stream=stream,
More information about the Mercurial-devel
mailing list