# HG changeset patch # User jrice@netbeans.org # Date 1201740671 0 # Node ID 75a6068f41982cbee46eaeb8f69b7cfd4102264a # Parent d28df42b4215259cc4c494574edc8ba518ab6b43 #117653: Added support for Show Out - will show all outgoing changesets in Show History style, allowing diff and revert diff -r d28df42b4215 -r 75a6068f4198 mercurial/src/org/netbeans/modules/mercurial/Bundle.properties --- a/mercurial/src/org/netbeans/modules/mercurial/Bundle.properties Wed Jan 30 22:50:40 2008 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/Bundle.properties Thu Jan 31 00:51:11 2008 +0000 @@ -104,6 +104,7 @@ CTL_PopupMenuItem_ExportDiff = E&xport D CTL_PopupMenuItem_ExportDiff = E&xport Diff... CTL_PopupMenuItem_ImportDiff = Im&port Patches... CTL_PopupMenuItem_Ignore = &Toggle Ignore +CTL_PopupMenuItem_ShowOut = Sho&w Out CTL_PopupMenuItem_FetchLocal = &Fetch CTL_PopupMenuItem_PushOther = Pu&sh Other... CTL_PopupMenuItem_PushLocal = Push &to - default diff -r d28df42b4215 -r 75a6068f4198 mercurial/src/org/netbeans/modules/mercurial/MercurialAnnotator.java --- a/mercurial/src/org/netbeans/modules/mercurial/MercurialAnnotator.java Wed Jan 30 22:50:40 2008 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/MercurialAnnotator.java Thu Jan 31 00:51:11 2008 +0000 @@ -70,6 +70,7 @@ import org.netbeans.modules.mercurial.ui import org.netbeans.modules.mercurial.ui.diff.ImportDiffAction; import org.netbeans.modules.mercurial.ui.ignore.IgnoreAction; import org.netbeans.modules.mercurial.ui.log.LogAction; +import org.netbeans.modules.mercurial.ui.log.OutAction; import org.netbeans.modules.mercurial.ui.merge.MergeAction; import org.netbeans.modules.mercurial.ui.properties.PropertiesAction; import org.netbeans.modules.mercurial.ui.pull.FetchAction; @@ -358,13 +359,15 @@ public class MercurialAnnotator extends root.getName()), ctx)); } actions.add(new CloneExternalAction(loc.getString("CTL_PopupMenuItem_CloneOther"), ctx)); // NOI18N + actions.add(null); + actions.add(new OutAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_ShowOut"), ctx)); // NOI18N + actions.add(new FetchAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_FetchLocal"), ctx)); // NOI18N + actions.add(null); actions.add(new PushAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_PushLocal"), ctx)); // NOI18N actions.add(new PushOtherAction(loc.getString("CTL_PopupMenuItem_PushOther"), ctx)); // NOI18N actions.add(new PullAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_PullLocal"), ctx)); // NOI18N actions.add(new PullOtherAction(loc.getString("CTL_PopupMenuItem_PullOther"), ctx)); // NOI18N actions.add(new MergeAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_Merge"), ctx)); // NOI18N - actions.add(null); - actions.add(new FetchAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_FetchLocal"), ctx)); // NOI18N actions.add(null); AnnotateAction tempA = new AnnotateAction(loc.getString("CTL_PopupMenuItem_ShowAnnotations"), ctx); // NOI18N if (tempA.visible(nodes)) { @@ -395,15 +398,17 @@ public class MercurialAnnotator extends root.getName()), ctx)); } + actions.add(null); + actions.add(new OutAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_ShowOut"), ctx)); // NOI18N + actions.add(new FetchAction(NbBundle.getMessage(MercurialAnnotator.class, + "CTL_PopupMenuItem_FetchLocal"), ctx)); // NOI18N + actions.add(null); actions.add(new PushAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_PushLocal"), ctx)); // NOI18N actions.add(new PullAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_PullLocal"), ctx)); // NOI18N actions.add(new MergeAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_Merge"), ctx)); // NOI18N - actions.add(null); - actions.add(new FetchAction(NbBundle.getMessage(MercurialAnnotator.class, - "CTL_PopupMenuItem_FetchLocal"), ctx)); // NOI18N actions.add(null); if (!onlyFolders) { diff -r d28df42b4215 -r 75a6068f4198 mercurial/src/org/netbeans/modules/mercurial/ui/log/Bundle.properties --- a/mercurial/src/org/netbeans/modules/mercurial/ui/log/Bundle.properties Wed Jan 30 22:50:40 2008 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/log/Bundle.properties Thu Jan 31 00:51:11 2008 +0000 @@ -37,6 +37,8 @@ # Version 2 license, then the option applies only if the new code is # made subject to such option by the copyright holder. + +MSG_Out_TabTitle = Mercurial Out - {0} MSG_Log_Progress=Showing History... MSG_Log_TabTitle = Mercurial History - {0} @@ -85,7 +87,7 @@ MSG_SymlinkWarning2 = See {0} how to wor MSG_SymlinkWarning2 = See {0} how to work around this problem. LBL_SearchHistory_Searching = -LBL_SearchHistory_NoResults = +LBL_SearchHistory_NoResults = ACSN_SummaryView_List = List of found commits ACSD_SummaryView_List = Flat list of found commits sorted by file name and revision number. @@ -141,7 +143,7 @@ ACSD_PrevDifference=Go To Previous Diffe MSG_Search_PleaseWait=Please wait... MSG_Search_ResolvingTagProgress=Resolving tag URL... -MSG_Search_Progress=Searching History... +MSG_Search_Progress=Searching... MSG_Revert_Progress=Reverting... MSG_Rollback_Progress=Rolling Back... LBL_NumberOfChangedPaths = \ ({0} changes) diff -r d28df42b4215 -r 75a6068f4198 mercurial/src/org/netbeans/modules/mercurial/ui/log/LogAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/log/LogAction.java Wed Jan 30 22:50:40 2008 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/log/LogAction.java Thu Jan 31 00:51:11 2008 +0000 @@ -42,7 +42,6 @@ package org.netbeans.modules.mercurial.u import org.netbeans.modules.mercurial.Mercurial; import org.netbeans.modules.mercurial.util.HgUtils; -import org.netbeans.modules.mercurial.util.HgRepositoryContextCache; import org.netbeans.modules.versioning.spi.VCSContext; import javax.swing.*; import java.awt.event.ActionEvent; diff -r d28df42b4215 -r 75a6068f4198 mercurial/src/org/netbeans/modules/mercurial/ui/log/OutAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/log/OutAction.java Thu Jan 31 00:51:11 2008 +0000 @@ -0,0 +1,74 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ +package org.netbeans.modules.mercurial.ui.log; + +import org.netbeans.modules.mercurial.Mercurial; +import org.netbeans.modules.mercurial.util.HgUtils; +import org.netbeans.modules.versioning.spi.VCSContext; +import javax.swing.*; +import java.awt.event.ActionEvent; +import org.openide.util.NbBundle; + +/** + * Log action for mercurial: + * hg log - show revision history of entire repository or files + * + * @author John Rice + */ +public class OutAction extends AbstractAction { + + private final VCSContext context; + + public OutAction(String name, VCSContext context) { + this.context = context; + putValue(Action.NAME, name); + } + + public void actionPerformed(ActionEvent e) { + if(!Mercurial.getInstance().isGoodVersionAndNotify()) return; + SearchHistoryAction.openOut(context, + NbBundle.getMessage(OutAction.class, "MSG_Out_TabTitle", org.netbeans.modules.versioning.util.Utils.getContextDisplayName(context))); + } + + public boolean isEnabled() { + return HgUtils.getRootFile(context) != null; + } +} diff -r d28df42b4215 -r 75a6068f4198 mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchExecutor.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchExecutor.java Wed Jan 30 22:50:40 2008 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchExecutor.java Thu Jan 31 00:51:11 2008 +0000 @@ -134,8 +134,18 @@ class SearchExecutor implements Runnable } private void search(String rootUrl, Set files, String fromRevision, String toRevision, HgProgressSupport progressSupport) { - HgLogMessage[] messages = HgCommand.getLogMessages(rootUrl, files, fromRevision, toRevision); - appendResults(rootUrl, messages); + if (progressSupport.isCanceled()) { + searchCanceled = true; + return; + } + + HgLogMessage[] messages; + if (master.isOutSearch()) { + messages = HgCommand.getOutMessages(rootUrl); + } else { + messages = HgCommand.getLogMessages(rootUrl, files, fromRevision, toRevision); + } + appendResults(rootUrl, messages); } @@ -178,6 +188,8 @@ class SearchExecutor implements Runnable } results.add(rev); } + if(results.isEmpty()) results = null; + checkFinished(); } diff -r d28df42b4215 -r 75a6068f4198 mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchHistoryAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchHistoryAction.java Wed Jan 30 22:50:40 2008 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchHistoryAction.java Thu Jan 31 00:51:11 2008 +0000 @@ -104,6 +104,26 @@ public class SearchHistoryAction extends } }); } + /** + * Opens the Seach History panel to view Mercurial Out Changesets that will be sent on next Push to remote repo + * using: hg out - to get the data + * + * @param title title of the search + * @param commitMessage commit message to search for + * @param username user name to search for + * @param date date of the change in question + */ + public static void openOut(final VCSContext context, final String title) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + SearchHistoryTopComponent tc = new SearchHistoryTopComponent(context); + tc.setDisplayName(title); + tc.open(); + tc.requestActive(); + tc.searchOut(); + } + }); + } /** * Opens the Seach History panel with given pre-filled values. The search is executed in default context diff -r d28df42b4215 -r 75a6068f4198 mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchHistoryPanel.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchHistoryPanel.java Wed Jan 30 22:50:40 2008 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchHistoryPanel.java Thu Jan 31 00:51:11 2008 +0000 @@ -85,12 +85,13 @@ class SearchHistoryPanel extends javax.s private List results; private SummaryView summaryView; private DiffResultsView diffView; - + private boolean bOutSearch; private AbstractAction nextAction; private AbstractAction prevAction; /** Creates new form SearchHistoryPanel */ public SearchHistoryPanel(File [] roots, SearchCriteriaPanel criteria) { + this.bOutSearch = false; this.roots = roots; this.repositoryUrl = null; this.criteria = criteria; @@ -102,6 +103,7 @@ class SearchHistoryPanel extends javax.s } public SearchHistoryPanel(String repositoryUrl, File localRoot, SearchCriteriaPanel criteria) { + this.bOutSearch = false; this.repositoryUrl = repositoryUrl; this.roots = new File[] { localRoot }; this.criteria = criteria; @@ -110,6 +112,15 @@ class SearchHistoryPanel extends javax.s initComponents(); setupComponents(); refreshComponents(true); + } + + void setOutSearch() { + bOutSearch = true; + divider.setVisible(false); + } + + boolean isOutSearch() { + return bOutSearch; } void setSearchCriteria(boolean b) { diff -r d28df42b4215 -r 75a6068f4198 mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchHistoryTopComponent.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchHistoryTopComponent.java Wed Jan 30 22:50:40 2008 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchHistoryTopComponent.java Thu Jan 31 00:51:11 2008 +0000 @@ -82,6 +82,12 @@ public class SearchHistoryTopComponent e shp.setSearchCriteria(false); } + public void searchOut() { + shp.setOutSearch(); + shp.executeSearch(); + shp.setSearchCriteria(false); + } + private void initComponents(String repositoryUrl, File localRoot, long revision) { setLayout(new BorderLayout()); SearchCriteriaPanel scp = new SearchCriteriaPanel(repositoryUrl); diff -r d28df42b4215 -r 75a6068f4198 mercurial/src/org/netbeans/modules/mercurial/util/HgCommand.java --- a/mercurial/src/org/netbeans/modules/mercurial/util/HgCommand.java Wed Jan 30 22:50:40 2008 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/util/HgCommand.java Thu Jan 31 00:51:11 2008 +0000 @@ -133,6 +133,7 @@ public class HgCommand { private static final String HG_REMOVE_FLAG_FORCE_CMD = "--force"; // NOI18N private static final String HG_LOG_CMD = "log"; // NOI18N + private static final String HG_OUT_CMD = "out"; // NOI18N private static final String HG_LOG_LIMIT_ONE_CMD = "-l 1"; // NOI18N private static final String HG_LOG_LIMIT_CMD = "-l"; // NOI18N private static final String HG_LOG_TEMPLATE_SHORT_CMD = "--template={rev}\\n{desc|firstline}\\n{date|hgdate}\\n{node|short}\\n"; // NOI18N @@ -621,11 +622,68 @@ public class HgCommand { } return list; } + + private static List processLogMessages(List list, final List messages) { + String rev, author, desc, date, id, fm, fa, fd, fc; + if (list != null && !list.isEmpty()) { + rev = author = desc = date = id = fm = fa = fd = fc = null; + boolean bEnd = false; + for (String s : list) { + if (s.indexOf(HG_LOG_REVISION_OUT) == 0) { + rev = s.substring(HG_LOG_REVISION_OUT.length()).trim(); + } else if (s.indexOf(HG_LOG_AUTHOR_OUT) == 0) { + author = s.substring(HG_LOG_AUTHOR_OUT.length()).trim(); + } else if (s.indexOf(HG_LOG_DESCRIPTION_OUT) == 0) { + desc = s.substring(HG_LOG_DESCRIPTION_OUT.length()).trim(); + } else if (s.indexOf(HG_LOG_DATE_OUT) == 0) { + date = s.substring(HG_LOG_DATE_OUT.length()).trim(); + } else if (s.indexOf(HG_LOG_ID_OUT) == 0) { + id = s.substring(HG_LOG_ID_OUT.length()).trim(); + } else if (s.indexOf(HG_LOG_FILEMODS_OUT) == 0) { + fm = s.substring(HG_LOG_FILEMODS_OUT.length()).trim(); + } else if (s.indexOf(HG_LOG_FILEADDS_OUT) == 0) { + fa = s.substring(HG_LOG_FILEADDS_OUT.length()).trim(); + } else if (s.indexOf(HG_LOG_FILEDELS_OUT) == 0) { + fd = s.substring(HG_LOG_FILEDELS_OUT.length()).trim(); + } else if (s.indexOf(HG_LOG_FILECOPIESS_OUT) == 0) { + fc = s.substring(HG_LOG_FILECOPIESS_OUT.length()).trim(); + } else if (s.indexOf(HG_LOG_ENDCS_OUT) == 0) { + bEnd = true; + } else { + // Ignore all other lines + } + if (rev != null & bEnd) { + messages.add(new HgLogMessage(rev, author, desc, date, id, fm, fa, fd, fc)); + rev = author = desc = date = id = fm = fa = fd = fc = null; + bEnd = false; + } + } + } + return messages; + } + + public static HgLogMessage[] getOutMessages(final String rootUrl) { + final List messages = new ArrayList(0); + final File root = new File(rootUrl); + + try { + + List list = new LinkedList(); + list = HgCommand.doOut(root); + processLogMessages(list, messages); + + } catch (HgException ex) { + NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); + DialogDisplayer.getDefault().notifyLater(e); + } + + return messages.toArray(new HgLogMessage[0]); + } + public static HgLogMessage[] getLogMessages(final String rootUrl, final Set files, String fromRevision, String toRevision) { final List messages = new ArrayList(0); final File root = new File(rootUrl); - String rev, author, desc, date, id, fm, fa, fd, fc; try { String headRev = HgCommand.getLastRevision(root, null); @@ -637,42 +695,8 @@ public class HgCommand { list = HgCommand.doLogForHistory(root, files != null ? new ArrayList(files) : null, fromRevision, toRevision, headRev); - - if (list != null && !list.isEmpty()) { - rev = author = desc = date = id = fm = fa = fd = fc = null; - boolean bEnd = false; - for (String s : list) { - if (s.indexOf(HG_LOG_REVISION_OUT) == 0) { - rev = s.substring(HG_LOG_REVISION_OUT.length()).trim(); - } else if (s.indexOf(HG_LOG_AUTHOR_OUT) == 0) { - author = s.substring(HG_LOG_AUTHOR_OUT.length()).trim(); - } else if (s.indexOf(HG_LOG_DESCRIPTION_OUT) == 0) { - desc = s.substring(HG_LOG_DESCRIPTION_OUT.length()).trim(); - } else if (s.indexOf(HG_LOG_DATE_OUT) == 0) { - date = s.substring(HG_LOG_DATE_OUT.length()).trim(); - } else if (s.indexOf(HG_LOG_ID_OUT) == 0) { - id = s.substring(HG_LOG_ID_OUT.length()).trim(); - } else if (s.indexOf(HG_LOG_FILEMODS_OUT) == 0) { - fm = s.substring(HG_LOG_FILEMODS_OUT.length()).trim(); - } else if (s.indexOf(HG_LOG_FILEADDS_OUT) == 0) { - fa = s.substring(HG_LOG_FILEADDS_OUT.length()).trim(); - } else if (s.indexOf(HG_LOG_FILEDELS_OUT) == 0) { - fd = s.substring(HG_LOG_FILEDELS_OUT.length()).trim(); - } else if (s.indexOf(HG_LOG_FILECOPIESS_OUT) == 0) { - fc = s.substring(HG_LOG_FILECOPIESS_OUT.length()).trim(); - } else if (s.indexOf(HG_LOG_ENDCS_OUT) == 0) { - bEnd = true; - } else { - // Ignore empty lines - } - - if (rev != null & bEnd) { - messages.add(new HgLogMessage(rev, author, desc, date, id, fm, fa, fd, fc)); - rev = author = desc = date = id = fm = fa = fd = fc = null; - bEnd = false; - } - } - } + processLogMessages(list, messages); + } catch (HgException ex) { NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); DialogDisplayer.getDefault().notifyLater(e); @@ -951,6 +975,37 @@ public class HgCommand { command.add(f.getAbsolutePath()); } } + List list = exec(command); + if (!list.isEmpty()) { + if (isErrorNoRepository(list.get(0))) { + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); + } else if (isErrorAbort(list.get(0))) { + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); + } + } + return list; + } + + /** + * Retrives the Out information for the specified repository + * + * @param File repository of the mercurial repository's root directory + * @return List list of the out entries for the specified repo. + * @throws org.netbeans.modules.mercurial.HgException + */ + public static List doOut(File repository) throws HgException { + if (repository == null ) return null; + + List command = new ArrayList(); + + command.add(getHgCommand()); + command.add(HG_OUT_CMD); + command.add(HG_OPT_REPOSITORY); + command.add(repository.getAbsolutePath()); + command.add(HG_LOG_DEBUG_CMD); + + command.add(HG_LOG_TEMPLATE_HISTORY_CMD); + List list = exec(command); if (!list.isEmpty()) { if (isErrorNoRepository(list.get(0))) {