忽略 Mercurial 中的文件夹

发布于 2024-07-09 21:46:04 字数 692 浏览 11 评论 0原文

警告: 我尝试了此处列出的所有可能性: 我怎样才能忽略Mercurial 中文件夹下的所有内容
没有一个像我希望的那样工作。

我想忽略文件夹 test 下的所有内容。 但不忽略 srcProject\test\TestManager

我尝试

syntax: glob
test/**

它会忽略 testsrcProject\test\TestManager

与:

syntax: regexp
^/test/

这是同一件事。

另外:

syntax: regexp
test\\*

我已经在 Windows 中安装了 TortoiseHG 0.4rc2 和 Mercurial-626cb86a6523+tortoisehg、Python-2.5.1、PyGTK-2.10.6、GTK-2.10.11

Caveat:
I try all the posibilities listed here: How can I ignore everything under a folder in Mercurial.
None works as I hope.

I want to ignore every thing under the folder test. But not ignore srcProject\test\TestManager

I try

syntax: glob
test/**

And it ignores test and srcProject\test\TestManager

With:

syntax: regexp
^/test/

It's the same thing.

Also with:

syntax: regexp
test\\*

I have install TortoiseHG 0.4rc2 with Mercurial-626cb86a6523+tortoisehg, Python-2.5.1, PyGTK-2.10.6, GTK-2.10.11 in Windows

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

鸠魁 2024-07-16 21:46:04

在正则表达式版本中尝试在插入符号后不加斜杠。

^test/

这是一个测试:

~$ mkdir hg-folder-ignore
~$ cd hg-folder-ignore
~/hg-folder-ignore$ echo '^test/' > .hgignore
~/hg-folder-ignore$ hg init
~/hg-folder-ignore$ mkdir test
~/hg-folder-ignore$ touch test/ignoreme
~/hg-folder-ignore$ mkdir -p srcProject/test/TestManager
~/hg-folder-ignore$ touch srcProject/test/TestManager/dont-ignore
~/hg-folder-ignore$ hg stat
? .hgignore
? srcProject/test/TestManager/dont-ignore

请注意,ignoreme 没有显示,而 dont-ignore 则显示。

Try it without the slash after the caret in the regexp version.

^test/

Here's a test:

~$ mkdir hg-folder-ignore
~$ cd hg-folder-ignore
~/hg-folder-ignore$ echo '^test/' > .hgignore
~/hg-folder-ignore$ hg init
~/hg-folder-ignore$ mkdir test
~/hg-folder-ignore$ touch test/ignoreme
~/hg-folder-ignore$ mkdir -p srcProject/test/TestManager
~/hg-folder-ignore$ touch srcProject/test/TestManager/dont-ignore
~/hg-folder-ignore$ hg stat
? .hgignore
? srcProject/test/TestManager/dont-ignore

Notice that ignoreme isn't showing up and dont-ignore is.

鹊巢 2024-07-16 21:46:04

这两种情况都对我有用(在 Linux 和 Windows 上):

syntax: regexp
^backup/     #root folder
nbproject/   #any folder

或者

syntax: glob
./backup/*   #root folder
nbproject/*  #any folder

但是,在我将 .hgignore 文件的链接添加到我的存储库中的 .hgrc 文件之前:

[ui]
ignore = .hg/.hgignore

还值得一提的是,mercurial 会忽略它不是的文件当前正在跟踪,这是在您将其配置为忽略它们之前添加的。 因此,不要因为 hg status 说某些文件是 M(已修改)或 ! (丢失)在您刚刚添加到忽略列表的文件夹中!

Both cases worked for me (on linux and windows):

syntax: regexp
^backup/     #root folder
nbproject/   #any folder

or

syntax: glob
./backup/*   #root folder
nbproject/*  #any folder

However, it wasn't before I added a link to .hgignore file to .hgrc file in my repo:

[ui]
ignore = .hg/.hgignore

Also worth mentioning that mercurial ignores files that it is not currently tracking, which are those added before you configured it to ignore them. So, don't be put off by hg status saying some filed are M (modified) or ! (missing) in the folders that you have just added to the ignore list!

云淡月浅 2024-07-16 21:46:04

您可以使用零宽度负向前查找和向后查找断言来指定仅当 test 前面没有 srcProject 且后面没有 时才忽略它>TestManager

syntax: regexp
(?<!srcProject\\)test\\(?!TestManager)

Mercurial 使用 Python 正则表达式,因此您可以在 Python 文档中找到有关零宽度断言的更多信息:https://docs.python.org/library/re.html#regular-expression-syntax

You can use zero-width negative look-ahead and look-behind assertions to specify that you want to ignore test only when it's not preceded by srcProject and not followed by TestManager:

syntax: regexp
(?<!srcProject\\)test\\(?!TestManager)

Mercurial uses Python regular expressions, so you can find more info on zero-width assertions in the Python docs: https://docs.python.org/library/re.html#regular-expression-syntax

深海不蓝 2024-07-16 21:46:04

在存储库的根目录下创建 .hgignore 文件

现在在文件中添加以下内容。

语法:glob

bin/**

*.DS_Store

这将从存储库中删除 bin 目录和所有 *.DS_Store 文件

Create .hgignore file under root directory of the repository

Now add the following contents in the file .

syntax: glob

bin/**

*.DS_Store

This will remove the bin directory and all the *.DS_Store files from the repository

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