Patchwork add: use lexists so that broken symbolic links are added

login
register
mail settings
Submitter John Coomes
Date Dec. 3, 2014, 11:38 p.m.
Message ID <054c810ef533f3cc0473.1417649911@mykonos.us.oracle.com>
Download mbox | patch
Permalink /patch/6987/
State Accepted
Commit afa3fbbcabd3a4ac4000f06fe108b4e200dfc229
Headers show

Comments

John Coomes - Dec. 3, 2014, 11:38 p.m.
# HG changeset patch
# User John Coomes <john.coomes@oracle.com>
# Date 1417646009 28800
#      Wed Dec 03 14:33:29 2014 -0800
# Node ID 054c810ef533f3cc04736058338ce36e06be13fc
# Parent  756376ec6c128b42239d3726f73cd7a47446d1af
add: use lexists so that broken symbolic links are added

This restores the add behavior prior to d8cdd46f426d and matches the
behavior of addremove.
Matt Mackall - Dec. 4, 2014, 1:01 a.m.
On Wed, 2014-12-03 at 15:38 -0800, John Coomes wrote:
> # HG changeset patch
> # User John Coomes <john.coomes@oracle.com>
> # Date 1417646009 28800
> #      Wed Dec 03 14:33:29 2014 -0800
> # Node ID 054c810ef533f3cc04736058338ce36e06be13fc
> # Parent  756376ec6c128b42239d3726f73cd7a47446d1af
> add: use lexists so that broken symbolic links are added
> 
> This restores the add behavior prior to d8cdd46f426d and matches the
> behavior of addremove.

Nice, queued for default.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1984,7 +1984,7 @@ 
         cca = scmutil.casecollisionauditor(ui, abort, repo.dirstate)
     for f in wctx.walk(match):
         exact = match.exact(f)
-        if exact or not explicitonly and f not in wctx and repo.wvfs.exists(f):
+        if exact or not explicitonly and f not in wctx and repo.wvfs.lexists(f):
             if cca:
                 cca(f)
             names.append(f)
diff --git a/tests/test-symlinks.t b/tests/test-symlinks.t
--- a/tests/test-symlinks.t
+++ b/tests/test-symlinks.t
@@ -3,12 +3,18 @@ 
 == tests added in 0.7 ==
 
   $ hg init test-symlinks-0.7; cd test-symlinks-0.7;
-  $ touch foo; ln -s foo bar;
+  $ touch foo; ln -s foo bar; ln -s nonexistent baz
 
-import with addremove -- symlink walking should _not_ screwup.
+import with add and addremove -- symlink walking should _not_ screwup.
 
+  $ hg add
+  adding bar
+  adding baz
+  adding foo
+  $ hg forget bar baz foo
   $ hg addremove
   adding bar
+  adding baz
   adding foo
 
 commit -- the symlink should _not_ appear added to dir state