# HG changeset patch # User jrice@netbeans.org # Date 1210952815 -3600 # Node ID b9a50ba69ffe3a485a7fd9a2212305e191f0779d # Parent 3b13fc76f535bd6fb66568b0b59ab285ab23e0f4 #133203: Search History will only list files from the selected context in the displayed changesets diff -r 3b13fc76f535 -r b9a50ba69ffe mercurial/src/org/netbeans/modules/mercurial/ui/log/HgLogMessage.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/log/HgLogMessage.java Fri May 16 12:31:10 2008 +0100 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/log/HgLogMessage.java Fri May 16 16:46:55 2008 +0100 @@ -81,8 +81,28 @@ public class HgLogMessage { public HgLogMessage(String changeset){ } - - public HgLogMessage(String rootURL, String rev, String auth, String desc, String date, String id, + private void updatePaths(List paths, List pathsStrings, String path, + List filesShortPaths, char HgStatus) { + if (filesShortPaths.isEmpty()) { + paths.add(new HgLogMessageChangedPath(path, HgStatus)); + if(pathsStrings != null){ + pathsStrings.add(path); + } + logCopied(path); + } else { + for (String fileSP : filesShortPaths) { + if (path.equals(fileSP) || path.startsWith(fileSP)) { + paths.add(new HgLogMessageChangedPath(path, HgStatus)); + if(pathsStrings != null){ + pathsStrings.add(path); + } + logCopied(path); + break; + } + } + } + } + public HgLogMessage(String rootURL, List filesShortPaths, String rev, String auth, String desc, String date, String id, String parents, String fm, String fa, String fd, String fc){ String splits[]; @@ -114,25 +134,19 @@ public class HgLogMessage { if (fa != null && !fa.equals("")) { splits = fa.split(" "); for (String s : splits) { - this.apaths.add(new HgLogMessageChangedPath(s, HgAddStatus)); - apathsStrings.add(s); - logCopied(s); + updatePaths(this.apaths, apathsStrings, s, filesShortPaths, HgAddStatus); } } if (fd != null && !fd.equals("")) { splits = fd.split(" "); for (String s : splits) { - this.dpaths.add(new HgLogMessageChangedPath(s, HgDelStatus)); - dpathsStrings.add(s); - logCopied(s); + updatePaths(this.dpaths, dpathsStrings, s, filesShortPaths, HgDelStatus); } } if (fc != null && !fc.equals("")) { splits = fc.split(" "); for (String s : splits) { - this.cpaths.add(new HgLogMessageChangedPath(s, HgCopyStatus)); - cpathsStrings.add(s); - logCopied(s); + updatePaths(this.cpaths, cpathsStrings, s, filesShortPaths, HgCopyStatus); } } if (fm != null && !fm.equals("")) { @@ -140,8 +154,7 @@ public class HgLogMessage { for (String s : splits) { //#132743, incorrectly reporting files as added/modified, deleted/modified in same changeset if (!apathsStrings.contains(s) && !dpathsStrings.contains(s) && !cpathsStrings.contains(s)) { - this.mpaths.add(new HgLogMessageChangedPath(s, HgModStatus)); - logCopied(s); + updatePaths(this.mpaths, null, s, filesShortPaths, HgModStatus); } } } diff -r 3b13fc76f535 -r b9a50ba69ffe mercurial/src/org/netbeans/modules/mercurial/util/HgCommand.java --- a/mercurial/src/org/netbeans/modules/mercurial/util/HgCommand.java Fri May 16 12:31:10 2008 +0100 +++ b/mercurial/src/org/netbeans/modules/mercurial/util/HgCommand.java Fri May 16 16:46:55 2008 +0100 @@ -825,9 +825,19 @@ public class HgCommand { return list; } - private static List processLogMessages(String rootURL, List list, final List messages) { + private static List processLogMessages(String rootURL, List files, List list, final List messages) { String rev, author, desc, date, id, parents, fm, fa, fd, fc; + List filesShortPaths = new ArrayList(); + if (list != null && !list.isEmpty()) { + if(files != null){ + for(File f: files){ + String shortPath = f.getAbsolutePath(); + if(shortPath.startsWith(rootURL) && shortPath.length() > rootURL.length()) { + filesShortPaths.add(shortPath.substring(rootURL.length()+1)); + } + } + } rev = author = desc = date = id = parents = fm = fa = fd = fc = null; boolean bEnd = false; for (String s : list) { @@ -858,7 +868,7 @@ public class HgCommand { } if (rev != null & bEnd) { - messages.add(new HgLogMessage(rootURL, rev, author, desc, date, id, parents, fm, fa, fd, fc)); + messages.add(new HgLogMessage(rootURL, filesShortPaths, rev, author, desc, date, id, parents, fm, fa, fd, fc)); rev = author = desc = date = id = parents = fm = fa = fd = fc = null; bEnd = false; } @@ -875,7 +885,7 @@ public class HgCommand { List list = new LinkedList(); list = HgCommand.doIncomingForSearch(root, toRevision, bShowMerges, logger); - processLogMessages(rootUrl, list, messages); + processLogMessages(rootUrl, null, list, messages); } catch (HgException ex) { NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); @@ -895,7 +905,7 @@ public class HgCommand { List list = new LinkedList(); list = HgCommand.doOutForSearch(root, toRevision, bShowMerges, logger); - processLogMessages(rootUrl, list, messages); + processLogMessages(rootUrl, null, list, messages); } catch (HgException ex) { NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); @@ -950,10 +960,11 @@ public class HgCommand { } List list = new LinkedList(); + List filesList = files != null ? new ArrayList(files) : null; list = HgCommand.doLogForHistory(root, - files != null ? new ArrayList(files) : null, - fromRevision, toRevision, headRev, bShowMerges, bGetFileInfo, limit, logger); - processLogMessages(rootUrl, list, messages); + filesList, + fromRevision, toRevision, headRev, bShowMerges, bGetFileInfo, limit, logger); + processLogMessages(rootUrl, filesList, list, messages); } catch (HgException ex) { NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); DialogDisplayer.getDefault().notifyLater(e);