dirstate.status: avoid putting ignored files in the unknown list
authorAlexis S. L. Carvalho <alexis@cecm.usp.br>
Fri, 08 Feb 2008 18:07:55 -0200
changeset 6033 a1ebd5cd7e55
parent 6032 b41f0d6a74fc
child 6034 83633602e2c5
dirstate.status: avoid putting ignored files in the unknown list If list_ignored was false, we would blindly add files not in the dirstate to the unknown list. This should finish fixing issue886.
mercurial/dirstate.py
tests/test-revert.out
tests/test-status
tests/test-status.out
--- a/mercurial/dirstate.py	Fri Feb 08 18:07:55 2008 -0200
+++ b/mercurial/dirstate.py	Fri Feb 08 18:07:55 2008 -0200
@@ -530,6 +530,7 @@
         lookup, modified, added, unknown, ignored = [], [], [], [], []
         removed, deleted, clean = [], [], []
 
+        files = files or []
         _join = self._join
         lstat = os.lstat
         cmap = self._copymap
@@ -547,8 +548,9 @@
             if fn in dmap:
                 type_, mode, size, time, foo = dmap[fn]
             else:
-                if list_ignored and self._ignore(fn):
-                    iadd(fn)
+                if (list_ignored or fn in files) and self._dirignore(fn):
+                    if list_ignored:
+                        iadd(fn)
                 else:
                     uadd(fn)
                 continue
--- a/tests/test-revert.out	Fri Feb 08 18:07:55 2008 -0200
+++ b/tests/test-revert.out	Fri Feb 08 18:07:55 2008 -0200
@@ -71,9 +71,9 @@
 % reverting a rename target should revert the source
 ? newa
 %% 4 ignored files (we will add/commit everything)
-? ignoreddir/file
-? ignoreddir/removed
 I ignored
+I ignoreddir/file
+I ignoreddir/removed
 I removed
 %% should revert ignored* and undelete *removed
 reverting ignored
--- a/tests/test-status	Fri Feb 08 18:07:55 2008 -0200
+++ b/tests/test-status	Fri Feb 08 18:07:55 2008 -0200
@@ -21,7 +21,7 @@
 hg init repo2
 cd repo2
 touch modified removed deleted ignored
-echo "ignored" > .hgignore
+echo "^ignored$" > .hgignore
 hg ci -A -m 'initial checkin' -d "1000000 0"
 sleep 1 # make sure mtime is changed
 touch modified added unknown ignored
@@ -37,3 +37,10 @@
 hg status -C
 echo "hg status -A:"
 hg status -A
+echo "^ignoreddir$" > .hgignore
+mkdir ignoreddir
+touch ignoreddir/file
+echo "hg status ignoreddir/file:"
+hg status ignoreddir/file
+echo "hg status -i ignoreddir/file:"
+hg status -i ignoreddir/file
--- a/tests/test-status.out	Fri Feb 08 18:07:55 2008 -0200
+++ b/tests/test-status.out	Fri Feb 08 18:07:55 2008 -0200
@@ -99,7 +99,6 @@
 A added
 R removed
 ! deleted
-? ignored
 ? unknown
 hg status -C:
 A added
@@ -118,3 +117,6 @@
 I ignored
 C .hgignore
 C modified
+hg status ignoreddir/file:
+hg status -i ignoreddir/file:
+I ignoreddir/file