Mercurial > public > mercurial-scm > hg-stable
diff mercurial/cmdutil.py @ 38497:da2a7d8354b2
unlinkpath: make empty directory removal optional (issue5901) (issue5826)
There are known cases where performing operations such as rebase from a
directory that is newly created can fail or at least lead to being in a
directory handle that no longer exists.
This is even reproducible by just doing something as simple as:
cd foo; hg rm *
The behavior is different if you use `hg addremove`, the directory is not
removed until we attempt to go back to the node after committing it:
cd foo; rm *; hg addremove; hg ci -m'bye foo'; hg co .^; hg co tip
Differential Revision: https://phab.mercurial-scm.org/D3859
author | Kyle Lippincott <spectral@google.com> |
---|---|
date | Thu, 28 Jun 2018 18:07:22 -0700 |
parents | 8459e8d2f729 |
children | b1bbff1dd99a |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Thu Jun 28 21:24:47 2018 +0530 +++ b/mercurial/cmdutil.py Thu Jun 28 18:07:22 2018 -0700 @@ -1242,7 +1242,8 @@ dryrun=dryrun, cwd=cwd) if rename and not dryrun: if not after and srcexists and not samefile: - repo.wvfs.unlinkpath(abssrc) + rmdir = repo.ui.configbool('experimental', 'removeemptydirs') + repo.wvfs.unlinkpath(abssrc, rmdir=rmdir) wctx.forget([abssrc]) # pat: ossep @@ -2269,7 +2270,9 @@ for f in list: if f in added: continue # we never unlink added files on remove - repo.wvfs.unlinkpath(f, ignoremissing=True) + rmdir = repo.ui.configbool('experimental', + 'removeemptydirs') + repo.wvfs.unlinkpath(f, ignoremissing=True, rmdir=rmdir) repo[None].forget(list) if warn: @@ -3029,7 +3032,8 @@ def doremove(f): try: - repo.wvfs.unlinkpath(f) + rmdir = repo.ui.configbool('experimental', 'removeemptydirs') + repo.wvfs.unlinkpath(f, rmdir=rmdir) except OSError: pass repo.dirstate.remove(f)