# HG changeset patch # User Mathias De Maré # Date 1418196783 -3600 # Node ID f5de2a82b77ef9d5209b78546404795c204f0a72 # Parent de143427c499c570d1e996c45b088d2a392296f6 subrepo: move git version check into a separate method This allows checking the git version in other methods, instead of only being able to check if the version is ok or not. diff -r de143427c499 -r f5de2a82b77e mercurial/subrepo.py --- a/mercurial/subrepo.py Thu Oct 11 23:22:02 2012 +0200 +++ b/mercurial/subrepo.py Wed Dec 10 08:33:03 2014 +0100 @@ -1135,6 +1135,14 @@ 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+)', out) + if m: + return (int(m.group(1)), int(m.group(2))) + + return -1 + + @staticmethod def _checkversion(out): '''ensure git version is new enough @@ -1158,13 +1166,12 @@ >>> _checkversion('no') 'unknown' ''' - m = re.search(r'^git version (\d+)\.(\d+)', out) - if not m: - return 'unknown' - version = (int(m.group(1)), int(m.group(2))) + 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): return 'abort' elif version < (1, 6):