changeset 18386:03442135dff4

refactoring: use unlinkpath with ignoremissing
author Mads Kiilerich <madski@unity3d.com>
date Tue, 15 Jan 2013 23:30:10 +0100
parents bafbfe0b450c
children 39616410aa32
files hgext/largefiles/overrides.py hgext/rebase.py mercurial/commands.py
diffstat 3 files changed, 5 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py	Tue Jan 15 23:30:10 2013 +0100
+++ b/hgext/largefiles/overrides.py	Tue Jan 15 23:30:10 2013 +0100
@@ -170,8 +170,7 @@
                 # are removing the file.
                 if getattr(repo, "_isaddremove", False):
                     ui.status(_('removing %s\n') % f)
-                if os.path.exists(repo.wjoin(f)):
-                    util.unlinkpath(repo.wjoin(f))
+                util.unlinkpath(repo.wjoin(f), ignoremissing=True)
             lfdirstate.remove(f)
         lfdirstate.write()
         forget = [lfutil.standin(f) for f in forget]
--- a/hgext/rebase.py	Tue Jan 15 23:30:10 2013 +0100
+++ b/hgext/rebase.py	Tue Jan 15 23:30:10 2013 +0100
@@ -319,8 +319,7 @@
 
         clearstatus(repo)
         ui.note(_("rebase completed\n"))
-        if os.path.exists(repo.sjoin('undo')):
-            util.unlinkpath(repo.sjoin('undo'))
+        util.unlinkpath(repo.sjoin('undo'), ignoremissing=True)
         if skipped:
             ui.note(_("%d revisions have been skipped\n") % len(skipped))
 
@@ -508,8 +507,7 @@
 
 def clearstatus(repo):
     'Remove the status files'
-    if os.path.exists(repo.join("rebasestate")):
-        util.unlinkpath(repo.join("rebasestate"))
+    util.unlinkpath(repo.join("rebasestate"), ignoremissing=True)
 
 def restorestatus(repo):
     'Restore a previously stored status'
--- a/mercurial/commands.py	Tue Jan 15 23:30:10 2013 +0100
+++ b/mercurial/commands.py	Tue Jan 15 23:30:10 2013 +0100
@@ -2947,8 +2947,8 @@
         wlock.release()
 
     # remove state when we complete successfully
-    if not opts.get('dry_run') and os.path.exists(repo.join('graftstate')):
-        util.unlinkpath(repo.join('graftstate'))
+    if not opts.get('dry_run'):
+        util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
 
     return 0