# HG changeset patch # User jrice@netbeans.org # Date 1207149126 -3600 # Node ID 0b7d4a0c3043ac66037a95640a87aed7a956c1fc # Parent 208cabf1e10e907b36e33837e1739818f69cfb14 #126803: Username email checking in properties now consistent with Options and also allows userid@localhost diff -r 208cabf1e10e -r 0b7d4a0c3043 mercurial/src/org/netbeans/modules/mercurial/HgMail.java --- a/mercurial/src/org/netbeans/modules/mercurial/HgMail.java Wed Apr 02 11:36:48 2008 +0100 +++ b/mercurial/src/org/netbeans/modules/mercurial/HgMail.java Wed Apr 02 16:12:06 2008 +0100 @@ -47,10 +47,12 @@ public class HgMail { //Combined together, these form the allowed email regexp allowed by RFC 2822: private static final String addrSpec = "^" + localPart + "@" + domain + "$"; // NOI18N + private static final String addrLocalSpec = "^" + localPart + "@" + localPart + "$"; // NOI18N //now compile it: public static final Pattern VALID_PATTERN = Pattern.compile( addrSpec ); + public static final Pattern VALID_LOCAL_PATTERN = Pattern.compile( addrLocalSpec ); public static Boolean isUserNameValid(String name) { /* @@ -62,10 +64,10 @@ public class HgMail { int startbr = name.lastIndexOf("<"); // NOI18N if (startbr != -1) { String newName = name.substring(startbr + 1, name.length() -1); - return VALID_PATTERN.matcher(newName).matches(); + return VALID_PATTERN.matcher(newName).matches() || VALID_LOCAL_PATTERN.matcher(newName).matches(); } return false; } - return VALID_PATTERN.matcher(name).matches(); + return VALID_PATTERN.matcher(name).matches() || VALID_LOCAL_PATTERN.matcher(name).matches(); } } diff -r 208cabf1e10e -r 0b7d4a0c3043 mercurial/src/org/netbeans/modules/mercurial/HgModuleConfig.java --- a/mercurial/src/org/netbeans/modules/mercurial/HgModuleConfig.java Wed Apr 02 11:36:48 2008 +0100 +++ b/mercurial/src/org/netbeans/modules/mercurial/HgModuleConfig.java Wed Apr 02 16:12:06 2008 +0100 @@ -208,7 +208,7 @@ public class HgModuleConfig { } catch (Exception ex) { hostName = "localhost"; //NOI18N } - userName = userId + "@" + hostName + ".zzz"; // NOI18N + userName = userId + "@" + hostName; // NOI18N } return userName; } diff -r 208cabf1e10e -r 0b7d4a0c3043 mercurial/src/org/netbeans/modules/mercurial/options/Bundle.properties --- a/mercurial/src/org/netbeans/modules/mercurial/options/Bundle.properties Wed Apr 02 11:36:48 2008 +0100 +++ b/mercurial/src/org/netbeans/modules/mercurial/options/Bundle.properties Wed Apr 02 16:12:06 2008 +0100 @@ -89,7 +89,7 @@ LBL_Properties_Progress=Scanning Mercuri LBL_Properties_Progress=Scanning Mercurial Extensions MSG_WARN_FIELD_TITLE = Invalid Field -MSG_WARN_USER_NAME_TEXT = The text specified in the Mercurial User Name is not a valid email address. +MSG_WARN_USER_NAME_TEXT = The specified username is not a valid email address.\n\nThe username has not been changed. MSG_WARN_EXEC_PATH_TEXT = The specified Mercurial Executable Path does not contain the Mercurial program. MercurialPanel.ExportFilename.text=&Default Export Filename\: diff -r 208cabf1e10e -r 0b7d4a0c3043 mercurial/src/org/netbeans/modules/mercurial/ui/properties/Bundle.properties --- a/mercurial/src/org/netbeans/modules/mercurial/ui/properties/Bundle.properties Wed Apr 02 11:36:48 2008 +0100 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/properties/Bundle.properties Wed Apr 02 16:12:06 2008 +0100 @@ -54,3 +54,6 @@ jLabel3.txt=Mercurial &Properties: jLabel3.txt=Mercurial &Properties: ACSD_txtAreaValue=Used to edit the value of the selected prooperty ACSD_Properties_Dialog=Mercurial Properties Editor + +MSG_WARN_FIELD_TITLE = Invalid Property +MSG_WARN_USER_NAME_TEXT = The specified username is not a valid email address.\n\nThe username has not been changed. diff -r 208cabf1e10e -r 0b7d4a0c3043 mercurial/src/org/netbeans/modules/mercurial/ui/properties/HgProperties.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/properties/HgProperties.java Wed Apr 02 11:36:48 2008 +0100 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/properties/HgProperties.java Wed Apr 02 16:12:06 2008 +0100 @@ -166,7 +166,15 @@ public class HgProperties implements Lis String hgPropertyValue = hgPropertiesNodes[i].getValue(); boolean bPropChanged = !(initHgProps[i].getValue()).equals(hgPropertyValue); if (bPropChanged && hgPropertyValue.trim().length() >= 0 ) { - HgModuleConfig.getDefault().setProperty(root, hgPropertyName, hgPropertyValue); + if (hgPropertyName.equals(HGPROPNAME_USERNAME) && + !HgModuleConfig.getDefault().isUserNameValid(hgPropertyValue)) { + JOptionPane.showMessageDialog(null, + NbBundle.getMessage(HgProperties.class, "MSG_WARN_USER_NAME_TEXT"), // NOI18N + NbBundle.getMessage(HgProperties.class, "MSG_WARN_FIELD_TITLE"), // NOI18N + JOptionPane.WARNING_MESSAGE); + }else{ + HgModuleConfig.getDefault().setProperty(root, hgPropertyName, hgPropertyValue); + } } } HgRepositoryContextCache.resetPullDefault(); diff -r 208cabf1e10e -r 0b7d4a0c3043 mercurial/src/org/netbeans/modules/mercurial/util/HgCommand.java --- a/mercurial/src/org/netbeans/modules/mercurial/util/HgCommand.java Wed Apr 02 11:36:48 2008 +0100 +++ b/mercurial/src/org/netbeans/modules/mercurial/util/HgCommand.java Wed Apr 02 16:12:06 2008 +0100 @@ -1646,9 +1646,9 @@ public class HgCommand { command.add(repository.getAbsolutePath()); command.add(HG_OPT_CWD_CMD); command.add(repository.getAbsolutePath()); - + String projectUserName = new HgConfigFiles(repository).getUserName(false); - String globalUsername = HgConfigFiles.getSysInstance().getSysUserName(); + String globalUsername = HgModuleConfig.getDefault().getSysUserName(); String username = null; if(projectUserName != null && projectUserName.length() > 0) username = projectUserName;