Patchwork context: skip path conflicts by default when clearing unknown file (issue5776)

login
register
mail settings
Submitter Matt Harbison
Date March 24, 2018, 5:25 p.m.
Message ID <7624b67b6d7512f283e9.1521912314@Envy>
Download mbox | patch
Permalink /patch/29818/
State Accepted
Headers show

Comments

Matt Harbison - March 24, 2018, 5:25 p.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1521869450 14400
#      Sat Mar 24 01:30:50 2018 -0400
# Node ID 7624b67b6d7512f283e9e589f5c36fe3e7e4bb16
# Parent  a61fff493d9888935a1ff5e48bb823499f47e832
context: skip path conflicts by default when clearing unknown file (issue5776)

Prior to adding path conflict checking in 989e884d1be9, the test-audit-path.t
tests failed as shown here (but it was globbed away).  989e884d1be9 made it fail
with a message about the destination manifest containing a conflict (though the
no-symlink case wasn't updated).  When the path conflict checking was gated
behind an experimental config in 2a774cae3a03^::2a774cae3a03, the update started
erroneously succeeding here.  It turns out that the child of 989e884d1be9 is the
origin of this change when path conflict checking is disabled, as shown by
grafting the experimental config range on top of it.

What's happening here is merge.batchget() is writing the symlink 'back' to wdir
(but as a regular file for the no-symlink case), and then tries to write
'back/test', but calls wctx['back/test'].clearunknown() first.  The code that's
gated here was removing the newly written 'back' file, allowing 'back/test' to
succeed.  I tried checking for the dir components of 'back/test' in dirstate,
and skipping removal if present.  But that didn't work because the dirstate
isn't updated after each file is written out.

This is the last persistent test failure on Windows, so the testbot should start
turning green now. \o/
Augie Fackler - March 24, 2018, 6:06 p.m.
On Sat, Mar 24, 2018 at 01:25:14PM -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1521869450 14400
> #      Sat Mar 24 01:30:50 2018 -0400
> # Node ID 7624b67b6d7512f283e9e589f5c36fe3e7e4bb16
> # Parent  a61fff493d9888935a1ff5e48bb823499f47e832
> context: skip path conflicts by default when clearing unknown file (issue5776)

queued, thanks

Many many thanks for continuing this work on Windows. I'm excited to
have that buildbot green!

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1808,10 +1808,11 @@  class workingfilectx(committablefilectx)
         wvfs.audit(f)
         if wvfs.isdir(f) and not wvfs.islink(f):
             wvfs.rmtree(f, forcibly=True)
-        for p in reversed(list(util.finddirs(f))):
-            if wvfs.isfileorlink(p):
-                wvfs.unlink(p)
-                break
+        if self._repo.ui.configbool('experimental', 'merge.checkpathconflicts'):
+            for p in reversed(list(util.finddirs(f))):
+                if wvfs.isfileorlink(p):
+                    wvfs.unlink(p)
+                    break
 
     def setflags(self, l, x):
         self._repo.wvfs.setflags(self._path, l, x)
diff --git a/tests/test-audit-path.t b/tests/test-audit-path.t
--- a/tests/test-audit-path.t
+++ b/tests/test-audit-path.t
@@ -109,8 +109,7 @@  attack back/test where back symlinks to 
 #else
 ('back' will be a file and cause some other system specific error)
   $ hg update -Cr2
-  back: is both a file and a directory
-  abort: * (glob)
+  abort: $TESTTMP/target/back/test: $ENOTDIR$
   [255]
 #endif