开发者

Mercurial: warn when adding files which would otherwise be ignored?

开发者 https://www.devze.com 2022-12-18 14:20 出处:网络
How can ask Mercurial to warn me before I add files which would otherwise be ignored? For e开发者_开发百科xample, something like:

How can ask Mercurial to warn me before I add files which would otherwise be ignored?

For e开发者_开发百科xample, something like:

$ hg add foo.o
warning: adding ignored file foo.o

There seems to have been a patch submitted to the mailing list: https://www.mercurial-scm.org/pipermail/mercurial-devel/2008-February/004993.html

But I can't find any further references to it.


Use hg addremove. It will not add ignored files.
Extract from addremove documentation

New files are ignored if they match any of the patterns in .hgignore. As with add, these changes take effect at the next commit.


It's sort of a hacky workaround and only half what you want, but you could replace

$ hg add foo.o

with

$ hg add -I foo.o

That says "add everything but only if it's not ignored and it matches the pattern after -I".

An example:

$ ls -A
.hg  .hgignore  this
$ cat .hgignore 
this
$ hg stat --all
? .hgignore
I this
$ hg add -I this
$ hg stat --all
? .hgignore
I this

So you can see that "this" wasn't added and is still in ignored state. Of course, that's not a warning, it's a refusal.


This won't help much on add, but you could catch it during commit by using a pretxncommit hook.

0

精彩评论

暂无评论...
验证码 换一张
取 消