hgignore 多行正则表达式

发布于 2024-12-02 14:53:06 字数 492 浏览 2 评论 0原文

我用谷歌搜索了一下,但没有找到关于该主题的任何建议。 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

最冷一天 2024-12-09 14:53:06

至于您问题的规范答案,是否支持多行正则表达式?否。为了进行确认,请查看 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 in ignore.py in the mercurial 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).

半窗疏影 2024-12-09 14:53:06

您可以将文件添加到存储库并让 Mercurial 跟踪它们,即使它们匹配忽略规则,因此通常执行此类操作的最佳方法是忽略太多,例如(对磁力模块一无所知,所以这可能是错误的)

syntax: glob
app/*
skin/*
js/myreviews/*

,然后明确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)

syntax: glob
app/*
skin/*
js/myreviews/*

and then explicitly hg add the files you do want.

As Joel points out hg adds --include and --exclude options are also useful in these scenarios

pre-emptive additional info: hg forget will undo tracking a file without deleting it

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文