aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/luarocks/fetch/hg.tl (renamed from src/luarocks/fetch/hg.lua)19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/luarocks/fetch/hg.lua b/src/luarocks/fetch/hg.tl
index 0ef0f5e4..3f94cee1 100644
--- a/src/luarocks/fetch/hg.lua
+++ b/src/luarocks/fetch/hg.tl
@@ -1,13 +1,14 @@
1 1
2--- Fetch back-end for retrieving sources from HG. 2--- Fetch back-end for retrieving sources from HG.
3local hg = {} 3local record hg
4 4end
5local unpack = unpack or table.unpack
6 5
7local fs = require("luarocks.fs") 6local fs = require("luarocks.fs")
8local dir = require("luarocks.dir") 7local dir = require("luarocks.dir")
9local util = require("luarocks.util") 8local util = require("luarocks.util")
10 9
10local type Rockspec = require("luarocks.core.types.rockspec").Rockspec
11
11--- Download sources for building a rock, using hg. 12--- Download sources for building a rock, using hg.
12-- @param rockspec table: The rockspec table 13-- @param rockspec table: The rockspec table
13-- @param extract boolean: Unused in this module (required for API purposes.) 14-- @param extract boolean: Unused in this module (required for API purposes.)
@@ -15,13 +16,11 @@ local util = require("luarocks.util")
15-- @return (string, string) or (nil, string): The absolute pathname of 16-- @return (string, string) or (nil, string): The absolute pathname of
16-- the fetched source tarball and the temporary directory created to 17-- the fetched source tarball and the temporary directory created to
17-- store it; or nil and an error message. 18-- store it; or nil and an error message.
18function hg.get_sources(rockspec, extract, dest_dir) 19function hg.get_sources(rockspec: Rockspec, extract: boolean, dest_dir?: string): string, string
19 assert(rockspec:type() == "rockspec")
20 assert(type(dest_dir) == "string" or not dest_dir)
21 20
22 local hg_cmd = rockspec.variables.HG 21 local hg_cmd = rockspec.variables.HG
23 local ok, err_msg = fs.is_tool_available(hg_cmd, "Mercurial") 22 local ok_available, err_msg = fs.is_tool_available(hg_cmd, "Mercurial")
24 if not ok then 23 if not ok_available then
25 return nil, err_msg 24 return nil, err_msg
26 end 25 end
27 26
@@ -36,7 +35,7 @@ function hg.get_sources(rockspec, extract, dest_dir)
36 if tag_or_branch then 35 if tag_or_branch then
37 command = {hg_cmd, "clone", "--rev", tag_or_branch, url, module} 36 command = {hg_cmd, "clone", "--rev", tag_or_branch, url, module}
38 end 37 end
39 local store_dir 38 local store_dir: string
40 if not dest_dir then 39 if not dest_dir then
41 store_dir = fs.make_temp_dir(name_version) 40 store_dir = fs.make_temp_dir(name_version)
42 if not store_dir then 41 if not store_dir then
@@ -48,7 +47,7 @@ function hg.get_sources(rockspec, extract, dest_dir)
48 end 47 end
49 local ok, err = fs.change_dir(store_dir) 48 local ok, err = fs.change_dir(store_dir)
50 if not ok then return nil, err end 49 if not ok then return nil, err end
51 if not fs.execute(unpack(command)) then 50 if not fs.execute(table.unpack(command)) then
52 return nil, "Failed cloning hg repository." 51 return nil, "Failed cloning hg repository."
53 end 52 end
54 ok, err = fs.change_dir(module) 53 ok, err = fs.change_dir(module)