Mercurial > hg
changeset 14945:11aad09a6370
hgext: replace uses of hasattr with util.safehasattr
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Mon, 25 Jul 2011 20:37:12 -0500 |
parents | e2c413bde8a5 |
children | 28762bf809d8 |
files | hgext/convert/cvsps.py hgext/convert/git.py hgext/convert/transport.py hgext/inotify/__init__.py hgext/pager.py hgext/relink.py |
diffstat | 6 files changed, 11 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/convert/cvsps.py Mon Jul 25 15:30:19 2011 -0500 +++ b/hgext/convert/cvsps.py Mon Jul 25 20:37:12 2011 -0500 @@ -11,6 +11,7 @@ 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 @@ 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]) <=
--- a/hgext/convert/git.py Mon Jul 25 15:30:19 2011 -0500 +++ b/hgext/convert/git.py Mon Jul 25 20:37:12 2011 -0500 @@ -16,7 +16,7 @@ # 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
--- a/hgext/convert/transport.py Mon Jul 25 15:30:19 2011 -0500 +++ b/hgext/convert/transport.py Mon Jul 25 20:37:12 2011 -0500 @@ -54,7 +54,7 @@ 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 @@ 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:
--- a/hgext/inotify/__init__.py Mon Jul 25 15:30:19 2011 -0500 +++ b/hgext/inotify/__init__.py Mon Jul 25 20:37:12 2011 -0500 @@ -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 @@ 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__):
--- a/hgext/pager.py Mon Jul 25 15:30:19 2011 -0500 +++ b/hgext/pager.py Mon Jul 25 20:37:12 2011 -0500 @@ -58,7 +58,7 @@ 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
--- a/hgext/relink.py Mon Jul 25 15:30:19 2011 -0500 +++ b/hgext/relink.py Mon Jul 25 20:37:12 2011 -0500 @@ -36,7 +36,8 @@ 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'))