Mercurial > hg > easyhg
diff easyhg.py @ 210:c5fceb3fe5b4
* OS/X: Add script to run external diff; add space around tab widget; textual fixes
* Bail out of easyhg.py in uisetup rather than at extension load time if we can't load PyQt4 -- that way we find out about it in easyhg
* Ensure editing the default path works even if hgrc doesn't yet exist; ensure path and branch are reset (to empty and default) if their respective files are absent
author | Chris Cannam |
---|---|
date | Wed, 05 Jan 2011 14:31:07 +0000 |
parents | 07b908b4fa5f |
children | 960b782f0a64 |
line wrap: on
line diff
--- a/easyhg.py Tue Jan 04 16:34:33 2011 +0000 +++ b/easyhg.py Wed Jan 05 14:31:07 2011 +0000 @@ -26,11 +26,24 @@ if not easyhg_import_path.startswith('NO_'): sys.path.append(easyhg_import_path) -from PyQt4 import QtGui +# Try to load the PyQt4 module that we need. If this fails, we should +# bail out later (in uisetup), because if we bail out now, Mercurial +# will just continue without us and report success. The invoking +# application needs to be able to discover whether the module load +# succeeded or not, so we need to ensure that Mercurial itself returns +# failure if it didn't. +# +easyhg_pyqt_ok = True +try: + from PyQt4 import QtGui +except ImportError as err: + easyhg_pyqt_ok = False easyhg_qtapp = None def uisetup(ui): + if not easyhg_pyqt_ok: + raise util.Abort(_('Failed to load PyQt4 module required by easyhg.py')) ui.__class__.prompt = easyhg_prompt ui.__class__.getpass = easyhg_getpass global easyhg_qtapp