Patchwork D444: merge: move some of the logic in batchget() to workingfilectx

login
register
mail settings
Submitter phabricator
Date Aug. 31, 2017, 9:23 p.m.
Message ID <56fe2620ef4ce77e301dc9008e010d5b@localhost.localdomain>
Download mbox | patch
Permalink /patch/23574/
State Not Applicable
Headers show

Comments

phabricator - Aug. 31, 2017, 9:23 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG65ae54582713: merge: move some of the logic in batchget() to workingfilectx (authored by phillco).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D444?vs=1478&id=1516#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D444?vs=1478&id=1516

REVISION DETAIL
  https://phab.mercurial-scm.org/D444

AFFECTED FILES
  mercurial/context.py
  mercurial/merge.py

CHANGE DETAILS




To: phillco, #hg-reviewers
Cc: martinvonz, mercurial-devel

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1150,9 +1150,7 @@ 
                 except OSError as e:
                     if e.errno != errno.ENOENT:
                         raise
-
-            if repo.wvfs.isdir(f) and not repo.wvfs.islink(f):
-                repo.wvfs.removedirs(f)
+            wctx[f].clearunknown()
             wctx[f].write(fctx(f).data(), flags, backgroundclose=True)
             if i == 100:
                 yield i, f
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1963,6 +1963,14 @@ 
         self._repo.wwrite(self._path, data, flags,
                           backgroundclose=backgroundclose)
 
+    def clearunknown(self):
+        """Removes conflicting items in the working directory so that
+        ``write()`` can be called successfully.
+        """
+        wvfs = self._repo.wvfs
+        if wvfs.isdir(self._path) and not wvfs.islink(self._path):
+            wvfs.removedirs(self._path)
+
     def setflags(self, l, x):
         self._repo.wvfs.setflags(self._path, l, x)