--- a/hgext/mq.py Wed Jan 05 15:56:03 2011 +0100
+++ b/hgext/mq.py Sun Jan 02 19:34:41 2011 +0100
@@ -1146,7 +1146,7 @@
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 @@
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
--- a/hgext/rebase.py Wed Jan 05 15:56:03 2011 +0100
+++ b/hgext/rebase.py Sun Jan 02 19:34:41 2011 +0100
@@ -215,7 +215,7 @@
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 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'
--- a/mercurial/commands.py Wed Jan 05 15:56:03 2011 +0100
+++ b/mercurial/commands.py Sun Jan 02 19:34:41 2011 +0100
@@ -3250,7 +3250,7 @@
continue
audit_path(f)
try:
- util.unlink(repo.wjoin(f))
+ util.unlinkpath(repo.wjoin(f))
except OSError:
pass
repo.dirstate.remove(f)
--- a/mercurial/context.py Wed Jan 05 15:56:03 2011 +0100
+++ b/mercurial/context.py Sun Jan 02 19:34:41 2011 +0100
@@ -829,7 +829,7 @@
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
--- a/mercurial/merge.py Wed Jan 05 15:56:03 2011 +0100
+++ b/mercurial/merge.py Sun Jan 02 19:34:41 2011 +0100
@@ -312,7 +312,7 @@
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 @@
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()
--- a/mercurial/util.py Wed Jan 05 15:56:03 2011 +0100
+++ b/mercurial/util.py Sun Jan 02 19:34:41 2011 +0100
@@ -431,7 +431,7 @@
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
--- a/mercurial/windows.py Wed Jan 05 15:56:03 2011 +0100
+++ b/mercurial/windows.py Sun Jan 02 19:34:41 2011 +0100
@@ -276,7 +276,7 @@
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