This is an archive of the discontinued Mercurial Phabricator instance.

unlinkpath: make empty directory removal optional (issue5901) (issue5826)
ClosedPublic

Authored by spectral on Jun 28 2018, 9:10 PM.

Details

Summary

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

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

spectral created this revision.Jun 28 2018, 9:10 PM
spectral updated this revision to Diff 9351.Jun 28 2018, 9:38 PM
spectral added inline comments.Jun 28 2018, 9:44 PM
tests/test-removeemptydirs.t
126

I'm rather uncertain about this, but there's no generic 'linux' in hghave at the moment; I'm testing on my mac now.

spectral marked an inline comment as done.Jun 28 2018, 9:54 PM

(Tests pass on my mac as well)

yuja added a subscriber: yuja.Jun 29 2018, 8:30 AM

Queued, thanks.

+ $ NO_RM=--config=experimental.removeemptydirs=0
+ $ isdir() { if [[ -d $1 ]]; then echo yes; else echo no; fi }
+ $ isfile() { if [[ -f $1 ]]; then echo yes; else echo no; fi }

changed to [ ... ] since [[ ... ]] requires bash.

This revision was automatically updated to reflect the committed changes.
av6 added a subscriber: av6.Jun 29 2018, 11:53 AM
av6 added inline comments.
mercurial/configitems.py
569

Not a huge deal for experimental options, but be aware of https://www.mercurial-scm.org/wiki/UIGuideline#naming_config_options (which recommends remove-empty-dirs).