changeset 718:9c6f083eecad

gignore: remove illegal components (issue92) mercurial can't ignore .hg direcotry.
author Takumi IINO <trot.thunder@gmail.com>
date Wed, 16 Apr 2014 22:04:26 +0900
parents 40c43c02f5b1
children 3a045277a434
files hggit/gitdirstate.py tests/test-gitignore.t
diffstat 2 files changed, 40 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/gitdirstate.py	Thu May 08 20:18:06 2014 -0700
+++ b/hggit/gitdirstate.py	Wed Apr 16 22:04:26 2014 +0900
@@ -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:]
--- a/tests/test-gitignore.t	Thu May 08 20:18:06 2014 -0700
+++ b/tests/test-gitignore.t	Wed Apr 16 22:04:26 2014 +0900
@@ -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