[PATCH 2 of 3] subrepo: extend git version check to 3 digits
Siddharth Agarwal
sid at less-broken.com
Wed Dec 10 15:07:20 CST 2014
On 12/10/2014 01:48 AM, Mathias De Maré wrote:
> # 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)))
I actually changed this to be two digits instead of three because this
doesn't work with rc versions of Git. The doctests cover this.
> +
> 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,
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list