Show More
@@ -1107,18 +1107,50 b' class gitsubrepo(abstractsubrepo):' | |||
|
1107 | 1107 | raise |
|
1108 | 1108 | self._gitexecutable = 'git.cmd' |
|
1109 | 1109 | out, err = self._gitnodir(['--version']) |
|
1110 | versionstatus = self._checkversion(out) | |
|
1111 | if versionstatus == 'unknown': | |
|
1112 | self._ui.warn(_('cannot retrieve git version\n')) | |
|
1113 | elif versionstatus == 'abort': | |
|
1114 | raise util.Abort(_('git subrepo requires at least 1.6.0 or later')) | |
|
1115 | elif versionstatus == 'warning': | |
|
1116 | self._ui.warn(_('git subrepo requires at least 1.6.0 or later\n')) | |
|
1117 | ||
|
1118 | @staticmethod | |
|
1119 | def _checkversion(out): | |
|
1120 | '''ensure git version is new enough | |
|
1121 | ||
|
1122 | >>> _checkversion = gitsubrepo._checkversion | |
|
1123 | >>> _checkversion('git version 1.6.0') | |
|
1124 | 'ok' | |
|
1125 | >>> _checkversion('git version 1.8.5') | |
|
1126 | 'ok' | |
|
1127 | >>> _checkversion('git version 1.4.0') | |
|
1128 | 'abort' | |
|
1129 | >>> _checkversion('git version 1.5.0') | |
|
1130 | 'warning' | |
|
1131 | >>> _checkversion('git version 1.9-rc0') | |
|
1132 | 'ok' | |
|
1133 | >>> _checkversion('git version 1.9.0.265.g81cdec2') | |
|
1134 | 'ok' | |
|
1135 | >>> _checkversion('git version 1.9.0.GIT') | |
|
1136 | 'ok' | |
|
1137 | >>> _checkversion('git version 12345') | |
|
1138 | 'unknown' | |
|
1139 | >>> _checkversion('no') | |
|
1140 | 'unknown' | |
|
1141 | ''' | |
|
1110 | 1142 | m = re.search(r'^git version (\d+)\.(\d+)', out) |
|
1111 | 1143 | if not m: |
|
1112 | self._ui.warn(_('cannot retrieve git version\n')) | |
|
1113 | return | |
|
1144 | return 'unknown' | |
|
1114 | 1145 | version = (int(m.group(1)), int(m.group(2))) |
|
1115 | 1146 | # git 1.4.0 can't work at all, but 1.5.X can in at least some cases, |
|
1116 | 1147 | # despite the docstring comment. For now, error on 1.4.0, warn on |
|
1117 | 1148 | # 1.5.0 but attempt to continue. |
|
1118 | 1149 | if version < (1, 5): |
|
1119 | raise util.Abort(_('git subrepo requires at least 1.6.0 or later')) | |
|
1150 | return 'abort' | |
|
1120 | 1151 | elif version < (1, 6): |
|
1121 | self._ui.warn(_('git subrepo requires at least 1.6.0 or later\n')) | |
|
1152 | return 'warning' | |
|
1153 | return 'ok' | |
|
1122 | 1154 | |
|
1123 | 1155 | def _gitcommand(self, commands, env=None, stream=False): |
|
1124 | 1156 | return self._gitdir(commands, env=env, stream=stream)[0] |
General Comments 0
You need to be logged in to leave comments.
Login now