class HgExcludeFilter extends BaseExcludeFilter (View source)

An exclude filter that processes hgignore files

Constants

HG_IGNORE_REGEX

HG_IGNORE_GLOB

Properties

protected string $sourcePath from BaseExcludeFilter
protected array $excludePatterns from BaseExcludeFilter
protected int $patternMode Either HG_IGNORE_REGEX or HG_IGNORE_GLOB

Methods

__construct(string $sourcePath)

Parses .hgignore file if it exist

bool
filter(string $relativePath, bool $exclude)

Checks the given path against all exclude patterns in this filter

array
parseLines(array $lines, callback $lineParser)

Processes a file containing exclude rules of different formats per line

array
generatePatterns(array $rules)

Generates a set of exclude patterns for filter() from gitignore rules

array
generatePattern(string $rule)

Generates an exclude pattern for filter() from a gitignore rule

array
parseHgIgnoreLine(string $line)

Callback line parser which process hgignore lines

array
patternFromGlob(string $line)

Generates an exclude pattern for filter() from a hg glob expression

array
patternFromRegex(string $line)

Generates an exclude pattern for filter() from a hg regexp expression

Details

__construct(string $sourcePath)

Parses .hgignore file if it exist

Parameters

string $sourcePath Directory containing sources to be filtered

bool filter(string $relativePath, bool $exclude)

Checks the given path against all exclude patterns in this filter

Negated patterns overwrite exclude decisions of previous filters.

Parameters

string $relativePath The file's path relative to the sourcePath
bool $exclude Whether a previous filter wants to exclude this file

Return Value

bool Whether the file should be excluded

protected array parseLines(array $lines, callback $lineParser)

Processes a file containing exclude rules of different formats per line

Parameters

array $lines A set of lines to be parsed
callback $lineParser The parser to be used on each line

Return Value

array Exclude patterns to be used in filter()

protected array generatePatterns(array $rules)

Generates a set of exclude patterns for filter() from gitignore rules

Parameters

array $rules A list of exclude rules in gitignore syntax

Return Value

array Exclude patterns

protected array generatePattern(string $rule)

Generates an exclude pattern for filter() from a gitignore rule

Parameters

string $rule An exclude rule in gitignore syntax

Return Value

array An exclude pattern

array parseHgIgnoreLine(string $line)

Callback line parser which process hgignore lines

Parameters

string $line A line from .hgignore

Return Value

array An exclude pattern for filter()

protected array patternFromGlob(string $line)

Generates an exclude pattern for filter() from a hg glob expression

Parameters

string $line A line from .hgignore in glob mode

Return Value

array An exclude pattern for filter()

array patternFromRegex(string $line)

Generates an exclude pattern for filter() from a hg regexp expression

Parameters

string $line A line from .hgignore in regexp mode

Return Value

array An exclude pattern for filter()