subrepo: move git version check into a separate method
authorMathias De Maré <mathias.demare@gmail.com>
Wed, 10 Dec 2014 08:33:03 +0100
changeset 23521 f5de2a82b77e
parent 23520 de143427c499
child 23522 49a58b33d1ce
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.
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):