hgignore 多行正则表达式
我用谷歌搜索了一下,但没有找到关于该主题的任何建议。 .hgignore 中可以使用多行正则表达式吗? 我正在编写一个 magento 模块,并且不想在存储库中仅包含我的模块代码,因此我想出了这个正则表达式,但如果我必须将其写在一行中,那将会很混乱。
syntax: regexp
^(?!(
app/code/local/Mage/Myreviews/|
app/design/frontend/default/default/layout/myreviews\.xml|
app/design/frontend/default/default/template/myreviews/|
app/etc/modules/Mage_Myreviews\.xml|
skin/frontend/default/default/css/myreviews/|
skin/frontend/default/default/myreviews/|
js/myreviews/
)).*
I googled a bit, but didn't find any suggestions on that topic. Is multi line regex possible in .hgignore?
I'm writing a magento module, and wan't to include only my module code in repository, so I came up with this regex, but it would a be mess, if I had to write it in one line.
syntax: regexp
^(?!(
app/code/local/Mage/Myreviews/|
app/design/frontend/default/default/layout/myreviews\.xml|
app/design/frontend/default/default/template/myreviews/|
app/etc/modules/Mage_Myreviews\.xml|
skin/frontend/default/default/css/myreviews/|
skin/frontend/default/default/myreviews/|
js/myreviews/
)).*
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
至于您问题的规范答案,是否支持多行正则表达式?否。为了进行确认,请查看
mercurial
Python 包中ignore.py
中的ignorepats
函数,它会迭代一一归档。至于你应该做什么,@jk. 的答案很好(以及你提出的
glob: *
)。As for the canonical answer to your question, are multi-line regular expressions supported? No. For confirmation, take a look at the
ignorepats
function inignore.py
in themercurial
Python package—it iterates over the lines in the file one by one.As for what you should do instead, @jk.'s answer is good (and the
glob: *
that you've come up with).您可以将文件添加到存储库并让 Mercurial 跟踪它们,即使它们匹配忽略规则,因此通常执行此类操作的最佳方法是忽略太多,例如(对磁力模块一无所知,所以这可能是错误的)
,然后明确hg 添加您确实想要的文件。
正如 Joel 指出的那样,
hg add
的--include
和--exclude
选项在这些情况下也很有用,可以预先获取附加信息:
hg忘记
将撤消跟踪文件而不删除它You can add files to a repository and have mercurial track them even if they match an ignore rule, so usually the best way to do this sort of thing is to ignore a bit too much e.g. (don't know anything about magneto modules so this may be wrong)
and then explicitly hg add the files you do want.
As Joel points out
hg add
s--include
and--exclude
options are also useful in these scenariospre-emptive additional info:
hg forget
will undo tracking a file without deleting it