Differences between revisions 1 and 2
Revision 1 as of 2016-11-05 03:45:40
Size: 3203
Comment: copy paste of sprint notes, foozy's email, etc.
Revision 2 as of 2016-11-05 03:49:57
Size: 3261
Comment: add -I + fileset example
Deletions are marked like this. Additions are marked like this.
Line 60: Line 60:
 * not matched at "hg files glob:foo/bar"
 * but matched at "hg file -I glob:foo/bar"
 * not matched at: `hg files glob:foo/bar`
 * not matched at: `hg files -I 'set:
"glob:foo/bar"'`
 * but matched at: `hg files -I glob:foo/bar`

Note:

This page is primarily intended for developers of Mercurial.

Better Matcher API and File Patterns Plan

Status: Project

Main proponents: YourNameHere

/!\ This is a speculative project and does not represent any firm decisions on future behavior.

{X} Add a short summary of the idea here.

1. Goal

  • Short term: add non-recursive globs ?
  • Long term: extensible matcher API ?

2. Detailed description

2.1. Sprint Notes

Non-recursive globs (Rodrigo, spectral, Durham, :
    Issue is that * is sometimes recursive
    matcher API is a mess
    Should we re-write match.py or just add fileglob?
    Suggestion: add fileglob via a new, cleaner API, then migrate others over time
    Possible FB use case: pick parts of a tree to include and exclude (would add ordering dependency instead of excludes always trumping includes?)
    matcher API should be extensible
    matcher composition: anyof, allof, negate, per-file-type, etc.
    Inconsistencies in pattern behavior between hgignore, --include/--exclude, etc.
    FB: conversion between matchers and watchman expressions
    Proposal: wiki page, first group to have a use case proposes the initial API

2.2. Current Status

pattern type

root-ed

cwd-ed

any-of-path

wildcard

---

glob

relglob

regexp

re

---

relre

raw string

path

relpath

---

If rule is read in from file (e.g. .hgignore):

  • "glob" is treated as "relglob"
  • "re" is treated as "relre"

This is mentioned in "hg help patterns" and "hg help hgignore", but syntax name "relglob" and "relre" themselves aren't explained.

"end of name" matching is required:

  • for glob/relglob as PATTERN (e.g. argument in command line), but
  • not for glob/relglob as INCLUDES/EXCLUDES, or other pattern syntaxes

For example, file "foo/bar/baz" is:

  • not matched at: hg files glob:foo/bar

  • not matched at: hg files -I 'set:"glob:foo/bar"'

  • but matched at: hg files -I glob:foo/bar

This isn't mentioned in any help document :-<, and the latter seems to cause the issue mentioned in this patch series.

2.3. Proposal by foozy

How about introducing new systematic names like below to re-organize current complicated mapping between names and matching ? (and enable "end of name" matching by "-eon" suffix or so)

pattern type

root-ed

cwd-ed

any-of-path

wildcard

rootglob

cwdglob

anyglob

regexp

rootre

cwdre

anyre

raw string

rootpath

cwdpath

anypath

Of course, we should take care of backward compatibility of .hgignore or so (e.g. config knob to warn/abort for new syntax name in .hgignore).

2.4. Proposal by Rodrigo

Add rootglob: to get over the issue of -I/-X patterns.

https://patchwork.mercurial-scm.org/patch/17311/

3. Roadmap

{X}

4. See Also


CategoryDeveloper CategoryNewFeatures

FileNamePatternsPlan (last edited 2016-12-05 13:08:40 by YuyaNishihara)