Patchwork [STABLE] hgignore: fix regression with hgignore directory matches (issue3921)

login
register
mail settings
Submitter Durham Goode
Date May 3, 2013, 5:06 p.m.
Message ID <2b4403fdfd3d451b4eba.1367600803@dev350.prn1.facebook.com>
Download mbox | patch
Permalink /patch/1541/
State Accepted
Commit f4930b533d55ad4b8910785c6b166f8a798d01bc
Headers show

Comments

Durham Goode - May 3, 2013, 5:06 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1367599490 25200
#      Fri May 03 09:44:50 2013 -0700
# Branch stable
# Node ID 2b4403fdfd3d451b4eba347e123ae3467adece42
# Parent  a6542a670ece8e13ae7b32ef28e2816d63120524
hgignore: fix regression with hgignore directory matches (issue3921)

If a directory matched a regex in hgignore but the files inside the directory
did not match the regex, they would appear as deleted in hg status. This
change fixes them to appear normally in hg status.

Removing the ignore(nf) conditional here is ok because it just means we might
stat more files than we had before. My testing on a large repo shows this
causes no performance regression since the only additional files being stat'd
are the ones that are missing (i.e. status=!), which are generally rare.
Matt Mackall - May 3, 2013, 5:40 p.m.
On Fri, 2013-05-03 at 10:06 -0700, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1367599490 25200
> #      Fri May 03 09:44:50 2013 -0700
> # Branch stable
> # Node ID 2b4403fdfd3d451b4eba347e123ae3467adece42
> # Parent  a6542a670ece8e13ae7b32ef28e2816d63120524
> hgignore: fix regression with hgignore directory matches (issue3921)

Queued for stable, thanks for the prompt fix!

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -700,7 +700,7 @@ 
                 for nf in iter(visit):
                     # Report ignored items in the dmap as long as they are not
                     # under a symlink directory.
-                    if ignore(nf) and audit_path.check(nf):
+                    if audit_path.check(nf):
                         try:
                             results[nf] = lstat(join(nf))
                         except OSError:
diff --git a/tests/test-hgignore.t b/tests/test-hgignore.t
--- a/tests/test-hgignore.t
+++ b/tests/test-hgignore.t
@@ -124,3 +124,13 @@ 
   (?:(?:|.*/)[^/]*(?:/|$))
 
   $ cd ..
+
+Check patterns that match only the directory
+
+  $ echo "^dir\$" > .hgignore
+  $ hg status
+  A dir/b.o
+  ? .hgignore
+  ? a.c
+  ? a.o
+  ? syntax