# HG changeset patch # User Martin Geisler # Date 2010-08-25 14:23:32 # Node ID ad787252fed6a948f3ac6b37b0cac54c74319cec # Parent 77bbeafd7519a9be5452e9370ae4f7c27ac4fd3e util: remove lexists, Python 2.4 introduced os.path.lexists diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -297,7 +297,7 @@ def addremove(repo, pats=[], opts={}, dr unknown.append(abs) if repo.ui.verbose or not exact: repo.ui.status(_('adding %s\n') % ((pats and rel) or abs)) - elif repo.dirstate[abs] != 'r' and (not good or not util.lexists(target) + elif repo.dirstate[abs] != 'r' and (not good or not os.path.lexists(target) or (os.path.isdir(target) and not os.path.islink(target))): deleted.append(abs) if repo.ui.verbose or not exact: diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -3166,7 +3166,7 @@ def revert(ui, repo, *pats, **opts): target = repo.wjoin(abs) def handle(xlist, dobackup): xlist[0].append(abs) - if dobackup and not opts.get('no_backup') and util.lexists(target): + if dobackup and not opts.get('no_backup') and os.path.lexists(target): bakname = "%s.orig" % rel ui.note(_('saving current version of %s as %s\n') % (rel, bakname)) diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -282,7 +282,7 @@ def applyupdates(repo, action, wctx, mct # remove renamed files after safely stored for f in moves: - if util.lexists(repo.wjoin(f)): + if os.path.lexists(repo.wjoin(f)): repo.ui.debug("removing %s\n" % f) os.unlink(repo.wjoin(f)) @@ -320,7 +320,7 @@ def applyupdates(repo, action, wctx, mct else: merged += 1 util.set_flags(repo.wjoin(fd), 'l' in flags, 'x' in flags) - if f != fd and move and util.lexists(repo.wjoin(f)): + if f != fd and move and os.path.lexists(repo.wjoin(f)): repo.ui.debug("removing %s\n" % f) os.unlink(repo.wjoin(f)) elif m == "g": # get diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -918,7 +918,7 @@ def selectfile(afile_orig, bfile_orig, h nulla = afile_orig == "/dev/null" nullb = bfile_orig == "/dev/null" abase, afile = pathstrip(afile_orig, strip) - gooda = not nulla and util.lexists(afile) + gooda = not nulla and os.path.lexists(afile) bbase, bfile = pathstrip(bfile_orig, strip) if afile == bfile: goodb = gooda diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -431,15 +431,6 @@ def checksignature(func): return check -# os.path.lexists is not available on python2.3 -def lexists(filename): - "test whether a file with this name exists. does not follow symlinks" - try: - os.lstat(filename) - except: - return False - return True - def unlink(f): """unlink and remove the directory if it is empty""" os.unlink(f)