void () { // find if we've already been here final HgVcs vcs = HgVcs.getInstance(myProject); if (vcs == null) { return; } final @NotNull HgGlobalSettings hgGlobalSettings = HgGlobalSettings.getInstance(); @Nullable String rememberedLoginsForUrl = null; String url = VirtualFileManager.extractPath(myURL); if (!StringUtil.isEmptyOrSpaces(myURL)) { rememberedLoginsForUrl = hgGlobalSettings.getRememberedUserName(url); } String login = myProposedLogin; if (StringUtil.isEmptyOrSpaces(login)) { // find the last used login login = rememberedLoginsForUrl; } Credentials savedCredentials = PasswordSafe.getInstance().get(createCredentialAttributes(url)); String password = savedCredentials == null ? null : savedCredentials.getPasswordAsString(); if (savedCredentials != null && StringUtil.isEmptyOrSpaces(login)) { login = savedCredentials.getUserName(); } // don't show dialog if we don't have to (both fields are known) except force authorization required if (!myForceAuthorization && !StringUtil.isEmptyOrSpaces(password) && !StringUtil.isEmptyOrSpaces(login)) { myCredentials = new Credentials(login, password); ok = true; return; } if (mySilent) { ok = false; return; } final AuthDialog dialog = new AuthDialog(myProject, HgBundle.message("hg4idea.dialog.login.password.required"), HgBundle.message("hg4idea.dialog.login.description", myURL), login, password, true); if (dialog.showAndGet()) { ok = true; Credentials credentials = new Credentials(dialog.getUsername(), dialog.getPassword()); myCredentials = credentials; PasswordSafe.getInstance().set(createCredentialAttributes(url), credentials, !dialog.isRememberPassword()); hgGlobalSettings.addRememberedUrl(url, credentials.getUserName()); } }