Skip to content

Commit c47c146

Browse files
committed
Add script to split HG patch sets.
1 parent 880e66d commit c47c146

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

tools/hg_import_split.lua

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
local patch = arg[1]
3+
if not patch then
4+
print("run:", arg[0] .. "<hg_patch_set>")
5+
return
6+
end
7+
8+
local prefix, ext = patch:match("^(.*)%.(.*)$")
9+
10+
print("split HG patch set:", prefix .. '.' .. ext)
11+
12+
local input = io.open(patch, "rb")
13+
14+
local part = 0
15+
local output
16+
17+
local function append_line(line)
18+
if output then
19+
output:write(line, '\n')
20+
end
21+
end
22+
23+
local function open_next_output()
24+
if output then
25+
-- close previous patch.
26+
output:close()
27+
output = nil
28+
end
29+
part = part + 1
30+
local name = string.format("%s_%d.%s", prefix, part, ext)
31+
print("Start patch file:", name)
32+
output = io.open(name, "w+b")
33+
end
34+
35+
for line in input:lines() do
36+
if line == "# HG changeset patch" then
37+
open_next_output()
38+
end
39+
append_line(line)
40+
end
41+
42+
if output then
43+
output:close()
44+
end
45+

0 commit comments

Comments
 (0)