[PATCH 1 of 3] subrepo: only retrieve the first two components of the Git version

Siddharth Agarwal sid0 at fb.com
Fri Mar 21 02:58:17 UTC 2014


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1395369421 25200
#      Thu Mar 20 19:37:01 2014 -0700
# Node ID fae4002ec0e4060ffe84d6fb11d8ab1f566b2aa1
# Parent  170d6d591a7dbc09bfe1b509dfd8f39991e653a9
subrepo: only retrieve the first two components of the Git version

This makes the version detection compatible with Git versions like '1.9-rc0'.
We only cared about the first two components of the version anyway.

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -1107,17 +1107,17 @@
                 raise
             self._gitexecutable = 'git.cmd'
             out, err = self._gitnodir(['--version'])
-        m = re.search(r'^git version (\d+)\.(\d+)\.(\d+)', out)
+        m = re.search(r'^git version (\d+)\.(\d+)', out)
         if not m:
             self._ui.warn(_('cannot retrieve git version'))
             return
-        version = (int(m.group(1)), m.group(2), m.group(3))
+        version = (int(m.group(1)), m.group(2))
         # 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, 5, 0):
+        if version < (1, 5):
             raise util.Abort(_('git subrepo requires at least 1.6.0 or later'))
-        elif version < (1, 6, 0):
+        elif version < (1, 6):
             self._ui.warn(_('git subrepo requires at least 1.6.0 or later'))
 
     def _gitcommand(self, commands, env=None, stream=False):


More information about the Mercurial-devel mailing list