# HG changeset patch # User jrice@netbeans.org # Date 1202917852 0 # Node ID 07fc9e2fd1982732f5c0a1e461430f26c9876427 # Parent cf1fe73564b0dc911fe6b897e116d5267fcfdef5 #127180: multiple entries added into .hgirnore on clone - only prompt user to add if they have an existing .hgirnore and it does not have these entries diff -r cf1fe73564b0 -r 07fc9e2fd198 mercurial/src/org/netbeans/modules/mercurial/util/Bundle.properties --- a/mercurial/src/org/netbeans/modules/mercurial/util/Bundle.properties Wed Feb 13 15:23:29 2008 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/util/Bundle.properties Wed Feb 13 15:50:52 2008 +0000 @@ -63,7 +63,7 @@ MSG_ARG_LIST_TOO_LONG_ERR = \nMercurial MSG_ARG_LIST_TOO_LONG_ERR = \nMercurial command "hg {0}" could not be executed as too many argumensts ({1}) where passed\n\nPlease perform this operation from the command line. MSG_USING_PROXY_INFO = using IDE Options->General Proxy settings: {0} -MSG_IGNORE_FILES = When working with this Clone, if you are doing any Merges or Reverts Mercurial\nmay generate additional files with extensions, .orig, .chg and .rej.\n\nWould you like the IDE to automatically ignore them by adding these extensions\nto the clone's .hgignore file if not already there? +MSG_IGNORE_FILES = When working with this Clone, if you are doing any Merges or Reverts Mercurial\nmay generate additional files with extensions, .orig, .chg and .rej.\n\nWould you like the IDE to automatically ignore them by adding these extensions\nto the clone's .hgignore file? MSG_IGNORE_FILES_TITLE = Mercurial Working Files diff -r cf1fe73564b0 -r 07fc9e2fd198 mercurial/src/org/netbeans/modules/mercurial/util/HgUtils.java --- a/mercurial/src/org/netbeans/modules/mercurial/util/HgUtils.java Wed Feb 13 15:23:29 2008 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/util/HgUtils.java Wed Feb 13 15:50:52 2008 +0000 @@ -363,11 +363,6 @@ public class HgUtils { File root = hg.getTopmostManagedParent(path); if( root == null) return; File ignore = new File(root, FILENAME_HGIGNORE); - if (ignore.exists()) { - if (!confirmDialog(HgUtils.class, "MSG_IGNORE_FILES_TITLE", "MSG_IGNORE_FILES")) { // NOI18N - return; - } - } try { if (!ignore.exists()) { @@ -392,7 +387,8 @@ public class HgUtils { } } } - + + private static int HG_NUM_PATTERNS_TO_CHECK = 4; private static void addToExistingIgnoredFile(File hgignoreFile) { if(hgignoreFile == null || !hgignoreFile.exists() || !hgignoreFile.canWrite()) return; File tempFile = null; @@ -402,7 +398,11 @@ public class HgUtils { boolean bOrigPresent = false; boolean bChgAnyPresent = false; boolean bRejAnyPresent = false; - + + // If new patterns are added to HG_IGNORE_FILES, following code needs to + // check for these new patterns + assert( HG_IGNORE_FILES.length == HG_NUM_PATTERNS_TO_CHECK); + try { tempFile = new File(hgignoreFile.getAbsolutePath() + ".tmp"); // NOI18N if (tempFile == null) return; @@ -451,6 +451,10 @@ public class HgUtils { boolean bAnyAdditions = !bOrigAnyPresent || !bOrigPresent || !bChgAnyPresent || !bRejAnyPresent; if(bAnyAdditions){ + if (!confirmDialog(HgUtils.class, "MSG_IGNORE_FILES_TITLE", "MSG_IGNORE_FILES")) { // NOI18N + tempFile.delete(); + return; + } if(tempFile != null && tempFile.isFile() && tempFile.canWrite() && hgignoreFile != null){ hgignoreFile.delete(); tempFile.renameTo(hgignoreFile);