[PATCH 7 of 8] ignore: add support for including subdir .hgignores

Martin Geisler martin at geisler.net
Fri May 15 05:22:38 CDT 2015


Durham Goode <durham at fb.com> writes:

> At the moment we only support globs in sub-ignore files. regexs will
> cause an exception. This is because we can't reliabily modify a regex
> to have a prefix (ex: adding a prefix to '^foo|^bar' would require
> parsing the regex).

That is surprising from a high-level since regular languages are closed
under concatenation.

However, I see what you're saying: blindly adding a prefix to a regex
doesn't do what you expect. I didn't look at the mechanics of the code,
but if you could strip off the path elements as you descend down the
directory tree, you should get the right behavior.

So if we have

  root/sub-dir/foo/
               bar/
               .hgignore <- '^foo|^bar'
               baz.txt
       .hgignore <- '#include sub-dir/.hgignore'

then don't match

  sub-dir/foo/
  sub-dir/bar/

against

  sub-dir/(^foo|^bar)

Instead match

  foo/
  bar/

against

  ^foo|^bar

to conclude the directories should be ignored.

Maybe that's not what you want if you intend to make one big regular
expression upfront and run all paths through that.

-- 
Martin Geisler

http://google.com/+MartinGeisler
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20150515/e93f19d9/attachment.pgp>


More information about the Mercurial-devel mailing list