如何让 Mercurial 忽略除 *.cs 文件之外的所有内容?

发布于 2024-08-03 05:58:52 字数 228 浏览 11 评论 0原文

我启动了一个项目并将其添加到 Mercurial 中。但我只想将 *.cs 文件置于版本控制下。所以我必须添加 binobjslnsuo_resharper 文件夹等忽略模式。

如何让Hg只监控白名单等特定类型的文件?如何在 Subversion 中做到这一点?

I started a project and added it to Mercurial. But I want to take *.cs file under version control only. So I have to add bin, obj, sln, suo, _resharper folder etc to ignore pattern.

How to let Hg only monitor certain kind of file like white list? How to do that in Subversion?

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

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

发布评论

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

评论(3

早茶月光 2024-08-10 05:58:52

只需在遇到扩展名时将其添加到您的 .hgignore 文件即可:

syntax: glob
*.bin
*.obj

等等。这并不是很多工作,并且它向世界其他地方准确记录了您认为对版本控制不重要的文件类型。

您甚至可以设置全局忽略文件,请参阅忽略[ui] 部分 中的 code> 条目。

尝试通过使用负向前瞻正则表达式和其他巫术来颠倒.hgignore(在我看来)不是一个好主意。它几乎肯定不会起作用,只会导致混乱。这是因为 hg 将给定路径名称的所有前缀与 .hgignore 中的规则。 类似的文件

a/b/c.cs

将被忽略

a/b/c.cs
a/b
a

因此,如果其中任何一个与 .hgignore 文件中的规则匹配,则 。特别是,这意味着您不能使用负先行表达式来不忽略 a/b/c.cs ——该规则将匹配 a/b 或 <代码>a。

Just add the extensions to your .hgignore file as you come across them:

syntax: glob
*.bin
*.obj

and so on. It's not a lot of work, and it documents to the rest of the world exactly what kind of files you consider unimportant for revision control.

You can even setup a global ignore file, please see the ignore entry in the [ui] section.

Trying to turn the .hgignore upside-down by using negative lookahead regular expressions and other voodoo is (in my opinion) not a good idea. It will almost surely not work and will only lead to confusion. This is because hg matches all prefixes of a give path name against the rules in .hgignore. So a file like

a/b/c.cs

will be ignored if any of

a/b/c.cs
a/b
a

is matched by a rule in your .hgignore file. In particular, this means that you cannot use a negative lookahead expression to have a/b/c.cs not-ignored -- the rule will match a/b or a.

愚人国度 2024-08-10 05:58:52

关于 Martin Geisler 提供的 Mercurial 问题的链接 (https://www.mercurial-scm。 org/bts/issue712),请注意,该问题不是技术难题,而是支持:

这是一个古老且反复出现的功能请求,我很好地拒绝了
在这个错误被创建之前。我写过并支持过几个
包含/排除文件语法并决定我宁愿说“不,你
不能这样做”的用户比例比“不,你读错了文档”的用户比例高出 1%
重复地向 20% 的用户询问。
—Matt Mackall(Mercurial 的开发者)

Regarding the link to a Mercurial issue supplied by Martin Geisler (https://www.mercurial-scm.org/bts/issue712), please note that the issue is not one of technical difficulty, but support:

This is an ancient and recurring feature request, which I turned down well
before this bug was created. I've written and supported a couple
include/exclude file syntaxes and have decided I would rather say "no, you
can't do that" once to 1% of users than "no, you're reading the docs wrong"
repeatedly to 20% of users.
—Matt Mackall (developer of Mercurial)

归途 2024-08-10 05:58:52

将包含这些内容的名为 .hgignore 的文件添加到您的存储库中。

syntax: regexp

^\.cs

Subversion 不允许您使用正则表达式来忽略文件,仅允许使用 的子集glob 语法 来匹配文件/目录名称。我不知道如何忽略不以 .cs 结尾的文件,因此我搜索了网络和 此网页 说:

svn propset svn:ignore "*[!c][!s]
*.cs?*" .

谨慎使用它:)

编辑:Martin Geisler 是对的,我错了,正则表达式语法是错误的。我道歉。正确的概念是存在的,但没有元字符......:(

Add a file named .hgignore to your repository with these contents.

syntax: regexp

^\.cs

Subversion doesn't let you use regex to ignore files, only a subset of glob syntax to match file/directory names. I had no idea how to make ignore files not ending in .cs so I searched the web and this webpage says:

svn propset svn:ignore "*[!c][!s]
*.cs?*" .

Use it with caution :)

Edit: Martin Geisler is right and I was mistaken, the regexp syntax is wrong. I apologize. The correct concept is there but not the metacharacters... :(

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