diff -r 2394cd58b81f -r da2a7d8354b2 mercurial/cmdutil.py --- 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)