views:

68

answers:

2

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

For example, something like:

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

There seems to have been a patch submitted to the mailing list: http://www.selenic.com/pipermail/mercurial-devel/2008-February/004993.html

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

A: 

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

Blair Conrad
+1  A: 

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.

Ry4an
Dunno about the OP, but I liked this. It works pretty well when you want to do `hg add foobar*` and it adds foobar.py, foobar_test.py and the otherwise-ignored foobar.pyc (for example). With this trick it does the expected and ignores the pyc file.
rq