From 20eb94723f142f2bba420a05046157a3e115a3f0 Mon Sep 17 00:00:00 2001 From: mpeterv Date: Thu, 19 Mar 2015 16:02:25 +0300 Subject: Improve hg support * Allow fetching from remote hg repos using hg+http, hg+https and hg+ssh protocols; * Fix incorrect branch cloning. --- src/luarocks/fetch/hg.lua | 2 +- src/luarocks/fetch/hg_http.lua | 24 ++++++++++++++++++++++++ src/luarocks/fetch/hg_https.lua | 8 ++++++++ src/luarocks/fetch/hg_ssh.lua | 8 ++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/luarocks/fetch/hg_http.lua create mode 100644 src/luarocks/fetch/hg_https.lua create mode 100644 src/luarocks/fetch/hg_ssh.lua (limited to 'src') diff --git a/src/luarocks/fetch/hg.lua b/src/luarocks/fetch/hg.lua index b2ba56e9..e736a071 100644 --- a/src/luarocks/fetch/hg.lua +++ b/src/luarocks/fetch/hg.lua @@ -30,7 +30,7 @@ function hg.get_sources(rockspec, extract, dest_dir) local command = {hg_cmd, "clone", url, module} local tag_or_branch = rockspec.source.tag or rockspec.source.branch if tag_or_branch then - command = {hg_cmd, "clone", "--rev", url, module} + command = {hg_cmd, "clone", "--rev", tag_or_branch, url, module} end local store_dir if not dest_dir then diff --git a/src/luarocks/fetch/hg_http.lua b/src/luarocks/fetch/hg_http.lua new file mode 100644 index 00000000..8f506daf --- /dev/null +++ b/src/luarocks/fetch/hg_http.lua @@ -0,0 +1,24 @@ + +--- Fetch back-end for retrieving sources from hg repositories +-- that use http:// transport. For example, for fetching a repository +-- that requires the following command line: +-- `hg clone http://example.com/foo` +-- you can use this in the rockspec: +-- source = { url = "hg+http://example.com/foo" } +local hg_http = {} + +local hg = require("luarocks.fetch.hg") + +--- Download sources for building a rock, using hg over http. +-- @param rockspec table: The rockspec table +-- @param extract boolean: Unused in this module (required for API purposes.) +-- @param dest_dir string or nil: If set, will extract to the given directory. +-- @return (string, string) or (nil, string): The absolute pathname of +-- the fetched source tarball and the temporary directory created to +-- store it; or nil and an error message. +function hg_http.get_sources(rockspec, extract, dest_dir) + rockspec.source.url = rockspec.source.url:gsub("^hg.", "") + return hg.get_sources(rockspec, extract, dest_dir) +end + +return hg_http diff --git a/src/luarocks/fetch/hg_https.lua b/src/luarocks/fetch/hg_https.lua new file mode 100644 index 00000000..e67417fe --- /dev/null +++ b/src/luarocks/fetch/hg_https.lua @@ -0,0 +1,8 @@ + +--- Fetch back-end for retrieving sources from hg repositories +-- that use https:// transport. For example, for fetching a repository +-- that requires the following command line: +-- `hg clone https://example.com/foo` +-- you can use this in the rockspec: +-- source = { url = "hg+https://example.com/foo" } +return require "luarocks.fetch.hg_http" diff --git a/src/luarocks/fetch/hg_ssh.lua b/src/luarocks/fetch/hg_ssh.lua new file mode 100644 index 00000000..0c365fab --- /dev/null +++ b/src/luarocks/fetch/hg_ssh.lua @@ -0,0 +1,8 @@ + +--- Fetch back-end for retrieving sources from hg repositories +-- that use ssh:// transport. For example, for fetching a repository +-- that requires the following command line: +-- `hg clone ssh://example.com/foo` +-- you can use this in the rockspec: +-- source = { url = "hg+ssh://example.com/foo" } +return require "luarocks.fetch.hg_http" -- cgit v1.2.3-55-g6feb