comparison mercurial/subrepo.py @ 17024:33b057778cd2 stable

subrepo: warn user if Git is not version 1.6.0 or higher
author Benjamin Pollack <benjamin@bitquabit.com>
date Tue, 12 Jun 2012 09:28:55 -0400
parents 95ca6c8b38da
children 8ad08dcab7d9
comparison
equal deleted inserted replaced
16999:01eb88248937 17024:33b057778cd2
838 return self._svncommand(['cat'], name)[0] 838 return self._svncommand(['cat'], name)[0]
839 839
840 840
841 class gitsubrepo(abstractsubrepo): 841 class gitsubrepo(abstractsubrepo):
842 def __init__(self, ctx, path, state): 842 def __init__(self, ctx, path, state):
843 # TODO add git version check.
844 self._state = state 843 self._state = state
845 self._ctx = ctx 844 self._ctx = ctx
846 self._path = path 845 self._path = path
847 self._relpath = os.path.join(reporelpath(ctx._repo), path) 846 self._relpath = os.path.join(reporelpath(ctx._repo), path)
848 self._abspath = ctx._repo.wjoin(path) 847 self._abspath = ctx._repo.wjoin(path)
849 self._subparent = ctx._repo 848 self._subparent = ctx._repo
850 self._ui = ctx._repo.ui 849 self._ui = ctx._repo.ui
850 self._ensuregit()
851
852 def _ensuregit(self):
853 out, err = self._gitnodir(['--version'])
854 m = re.search(r'^git version (\d+)\.(\d+)\.(\d+)', out)
855 if not m:
856 self._ui.warn(_('cannot retrieve git version'))
857 return
858 version = (int(m.group(1)), m.group(2), m.group(3))
859 # git 1.4.0 can't work at all, but 1.5.X can in at least some cases,
860 # despite the docstring comment. For now, error on 1.4.0, warn on
861 # 1.5.0 but attempt to continue.
862 if version < (1, 5, 0):
863 raise util.Abort(_('git subrepo requires at least 1.6.0 or later'))
864 elif version < (1, 6, 0):
865 self._ui.warn(_('git subrepo requires at least 1.6.0 or later'))
851 866
852 def _gitcommand(self, commands, env=None, stream=False): 867 def _gitcommand(self, commands, env=None, stream=False):
853 return self._gitdir(commands, env=env, stream=stream)[0] 868 return self._gitdir(commands, env=env, stream=stream)[0]
854 869
855 def _gitdir(self, commands, env=None, stream=False): 870 def _gitdir(self, commands, env=None, stream=False):