# HG changeset patch # User jrice@netbeans.org # Date 1206633036 0 # Node ID ef55c64dc8f37d79e83f90a62a91f1a0eb4935f7 # Parent 33dfaaad29b458ffa2c010b9521939adb3f30ea6 #126803: Username settings - part3 unix additions diff -r 33dfaaad29b4 -r ef55c64dc8f3 mercurial/src/org/netbeans/modules/mercurial/HgModuleConfig.java --- a/mercurial/src/org/netbeans/modules/mercurial/HgModuleConfig.java Wed Mar 26 17:31:23 2008 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/HgModuleConfig.java Thu Mar 27 15:50:36 2008 +0000 @@ -206,7 +206,7 @@ public class HgModuleConfig { try { hostName = InetAddress.getLocalHost().getHostName(); } catch (Exception ex) { - return userName; + hostName = "localhost"; //NOI18N } userName = userId + "@" + hostName + ".zzz"; // NOI18N } diff -r 33dfaaad29b4 -r ef55c64dc8f3 mercurial/src/org/netbeans/modules/mercurial/config/HgConfigFiles.java --- a/mercurial/src/org/netbeans/modules/mercurial/config/HgConfigFiles.java Wed Mar 26 17:31:23 2008 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/config/HgConfigFiles.java Thu Mar 27 15:50:36 2008 +0000 @@ -320,13 +320,16 @@ public class HgConfigFiles { String filePath = getUserConfigPath() + fileName; File file = FileUtil.normalizeFile(new File(filePath)); File tmpFile = HgUtils.fixPathsInIniFileOnWindows(file); - if (tmpFile != null && tmpFile.isFile() && tmpFile.canWrite() && file != null) { - file.delete(); - tmpFile.renameTo(file); - } Ini system = null; try { - system = tmpFile != null? new Ini(new FileReader(tmpFile)): null; + if (Utilities.isWindows() && tmpFile != null && tmpFile.isFile() && tmpFile.canWrite() && file != null) { + file.delete(); + boolean bRenamed = tmpFile.renameTo(file); + system = bRenamed? new Ini(new FileReader(tmpFile)): null; + } else { + system = new Ini(new FileReader(file)); + } + } catch (FileNotFoundException ex) { // ignore } catch (IOException ex) { @@ -342,8 +345,12 @@ public class HgConfigFiles { try { File gFile = FileUtil.normalizeFile(new File(getGlobalConfigPath() + File.separator + fileName)); File tmp2File = HgUtils.fixPathsInIniFileOnWindows(gFile); - tmp2File.deleteOnExit(); - global = new Ini(new FileReader(tmp2File)); // NOI18N + if (Utilities.isWindows() && tmp2File != null) { + tmp2File.deleteOnExit(); + global = new Ini(new FileReader(tmp2File)); // NOI18N + } else { + global = new Ini(new FileReader(gFile)); // NOI18N + } } catch (FileNotFoundException ex) { // just doesn't exist - ignore } catch (IOException ex) { diff -r 33dfaaad29b4 -r ef55c64dc8f3 mercurial/src/org/netbeans/modules/mercurial/ui/properties/HgProperties.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/properties/HgProperties.java Wed Mar 26 17:31:23 2008 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/properties/HgProperties.java Thu Mar 27 15:50:36 2008 +0000 @@ -165,7 +165,7 @@ public class HgProperties implements Lis String hgPropertyName = hgPropertiesNodes[i].getName(); String hgPropertyValue = hgPropertiesNodes[i].getValue(); boolean bPropChanged = !(initHgProps[i].getValue()).equals(hgPropertyValue); - if (bPropChanged && hgPropertyValue.trim().length() > 0 ) { + if (bPropChanged && hgPropertyValue.trim().length() >= 0 ) { HgModuleConfig.getDefault().setProperty(root, hgPropertyName, hgPropertyValue); } } diff -r 33dfaaad29b4 -r ef55c64dc8f3 mercurial/src/org/netbeans/modules/mercurial/util/HgUtils.java --- a/mercurial/src/org/netbeans/modules/mercurial/util/HgUtils.java Wed Mar 26 17:31:23 2008 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/util/HgUtils.java Thu Mar 27 15:50:36 2008 +0000 @@ -275,7 +275,7 @@ public class HgUtils { * @return File processed tmpFile */ public static File fixPathsInIniFileOnWindows(File iniFile) { - if(!Utilities.isWindows()) return iniFile; + if(!Utilities.isWindows()) return null; File tmpFile = null; BufferedReader br = null;