问题描述
我的.hgignore
文件中包含以下内容:
I have the following in my .hgignore
file:
syntax: glob
obj/*
bin/*
*.suo
*.user
*.ncb
如果我注释掉*.
过滤器,则过滤器可以很好地过滤掉bin
和obj
文件夹中的文件,但是,如果我将这些过滤器保留在其中,则会收到以下错误:
If I comment out the *.
filters, the filtering works fine filtering out the files in the bin
and obj
folder, however, if I keep those filters in I receive the following error:
abort: c:\temp\.hgignore: invalid pattern (relre): *.suo
注意:文件采用UTF-8编码
Note: The file is encoded in UTF-8
推荐答案
Mercurial的错误消息告诉我们Mercurial不会读取您的syntax: glob
行.忽略文件中的模式默认为正则表达式,而*.suo
确实是无效的正则表达式(正则表达式不能以*
开头).
The error message from Mercurial tells us that your syntax: glob
line is not read by Mercurial. Patterns in ignore files default to regular expressions, and *.suo
is indeed an invalid regular expression (a regex cannot start with *
).
因为这是在Windows上,并且由于文件是UTF-8编码的,所以唯一合理的解释是,某些东西使Mercurial忽略了syntax: glob
行. UTF-8 BOM 就是这样的东西!字节顺序标记是插入到UTF-16编码文件中的一个小签名,用于指示文件的字节顺序.对于UTF-8编码的文件,不需要或不建议这样做,但是Windows编辑器总是倾向于插入它们.
Since this is on Windows, and since the file is UTF-8 encoded, then the only reasonable explanation is that there is somehthing that makes Mercurial ignore the syntax: glob
line. An UTF-8 BOM is such a "something"! A byte order mark is a small signature inserted into UTF-16 encoded files to signal the byte order of the file. This is not needed or recommended for UTF-8 encoded files, but Windows editors have a tendency to insert them anyway.
要解决此问题,请在记事本中打开文件,然后选择另存为".然后选择ANSI作为编码.您的.hgignore
文件是纯ASCII码,因此与没有BOM的UTF-8相同.
To fix this, please open the file in Notepad and choose "Save As". Then pick ANSI as the encoding. Your .hgignore
file is pure ASCII, so this will effective be the same as UTF-8 without a BOM.
这篇关于Mercurial给出“无效模式".简单的GLOB语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!