diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -1146,7 +1146,7 @@ class queue(object): for f in all_files: if f not in repo.dirstate: try: - util.unlink(repo.wjoin(f)) + util.unlinkpath(repo.wjoin(f)) except OSError, inst: if inst.errno != errno.ENOENT: raise @@ -1240,7 +1240,7 @@ class queue(object): raise util.Abort(_("deletions found between repo revs")) for f in a: try: - util.unlink(repo.wjoin(f)) + util.unlinkpath(repo.wjoin(f)) except OSError, e: if e.errno != errno.ENOENT: raise diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -215,7 +215,7 @@ def rebase(ui, repo, **opts): clearstatus(repo) ui.note(_("rebase completed\n")) if os.path.exists(repo.sjoin('undo')): - util.unlink(repo.sjoin('undo')) + util.unlinkpath(repo.sjoin('undo')) if skipped: ui.note(_("%d revisions have been skipped\n") % len(skipped)) finally: @@ -393,7 +393,7 @@ def storestatus(repo, originalwd, target def clearstatus(repo): 'Remove the status files' if os.path.exists(repo.join("rebasestate")): - util.unlink(repo.join("rebasestate")) + util.unlinkpath(repo.join("rebasestate")) def restorestatus(repo): 'Restore a previously stored status' diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -3250,7 +3250,7 @@ def revert(ui, repo, *pats, **opts): continue audit_path(f) try: - util.unlink(repo.wjoin(f)) + util.unlinkpath(repo.wjoin(f)) except OSError: pass repo.dirstate.remove(f) diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -829,7 +829,7 @@ class workingctx(changectx): if unlink: for f in list: try: - util.unlink(self._repo.wjoin(f)) + util.unlinkpath(self._repo.wjoin(f)) except OSError, inst: if inst.errno != errno.ENOENT: raise diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -312,7 +312,7 @@ def applyupdates(repo, action, wctx, mct if f == '.hgsubstate': # subrepo states need updating subrepo.submerge(repo, wctx, mctx, wctx) try: - util.unlink(repo.wjoin(f)) + util.unlinkpath(repo.wjoin(f)) except OSError, inst: if inst.errno != errno.ENOENT: repo.ui.warn(_("update failed to remove %s: %s!\n") % @@ -350,7 +350,7 @@ def applyupdates(repo, action, wctx, mct repo.ui.note(_("moving %s to %s\n") % (f, fd)) t = wctx.filectx(f).data() repo.wwrite(fd, t, flags) - util.unlink(repo.wjoin(f)) + util.unlinkpath(repo.wjoin(f)) if f2: repo.ui.note(_("getting %s to %s\n") % (f2, fd)) t = mctx.filectx(f2).data() diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -431,7 +431,7 @@ def checksignature(func): return check -def unlink(f): +def unlinkpath(f): """unlink and remove the directory if it is empty""" os.unlink(f) # try removing directories that might now be empty diff --git a/mercurial/windows.py b/mercurial/windows.py --- a/mercurial/windows.py +++ b/mercurial/windows.py @@ -276,7 +276,7 @@ def _removedirs(name): break head, tail = os.path.split(head) -def unlink(f): +def unlinkpath(f): """unlink and remove the directory if it is empty""" os.unlink(f) # try removing directories that might now be empty