# HG changeset patch # User Augie Fackler # Date 2011-07-26 01:37:12 # Node ID 11aad09a637050930dd61c982167ba5af5988487 # Parent e2c413bde8a59c63fd2f88ff7e9a620bbab38227 hgext: replace uses of hasattr with util.safehasattr diff --git a/hgext/convert/cvsps.py b/hgext/convert/cvsps.py --- a/hgext/convert/cvsps.py +++ b/hgext/convert/cvsps.py @@ -11,6 +11,7 @@ import cPickle as pickle from mercurial import util from mercurial.i18n import _ from mercurial import hook +from mercurial import util class logentry(object): '''Class logentry has the following attributes: @@ -513,8 +514,8 @@ def createchangeset(ui, log, fuzz=60, me e.comment == c.comment and e.author == c.author and e.branch == c.branch and - (not hasattr(e, 'branchpoints') or - not hasattr (c, 'branchpoints') or + (not util.safehasattr(e, 'branchpoints') or + not util.safehasattr (c, 'branchpoints') or e.branchpoints == c.branchpoints) and ((c.date[0] + c.date[1]) <= (e.date[0] + e.date[1]) <= diff --git a/hgext/convert/git.py b/hgext/convert/git.py --- a/hgext/convert/git.py +++ b/hgext/convert/git.py @@ -16,7 +16,7 @@ class convert_git(converter_source): # Windows does not support GIT_DIR= construct while other systems # cannot remove environment variable. Just assume none have # both issues. - if hasattr(os, 'unsetenv'): + if util.safehasattr(os, 'unsetenv'): def gitopen(self, s, noerr=False): prevgitdir = os.environ.get('GIT_DIR') os.environ['GIT_DIR'] = self.path diff --git a/hgext/convert/transport.py b/hgext/convert/transport.py --- a/hgext/convert/transport.py +++ b/hgext/convert/transport.py @@ -54,7 +54,7 @@ def _create_auth_baton(pool): if p: providers.append(p) else: - if hasattr(svn.client, 'get_windows_simple_provider'): + if util.safehasattr(svn.client, 'get_windows_simple_provider'): providers.append(svn.client.get_windows_simple_provider(pool)) return svn.core.svn_auth_open(providers, pool) @@ -73,7 +73,7 @@ class SvnRaTransport(object): self.password = '' # Only Subversion 1.4 has reparent() - if ra is None or not hasattr(svn.ra, 'reparent'): + if ra is None or not util.safehasattr(svn.ra, 'reparent'): self.client = svn.client.create_context(self.pool) ab = _create_auth_baton(self.pool) if False: diff --git a/hgext/inotify/__init__.py b/hgext/inotify/__init__.py --- a/hgext/inotify/__init__.py +++ b/hgext/inotify/__init__.py @@ -11,6 +11,7 @@ # todo: socket permissions from mercurial.i18n import _ +from mercurial import util import server from client import client, QueryFailed @@ -31,7 +32,7 @@ def debuginotify(ui, repo, **opts): ui.write((' %s/\n') % path) def reposetup(ui, repo): - if not hasattr(repo, 'dirstate'): + if not util.safehasattr(repo, 'dirstate'): return class inotifydirstate(repo.dirstate.__class__): diff --git a/hgext/pager.py b/hgext/pager.py --- a/hgext/pager.py +++ b/hgext/pager.py @@ -58,7 +58,7 @@ from mercurial import commands, dispatch from mercurial.i18n import _ def _runpager(p): - if not hasattr(os, 'fork'): + if not util.safehasattr(os, 'fork'): sys.stdout = util.popen(p, 'wb') if util.isatty(sys.stderr): sys.stderr = sys.stdout diff --git a/hgext/relink.py b/hgext/relink.py --- a/hgext/relink.py +++ b/hgext/relink.py @@ -36,7 +36,8 @@ def relink(ui, repo, origin=None, **opts command is running. (Both repositories will be locked against writes.) """ - if not hasattr(util, 'samefile') or not hasattr(util, 'samedevice'): + if (not util.safehasattr(util, 'samefile') or + not util.safehasattr(util, 'samedevice')): raise util.Abort(_('hardlinks are not supported on this system')) src = hg.repository(ui, ui.expandpath(origin or 'default-relink', origin or 'default'))