English 中文(简体)
Mer 否所有档案,只有一或多份档案材料除外?
原标题:Ignore all files except one or more files from a specific file type in Mercurial?

Identical question to gitignore: Ignore all files in folder hierarchy except one specific filetype, but for Mercurial.

I want .hgignore to ignore all files except one or more files from a specific file type, for instance only allow files of the *.java and *.class file type to be tracked, in the current directory as well as sub directories.

For example, in the following directory:

A.java
a.txt
a.png
A.class
B/C.java
B/G/H/h.png
B/C.class
D/E/F.java

I only want the following files to be included (including the structure of the directories):

A.java
A.class
B/C.java
B/C.class
D/E/F.java

(如果含有<代码>h.png<>/code>的目录将制作或不再制作,则无关紧要。)

I ve tried applying and changing the same principles as mentioned in the question above (but for Mercurial instead), as well as trying to apply principles from the question How can I ignore all directories except one using .hgignore?, without any luck.

EDIT:我用上述树种尝试如下:

$ hg stat
? A.class
? A.java
? B/C.class
? B/C.java
? B/G/H/h.png
? D/E/F.java
? a.png
? a.txt
$ hg add -I "**.{class, java}"
adding A.class
adding A.java
adding B/C.class
adding B/C.java
adding D/E/F.java

which gave me the wanted result. How do I create a .hgignore or config file that applies the -I "**.{class, java}" for each add or commit (and similar queries)?

问题回答

为此:

syntax: regexp
.*.(?!java$|class$)

或更好:

syntax: regexp
.*.(?!java$|.*.java$|class$|.*.class$)

这还将与“a.java”或“a.java.java”等杂草相匹配。

EDIT:此处是包含Søren s tips和我方面进一步 t弄的经修订的解决办法。 我希望,诸如“java”或“java”等假 positive现在就被搁置起来。

syntax: regexp
.(?!java$|class$)[^.]+$
(?<!.)java$
(?<!.)class$

If ignored patterns are countable, why not use list of glob patterns? In your case for ignoring everywhere in repo-tree all *.class and *.java (if I understand task correctly) .hgrc will be

syntax: glob

**.class
**.java

如果你想要忽略所有延期(或根本不可能知道)的档案,那么,除非你能够尝试在档案中使用档案(<编码>hg 求助文档<>。 除*.png外,所有延期都将是th。 如同(图瓦卢)一样。

"set:not **.png"




相关问题
Can I clone part of a Mercurial repository?

Is it possible to clone part of a Mercurial repository? Let s say the repository is quite large, or contains multiple projects, or multiple branches. Can I clone only part of the repository? E.g. in ...

Sync files in Two Different Repos using HG

I ve got a problem when I try to sync files in two different repos. What I want to do is: I ve got 2 repos A and B, and they share some common files, suppose they lie in A/docs/common/ and B/docs/...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

git for mercurial like git-svn

Hello is there a tool for git that allow to work with mercurial repositories F.e. for svn there is a git-svn package, that allows to clone/commit/update from svn and work in a git way.. So is there ...

Useful Mercurial Hooks [closed]

What are some useful Mercurial hooks that you have come across? A few example hooks are located in the Mercurial book: acl bugzilla notify check for whitespace I personally don t find these very ...

热门标签