I googl开发者_运维知识库ed 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/
)).*
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).
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 add
s --include
and --exclude
options are also useful in these scenarios
pre-emptive additional info: hg forget
will undo tracking a file without deleting it
精彩评论