23a24,25
> #    [HG_REPOSITORY url]         # URL of the mercurial repo
> #    [HG_TAG tag]                # mercurial branch name, commit id or tag
260a263
> 
309a313,340
> function(_ep_write_hgclone_script script_filename source_dir hg_EXECUTABLE hg_repository hg_tag src_name work_dir)
>   file(WRITE ${script_filename}
> "if(\"${hg_tag}\" STREQUAL \"\")
>   message(FATAL_ERROR \"Tag for git checkout should not be empty.\")
> endif()
> 
> 
> execute_process(
>   COMMAND \${CMAKE_COMMAND} -E remove_directory \"${source_dir}\"
>   RESULT_VARIABLE error_code
>   )
> if(error_code)
>   message(FATAL_ERROR \"Failed to remove directory: '${source_dir}'\")
> endif()
> 
> execute_process(
>   COMMAND \"${hg_EXECUTABLE}\" clone \"${hg_repository}\" -r ${hg_tag} \"${src_name}\"
>   WORKING_DIRECTORY \"${work_dir}\"
>   RESULT_VARIABLE error_code
>   )
> if(error_code)
>   message(FATAL_ERROR \"Failed to clone repository: '${git_repository}'\")
> endif()
> 
> "
> )
> 
> endfunction(_ep_write_hgclone_script)
963a995,1000
> function(_ep_get_hg_version hg_EXECUTABLE hg_version_var)
>   if(HG_EXECUTABLE)
>     set(${hg_version_var} "${HG_VERSION_STRING}" PARENT_SCOPE)
>   endif()
> endfunction()
> 
982a1020
>   get_property(hg_repository TARGET ${name} PROPERTY _EP_HG_REPOSITORY)
1096a1135,1172
>   elseif(hg_repository)
>     include(FindMercurial)
>     if(NOT HG_EXECUTABLE)
>       message(FATAL_ERROR "error: could not find mercurial for clone of ${name}")
>     endif()
> 
> 	_ep_get_hg_version("${HG_EXECUTABLE}" hg_version)
> 	if(hg_version VERSION_LESS 2.0.0)
>       message(WARNING "Warning: hg version 2.0.0 or later might be required.  hg_version='${hg_version}'")
>     endif()
> 
>     get_property(hg_tag TARGET ${name} PROPERTY _EP_HG_TAG)
>     if(NOT hg_tag)
>       set(hg_tag "default")
>     endif()
> 
>     set(repository ${hg_repository})
>     set(module)
>     set(tag ${hg_tag})
>     configure_file(
>       "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
>       "${stamp_dir}/${name}-hginfo.txt"
>       @ONLY
>       )
> 
>     get_filename_component(src_name "${source_dir}" NAME)
>     get_filename_component(work_dir "${source_dir}" PATH)
> 
>     # Since git clone doesn't succeed if the non-empty source_dir exists,
>     # create a cmake script to invoke as download command.
>     # The script will delete the source directory and then call git clone.
>     #
>     _ep_write_hgclone_script(${tmp_dir}/${name}-hgclone.cmake ${source_dir}
>       ${HG_EXECUTABLE} ${hg_repository} ${hg_tag} ${src_name} ${work_dir}
>       )
>     set(comment "Performing download step (hg clone) for '${name}'")
>     set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-hgclone.cmake)
>     list(APPEND depends ${stamp_dir}/${name}-hginfo.txt)
1144c1220
<       message(SEND_ERROR "error: no download info for '${name}' -- please specify existing/non-empty SOURCE_DIR or one of URL, CVS_REPOSITORY and CVS_MODULE, SVN_REPOSITORY, GIT_REPOSITORY or DOWNLOAD_COMMAND")
---
>       message(SEND_ERROR "error: no download info for '${name}' -- please specify existing/non-empty SOURCE_DIR or one of URL, CVS_REPOSITORY and CVS_MODULE, SVN_REPOSITORY, GIT_REPOSITORY, HG_REPOSITORY or DOWNLOAD_COMMAND")
1173a1250
>   get_property(hg_repository TARGET ${name} PROPERTY _EP_HG_REPOSITORY)
