comparison mercurial/patch.py @ 38493: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 7b12a2d2eedc
children c88d2c9b00dd
comparison
equal deleted inserted replaced
38492:2394cd58b81f 38493:da2a7d8354b2
495 self.opener.write(fname, data) 495 self.opener.write(fname, data)
496 if isexec: 496 if isexec:
497 self.opener.setflags(fname, False, True) 497 self.opener.setflags(fname, False, True)
498 498
499 def unlink(self, fname): 499 def unlink(self, fname):
500 self.opener.unlinkpath(fname, ignoremissing=True) 500 rmdir = self.ui.configbool('experimental', 'removeemptydirs')
501 self.opener.unlinkpath(fname, ignoremissing=True, rmdir=rmdir)
501 502
502 def writerej(self, fname, failed, total, lines): 503 def writerej(self, fname, failed, total, lines):
503 fname = fname + ".rej" 504 fname = fname + ".rej"
504 self.ui.warn( 505 self.ui.warn(
505 _("%d out of %d hunks FAILED -- saving rejects to file %s\n") % 506 _("%d out of %d hunks FAILED -- saving rejects to file %s\n") %