comparison easyhg.py @ 358:ea6f76c0aa76

Make username/password prompts in easyhg.py more helpful; use a distinctive return for cancel in these dialogs, and avoid showing command-failed in the main program when cancelled
author Chris Cannam
date Thu, 17 Mar 2011 13:52:57 +0000
parents 3b8501070c21
children 19cce6d2c470
comparison
equal deleted inserted replaced
357:4373061dd20e 358:ea6f76c0aa76
52 def easyhg_prompt(self, msg, default="y"): 52 def easyhg_prompt(self, msg, default="y"):
53 if not self.interactive(): 53 if not self.interactive():
54 self.write(msg, ' ', default, "\n") 54 self.write(msg, ' ', default, "\n")
55 return default 55 return default
56 if msg == _('user:'): 56 if msg == _('user:'):
57 msg = _('User:') 57 msg = _('Username for remote repository:')
58 d = QtGui.QInputDialog() 58 d = QtGui.QInputDialog()
59 d.setInputMode(QtGui.QInputDialog.TextInput) 59 d.setInputMode(QtGui.QInputDialog.TextInput)
60 d.setTextEchoMode(QtGui.QLineEdit.Normal) 60 d.setTextEchoMode(QtGui.QLineEdit.Normal)
61 d.setLabelText(msg) 61 d.setLabelText(msg)
62 d.setWindowTitle(_('EasyMercurial: Information')) 62 d.setWindowTitle(_('EasyMercurial: Information'))
63 d.show() 63 d.show()
64 d.raise_() 64 d.raise_()
65 ok = d.exec_() 65 ok = d.exec_()
66 r = d.textValue() 66 r = d.textValue()
67 if not ok: 67 if not ok:
68 raise util.Abort(_('response expected')) 68 raise util.Abort(_('username entry cancelled'))
69 if not r: 69 if not r:
70 return default 70 return default
71 return r 71 return r
72 72
73 def easyhg_getpass(self, prompt=None, default=None): 73 def easyhg_getpass(self, prompt=None, default=None):
74 if not self.interactive(): 74 if not self.interactive():
75 return default 75 return default
76 if not prompt or prompt == _('password:'): 76 if not prompt or prompt == _('password:'):
77 prompt = _('Password:'); 77 prompt = _('Password for remote repository:');
78 d = QtGui.QInputDialog() 78 d = QtGui.QInputDialog()
79 d.setInputMode(QtGui.QInputDialog.TextInput) 79 d.setInputMode(QtGui.QInputDialog.TextInput)
80 d.setTextEchoMode(QtGui.QLineEdit.Password) 80 d.setTextEchoMode(QtGui.QLineEdit.Password)
81 d.setLabelText(prompt) 81 d.setLabelText(prompt)
82 d.setWindowTitle(_('EasyMercurial: Password')) 82 d.setWindowTitle(_('EasyMercurial: Password'))
83 d.show() 83 d.show()
84 d.raise_() 84 d.raise_()
85 ok = d.exec_() 85 ok = d.exec_()
86 r = d.textValue() 86 r = d.textValue()
87 if not ok: 87 if not ok:
88 raise util.Abort(_('response expected')) 88 raise util.Abort(_('password entry cancelled'))
89 if not r: 89 if not r:
90 return default 90 return default
91 return r 91 return r
92 92
93