# HG changeset patch # User Phil Cohen # Date 1504204139 25200 # Node ID 65ae54582713af1f25bfa09c0c079f803923f4e4 # Parent fe04c018eaac15ea48f2611f3d07978ba1044126 merge: move some of the logic in batchget() to workingfilectx We will use this logic in two places with in-memory merge. Differential Revision: https://phab.mercurial-scm.org/D444 diff -r fe04c018eaac -r 65ae54582713 mercurial/context.py --- a/mercurial/context.py Thu Aug 31 11:28:59 2017 -0700 +++ b/mercurial/context.py Thu Aug 31 11:28:59 2017 -0700 @@ -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) diff -r fe04c018eaac -r 65ae54582713 mercurial/merge.py --- a/mercurial/merge.py Thu Aug 31 11:28:59 2017 -0700 +++ b/mercurial/merge.py Thu Aug 31 11:28:59 2017 -0700 @@ -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