# HG changeset patch # User Chris Cannam # Date 1291379579 0 # Node ID 98fa31128e9d244280c14c3544fa31e2111233db # Parent 087d7cdde662566cadd75c8848c85f14f9958617 * That string scraping was much too fiddly -- best keep it simpler for now diff -r 087d7cdde662 -r 98fa31128e9d easyhg.py --- a/easyhg.py Fri Dec 03 12:29:57 2010 +0000 +++ b/easyhg.py Fri Dec 03 12:32:59 2010 +0000 @@ -18,31 +18,13 @@ from mercurial.i18n import _ from PyQt4 import QtGui -# This is a gross hack throughout - easyhg_qtapp = None -easyhg_userprompt = '' -easyhg_pwdprompt = '' def uisetup(ui): - ui.__class__.write = easyhg_write ui.__class__.prompt = easyhg_prompt ui.__class__.getpass = easyhg_getpass - global easyhg_qtapp, easyhg_pwdprompt, easyhg_userprompt + global easyhg_qtapp easyhg_qtapp = QtGui.QApplication([]) - easyhg_pwdprompt = '' - easyhg_userprompt = '' - -def easyhg_write(self, *args, **opts): - global easyhg_pwdprompt - global easyhg_userprompt - for a in args: - (pfx, div, sfx) = a.partition(': '); - if pfx == 'realm' and sfx != '': - easyhg_userprompt = easyhg_pwdprompt = '' + sfx + '
'; - elif pfx == 'user' and sfx != '': - easyhg_pwdprompt += _('Password for user') + ' ' + sfx + ':'; - sys.stdout.write(str(a)) def easyhg_prompt(self, msg, default="y"): if not self.interactive(): @@ -50,28 +32,20 @@ return default if msg == _('user:'): msg = _('User:') - global easyhg_userprompt, easyhg_pwdprompt - if easyhg_userprompt != '': - msg = easyhg_userprompt + msg; - (r,ok) = QtGui.QInputDialog.getText(None, _('Question'), + (r,ok) = QtGui.QInputDialog.getText(None, _('Information needed'), msg, QtGui.QLineEdit.Normal) if not ok: raise util.Abort(_('response expected')) if not r: - easyhg_pwdprompt += _('Password:'); return default - easyhg_pwdprompt += _('Password for user') + ' ' + r + ':'; return r def easyhg_getpass(self, prompt=None, default=None): if not self.interactive(): return default - global easyhg_pwdprompt - if easyhg_pwdprompt != '': - msg = easyhg_pwdprompt - else: - msg = _('Password:'); - (r,ok) = QtGui.QInputDialog.getText(None, _('Password'), msg, + if not prompt or prompt == _('password:'): + prompt = _('Password:'); + (r,ok) = QtGui.QInputDialog.getText(None, _('Password'), prompt, QtGui.QLineEdit.Password) if not ok: raise util.Abort(_('response expected'))