hg - Ignore directory at root only
Asked Answered
R

2

31

In my project's .hgignore, I want to exclude /static/ (i.e., the static folder at the root of the directory), but not /templates/static/. How would I configure .hgignore to allow this?

Rudman answered 29/1, 2012 at 5:36 Comment(4)
What have you tried? Have you tried something like syntax:regexp with ^/static/.*?Leontina
Can this be done with glob?Hadji
@buffer No. According to the manpage, a glob cannot be rooted. But you can switch between syntaxes within the .hgignore.Kenn
If you're using glob syntax by default in your .hgignore, you can use re:^static/ to ignore the static folder only in your repo root.Crucifixion
W
35

You can include syntax: regexp at the beginning of .hgignore and then use perl regex syntax to root a directory by using ^. So just ^static should do the work.

Wendolyn answered 29/1, 2012 at 5:58 Comment(2)
I would change that to ^static/, otherwise it will ignore all directories whose name starts with static, which may cause confusion down the road.Stirps
If your .hgignore is in glob syntax you can just put syntax: regexp and syntex: glob before and after the line ^static/. Apparently it's allowed to switch between syntaxes. See manpage: "The chosen syntax stays in effect when parsing all patterns that follow, until another syntax is selected."Kenn
N
2

As of Mercurial 4.9, you can use syntax: rootglob to insert rooted glob patterns.

New rootglob: filename pattern for a glob that is rooted at the root of the repository. See hg help patterns and hg help hgignore for details

Nursemaid answered 13/3, 2019 at 16:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.