Submitter | Mathias De Maré |
---|---|
Date | Dec. 10, 2014, 9:48 a.m. |
Message ID | <239ccaaed78095a128fd.1418204927@mathias-Latitude-E6540> |
Download | mbox | patch |
Permalink | /patch/7039/ |
State | Accepted |
Commit | 49a58b33d1ced975fee1e3fd7bb8fca0084017c0 |
Headers | show |
Comments
On 12/10/2014 01:48 AM, Mathias De Maré wrote: > # HG changeset patch > # User Mathias De Maré <mathias.demare@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@selenic.com > http://selenic.com/mailman/listinfo/mercurial-devel
On Wed, 2014-12-10 at 13:07 -0800, Siddharth Agarwal wrote: > On 12/10/2014 01:48 AM, Mathias De Maré wrote: > > # HG changeset patch > > # User Mathias De Maré <mathias.demare@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) It falls through to here? So it becomes a question of whether we need to distinguish between x.y-rc (and friends) and x.y.0, right?
On 12/10/2014 01:31 PM, Matt Mackall wrote: > On Wed, 2014-12-10 at 13:07 -0800, Siddharth Agarwal wrote: >> On 12/10/2014 01:48 AM, Mathias De Maré wrote: >>> # HG changeset patch >>> # User Mathias De Maré <mathias.demare@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) > It falls through to here? So it becomes a question of whether we need to > distinguish between x.y-rc (and friends) and x.y.0, right? > Ah, I didn't notice that. I'm OK with not distinguishing between rc and 0 unless in the future we need to.
Patch
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))) + 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,