# HG changeset patch # User Takumi IINO # Date 1397653466 -32400 # Node ID 9c6f083eecad95ee124fa063fa174096126bdad2 # Parent 40c43c02f5b1276409a8e71d95e1671b4277e34f gignore: remove illegal components (issue92) mercurial can't ignore .hg direcotry. diff --git a/hggit/gitdirstate.py b/hggit/gitdirstate.py --- a/hggit/gitdirstate.py +++ b/hggit/gitdirstate.py @@ -39,6 +39,8 @@ if line.startswith('!'): warnings.append(_("unsupported ignore pattern '%s'") % line) continue + if re.match(r'(:?.*/)?\.hg(:?/|$)', line): + continue rootprefix = '%s/' % root if root else '' if line.startswith('/'): line = line[1:] diff --git a/tests/test-gitignore.t b/tests/test-gitignore.t --- a/tests/test-gitignore.t +++ b/tests/test-gitignore.t @@ -67,6 +67,44 @@ ? dir/.gitignore ? dir/bar + $ echo '.hg/' > .gitignore + $ hg status + ? .gitignore + ? bar + ? dir/.gitignore + ? dir/bar + ? foo + ? foobar + + $ echo 'dir/.hg/' > .gitignore + $ hg status + ? .gitignore + ? bar + ? dir/.gitignore + ? dir/bar + ? foo + ? foobar + + $ echo '.hg/foo' > .gitignore + $ hg status + ? .gitignore + ? bar + ? dir/.gitignore + ? dir/bar + ? foo + ? foobar + + $ touch foo.hg + $ echo 'foo.hg' > .gitignore + $ hg status + ? .gitignore + ? bar + ? dir/.gitignore + ? dir/bar + ? foo + ? foobar + $ rm foo.hg + $ touch .hgignore $ hg status ? .gitignore