comparison mercurial/subrepo.py @ 23521:f5de2a82b77e

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.
author Mathias De Mar? <mathias.demare@gmail.com>
date Wed, 10 Dec 2014 08:33:03 +0100
parents 2d86f4e38c08
children 49a58b33d1ce
comparison
equal deleted inserted replaced
23520:de143427c499 23521:f5de2a82b77e
1133 raise util.Abort(_('git subrepo requires at least 1.6.0 or later')) 1133 raise util.Abort(_('git subrepo requires at least 1.6.0 or later'))
1134 elif versionstatus == 'warning': 1134 elif versionstatus == 'warning':
1135 self._ui.warn(_('git subrepo requires at least 1.6.0 or later\n')) 1135 self._ui.warn(_('git subrepo requires at least 1.6.0 or later\n'))
1136 1136
1137 @staticmethod 1137 @staticmethod
1138 def _gitversion(out):
1139 m = re.search(r'^git version (\d+)\.(\d+)', out)
1140 if m:
1141 return (int(m.group(1)), int(m.group(2)))
1142
1143 return -1
1144
1145 @staticmethod
1138 def _checkversion(out): 1146 def _checkversion(out):
1139 '''ensure git version is new enough 1147 '''ensure git version is new enough
1140 1148
1141 >>> _checkversion = gitsubrepo._checkversion 1149 >>> _checkversion = gitsubrepo._checkversion
1142 >>> _checkversion('git version 1.6.0') 1150 >>> _checkversion('git version 1.6.0')
1156 >>> _checkversion('git version 12345') 1164 >>> _checkversion('git version 12345')
1157 'unknown' 1165 'unknown'
1158 >>> _checkversion('no') 1166 >>> _checkversion('no')
1159 'unknown' 1167 'unknown'
1160 ''' 1168 '''
1161 m = re.search(r'^git version (\d+)\.(\d+)', out) 1169 version = gitsubrepo._gitversion(out)
1162 if not m:
1163 return 'unknown'
1164 version = (int(m.group(1)), int(m.group(2)))
1165 # git 1.4.0 can't work at all, but 1.5.X can in at least some cases, 1170 # git 1.4.0 can't work at all, but 1.5.X can in at least some cases,
1166 # despite the docstring comment. For now, error on 1.4.0, warn on 1171 # despite the docstring comment. For now, error on 1.4.0, warn on
1167 # 1.5.0 but attempt to continue. 1172 # 1.5.0 but attempt to continue.
1173 if version == -1:
1174 return 'unknown'
1168 if version < (1, 5): 1175 if version < (1, 5):
1169 return 'abort' 1176 return 'abort'
1170 elif version < (1, 6): 1177 elif version < (1, 6):
1171 return 'warning' 1178 return 'warning'
1172 return 'ok' 1179 return 'ok'