1
0
Fork 0
mirror of https://github.com/correl/rebar.git synced 2025-04-10 17:00:11 -09:00

Ensure we have the correct hg version

This commit is contained in:
iw 2010-01-06 22:22:05 +00:00
parent 59b1f74498
commit 864d4b74d6

View file

@ -31,6 +31,8 @@
-export([preprocess/2, -export([preprocess/2,
distclean/2]). distclean/2]).
-define(HG_VERSION, "1.4").
%% =================================================================== %% ===================================================================
%% Public API %% Public API
%% =================================================================== %% ===================================================================
@ -207,13 +209,31 @@ download_source(AppDir, {hg, Url, Rev}) ->
%% =================================================================== %% ===================================================================
source_engine_avail({hg, _, _}) -> source_engine_avail({hg, _, _}) ->
Res = os:cmd("which hg"), Path = os:find_executable("hg"),
?DEBUG("which hg = ~p\n", [Res]), ?DEBUG("which hg = ~p\n", [Path]),
case Res of case Path of
[] -> false ->
false; false;
_ -> _ ->
true ensure_required_scm_client(hg, Path)
end; end;
source_engine_avail(_) -> source_engine_avail(_) ->
false. false.
%% We expect the initial part of the version string to be of the form:
%% "Mercurial Distributed SCM (version 1.4.1+20091201)". Rebar
%% requires version 1.4 or higher.
ensure_required_scm_client(hg, Path) ->
Info = os:cmd(Path ++ " --version"),
case re:run(Info, "version (\\d*\.\\d*\.\\d*)", [{capture, all_but_first, list}]) of
{match, [Vsn]} ->
case Vsn >= ?HG_VERSION of
true ->
true;
false ->
?ABORT("Rebar requires version ~p or higher of hg (~p)~n",
[?HG_VERSION, Path])
end;
_ ->
false
end.