monotone

monotone Mtn Source Tree

Root/contrib/monotone-cvs-ignore.lua

1function glob_to_pattern(glob)
2local pattern
3
4-- escape all special characters:
5pattern = string.gsub(glob, "([%^%$%(%)%%%.%[%]%*%+%-%?])", "%%%1")
6
7-- convert the glob's ones to pattern's:
8pattern = string.gsub(pattern, "%%%*", "[^/]*")
9pattern = string.gsub(pattern, "%%%?", ".")
10
11return pattern
12end
13
14function ignore_file(name)
15local dir, pat1, pat2
16
17dir = string.gsub(name, "/[^/]+$", "/")
18if (dir == name) then dir = "" end
19pat1 = "^" .. glob_to_pattern(dir)
20
21for line in io.lines(dir .. ".cvsignore") do
22pat2 = glob_to_pattern(line) .. "$"
23if (string.find(name, pat1 .. pat2)) then return true end
24end
25
26return false
27end

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status