# HG changeset patch # User Mads Kiilerich # Date 2013-01-15 22:30:10 # Node ID 03442135dff426805380fa57e25d017c87b46f0c # Parent bafbfe0b450cb80f688d7b62d6a5a7dc16a86614 refactoring: use unlinkpath with ignoremissing diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py --- a/hgext/largefiles/overrides.py +++ b/hgext/largefiles/overrides.py @@ -170,8 +170,7 @@ def removelargefiles(ui, repo, *pats, ** # 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] diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -319,8 +319,7 @@ def rebase(ui, repo, **opts): 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 storestatus(repo, originalwd, target 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' diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2947,8 +2947,8 @@ def graft(ui, repo, *revs, **opts): 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