# HG changeset patch # User Chris Cannam # Date 1310393731 -3600 # Node ID 0714a86b80777e85ac32940f2f4525aa83c85ff2 # Parent d63711ff6740425c0d48b568636cde96dcebd03b Check for repeated request (thus failed login) before looking up cached data, so we can cache in confidence without resending invalid login details (fixing #205) diff -r d63711ff6740 -r 0714a86b8077 easyhg.py --- a/easyhg.py Thu Jul 07 10:59:50 2011 +0100 +++ b/easyhg.py Mon Jul 11 15:15:31 2011 +0100 @@ -230,17 +230,21 @@ def __init__(self, ui, url, user, passwd): self.auth_store = EasyHgAuthStore(ui, url, user, passwd) - def ask(self, force_dialog): + def ask(self, repeat): if self.auth_store.user and self.auth_store.passwd and self.auth_store.remember: - if not force_dialog: + if not repeat: return (self.auth_store.user, self.auth_store.passwd) dialog = QtGui.QDialog() layout = QtGui.QGridLayout() dialog.setLayout(layout) - layout.addWidget(QtGui.QLabel(_('

Login required

Please provide your login details for the repository at
%s:') % self.auth_store.argless_url()), 0, 0, 1, 2) + heading = _('Login required') + if repeat: + heading = _('Login failed: please try again') + label_text = _(('

%s

Please provide your login details for the repository at
%s:') % (heading, self.auth_store.argless_url())) + layout.addWidget(QtGui.QLabel(label_text), 0, 0, 1, 2) user_field = QtGui.QLineEdit() if self.auth_store.user: user_field.setText(self.auth_store.user) @@ -334,17 +338,7 @@ self, realm, authuri) user, passwd = authinfo - if user and passwd: -# self.ui.write("note: user and passwd both provided\n") - return orig_find(self, realm, authuri) - -# self.ui.write("want username and/or password for %s\n" % authuri) - - force_dialog = False - -# if self.__easyhg_last: -# self.ui.write("last = realm '%s' authuri '%s'\n" % self.__easyhg_last) -# self.ui.write("me = realm '%s' authuri '%s'\n" % (realm, authuri)) + repeat = False if (realm, authuri) == self.__easyhg_last: # If we are called again just after identical previous @@ -352,16 +346,17 @@ # wrong. So we note this to force password prompt (and avoid # reusing bad password indefinitely). Thanks to # mercurial_keyring (Marcin Kasperski) for this logic -# self.ui.write("same again!\n") - force_dialog = True + repeat = True + + if user and passwd and not repeat: + return orig_find(self, realm, authuri) dialog = EasyHgAuthDialog(self.ui, authuri, user, passwd) - (user, passwd) = dialog.ask(force_dialog) + (user, passwd) = dialog.ask(repeat) -# self.add_password(realm, authuri, user, passwd) + self.add_password(realm, authuri, user, passwd) self.__easyhg_last = (realm, authuri) -# self.ui.write("done = realm '%s' authuri '%s'\n" % self.__easyhg_last) return (user, passwd)