# HG changeset patch # User padraigob@netbeans.org # Date 1203592134 0 # Node ID c1ae42bfee9b56d633a70410d05caaa24f4f4fc7 # Parent c174e5a9390df5aa6a3dcc179b5804d96e28ef52 127182: Use different tabs for different repositories diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/HgProgressSupport.java --- a/mercurial/src/org/netbeans/modules/mercurial/HgProgressSupport.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/HgProgressSupport.java Thu Feb 21 11:08:54 2008 +0000 @@ -63,6 +63,7 @@ public abstract class HgProgressSupport private ProgressHandle progressHandle = null; private String displayName = ""; // NOI18N private String originalDisplayName = ""; // NOI18N + private OutputLogger logger; private String repositoryRoot; private RequestProcessor.Task task; @@ -82,6 +83,7 @@ public abstract class HgProgressSupport public void setRepositoryRoot(String repositoryRoot) { this.repositoryRoot = repositoryRoot; + logger = null; } public void run() { @@ -98,6 +100,7 @@ public abstract class HgProgressSupport Mercurial.LOG.log(Level.FINE, "End - {0}", displayName); // NOI18N } finally { finnishProgress(); + if (logger != null) logger.closeLog(); } } @@ -166,7 +169,13 @@ public abstract class HgProgressSupport getProgressHandle().finish(); } - + public OutputLogger getLogger() { + if (logger == null) { + logger = Mercurial.getInstance().getLogger(repositoryRoot); + } + return logger; + } + public void annotate(HgException ex) { ExceptionHandler eh = new ExceptionHandler(ex); if(isCanceled()) { diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/Mercurial.java --- a/mercurial/src/org/netbeans/modules/mercurial/Mercurial.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/Mercurial.java Thu Feb 21 11:08:54 2008 +0000 @@ -163,22 +163,26 @@ public class Mercurial { NbBundle.getMessage(Mercurial.class, "MSG_VERSION_CONFIRM_QUERY", version), // NOI18N NbBundle.getMessage(Mercurial.class, "MSG_VERSION_CONFIRM"), // NOI18N JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); + OutputLogger logger = getLogger(Mercurial.MERCURIAL_OUTPUT_TAB_TITLE); if (response == JOptionPane.YES_OPTION) { goodVersion = true; prefs.put(HgModuleConfig.PROP_RUN_VERSION, version); - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(Mercurial.class, "MSG_USING_VERSION_MSG", version)); // NOI18N); + logger.outputInRed(NbBundle.getMessage(Mercurial.class, "MSG_USING_VERSION_MSG", version)); // NOI18N); } else { prefs.remove(HgModuleConfig.PROP_RUN_VERSION); - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(Mercurial.class, "MSG_NOT_USING_VERSION_MSG", version)); // NOI18N); + logger.outputInRed(NbBundle.getMessage(Mercurial.class, "MSG_NOT_USING_VERSION_MSG", version)); // NOI18N); } + logger.closeLog(); } else { goodVersion = true; } } else if (version == null) { Preferences prefs = HgModuleConfig.getDefault().getPreferences(); prefs.remove(HgModuleConfig.PROP_RUN_VERSION); - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(Mercurial.class, "MSG_VERSION_NONE_OUTPUT_MSG")); // NOI18N); + OutputLogger logger = getLogger(Mercurial.MERCURIAL_OUTPUT_TAB_TITLE); + logger.outputInRed(NbBundle.getMessage(Mercurial.class, "MSG_VERSION_NONE_OUTPUT_MSG")); // NOI18N); HgUtils.warningDialog(Mercurial.class, "MSG_VERSION_NONE_TITLE", "MSG_VERSION_NONE_MSG");// NOI18N + logger.closeLog(); } } @@ -362,4 +366,13 @@ public class Mercurial { } } + /** + * + * @param repositoryRoot String of Mercurial repository so that logger writes to correct output tab. Can be null + * in which case the logger will not print anything + * @return OutputLogger logger to write to + */ + public OutputLogger getLogger(String repositoryRoot) { + return OutputLogger.getLogger(repositoryRoot); + } } diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/MercurialInterceptor.java --- a/mercurial/src/org/netbeans/modules/mercurial/MercurialInterceptor.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/MercurialInterceptor.java Thu Feb 21 11:08:54 2008 +0000 @@ -129,7 +129,7 @@ public class MercurialInterceptor extend HgProgressSupport support = new HgProgressSupport() { public void perform() { try { - HgCommand.doRemove(root, file); + HgCommand.doRemove(root, file, this.getLogger()); // We need to cache the status of all deleted files Map interestingFiles = HgCommand.getInterestingStatus(root, file); if (!interestingFiles.isEmpty()){ @@ -173,7 +173,7 @@ public class MercurialInterceptor extend HgProgressSupport support = new HgProgressSupport() { public void perform() { try { - HgCommand.doRemove(root, file); + HgCommand.doRemove(root, file, this.getLogger()); cache.refresh(file, FileStatusCache.REPOSITORY_STATUS_UNKNOWN); } catch (HgException ex) { Mercurial.LOG.log(Level.FINE, "fileDeletedImpl(): File: {0} {1}", new Object[] {file.getAbsolutePath(), ex.toString()}); // NOI18N @@ -245,9 +245,10 @@ public class MercurialInterceptor extend srcFile.renameTo(dstFile); Runnable moveImpl = new Runnable() { public void run() { + OutputLogger logger = OutputLogger.getLogger(root.getAbsolutePath()); try { if (dstFile.isDirectory()) { - HgCommand.doRenameAfter(root, srcFile, dstFile); + HgCommand.doRenameAfter(root, srcFile, dstFile, logger); return; } int status = HgCommand.getSingleStatus(root, srcFile.getParent(), srcFile.getName()).getStatus(); @@ -255,13 +256,15 @@ public class MercurialInterceptor extend if (status == FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY || status == FileInformation.STATUS_NOTVERSIONED_EXCLUDED) { } else if (status == FileInformation.STATUS_VERSIONED_ADDEDLOCALLY) { - HgCommand.doRemove(root, srcFile); - HgCommand.doAdd(root, dstFile); + HgCommand.doRemove(root, srcFile, logger); + HgCommand.doAdd(root, dstFile, logger); } else { - HgCommand.doRenameAfter(root, srcFile, dstFile); + HgCommand.doRenameAfter(root, srcFile, dstFile, logger); } } catch (HgException e) { Mercurial.LOG.log(Level.FINE, "Mercurial failed to rename: File: {0} {1}", new Object[] {srcFile.getAbsolutePath(), dstFile.getAbsolutePath()}); // NOI18N + } finally { + logger.closeLog(); } } }; diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/OutputLogger.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/OutputLogger.java Thu Feb 21 11:08:54 2008 +0000 @@ -0,0 +1,258 @@ +/* + * 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; + +import java.io.File; +import java.io.IOException; +import java.util.logging.Level; +import java.util.List; +import java.net.URL; +import org.openide.awt.HtmlBrowser; +import org.openide.util.RequestProcessor; +import org.openide.windows.IOProvider; +import org.openide.windows.InputOutput; +import org.openide.windows.OutputEvent; +import org.openide.windows.OutputWriter; +import org.openide.windows.OutputListener; + +/** + * + * @author Tomas Stupka + */ +public class OutputLogger { + + private InputOutput log; + private boolean ignoreCommand = false; + private String repositoryRootString; + private static final RequestProcessor rp = new RequestProcessor("MercurialOutput", 1); + public static final int MAX_LINES_TO_PRINT = 500; + + private static final String MSG_TOO_MANY_LINES = "The number of output lines is greater than 500; see message log for complete output"; + + + public static OutputLogger getLogger(String repositoryRoot) { + if (repositoryRoot != null) { + return new OutputLogger(repositoryRoot); + } else { + return new NullLogger(); + } + } + + private OutputLogger(String repositoryRoot) { + repositoryRootString = repositoryRoot; + log = IOProvider.getDefault().getIO(repositoryRootString, false); + } + + private OutputLogger() { + } + + public void closeLog() { + rp.post(new Runnable() { + public void run() { + log.getOut().flush(); + log.getOut().close(); + log.getErr().flush(); + log.getErr().close(); + } + }); + } + + public void flushLog() { + rp.post(new Runnable() { + public void run() { + log.getOut().flush(); + log.getErr().flush(); + } + }); + } + + /** + * Print contents of list to OutputLogger's tab + * + * @param list to print out + * + */ + public void output(final List list){ + if( list.isEmpty()) return; + + rp.post(new Runnable() { + public void run() { + log.select(); + OutputWriter out = log.getOut(); + + int lines = list.size(); + if (lines > MAX_LINES_TO_PRINT) { + out.println(list.get(1)); + out.println(list.get(2)); + out.println(list.get(3)); + out.println("..."); + out.println(list.get(list.size() -1)); + out.println(MSG_TOO_MANY_LINES); + for (String s : list){ + Mercurial.LOG.log(Level.WARNING, s); + } + } else { + for (String s : list){ + out.println(s); + } + } + out.flush(); + } + }); + } + + /** + * Print msg to OutputLogger's tab + * + * @param String msg to print out + * + */ + public void output(final String msg){ + if( msg == null) return; + + rp.post(new Runnable() { + public void run() { + log.select(); + + log.getOut().println(msg); + log.getOut().flush(); + } + }); + } + + /** + * Print msg to OutputLogger's tab in Red + * + * @param String msg to print out + * + */ + public void outputInRed(final String msg){ + if( msg == null) return; + + rp.post(new Runnable() { + public void run() { + log.select(); + log.getErr().println(msg); + log.getErr().flush(); + } + }); + } + + /** + * Print URL to OutputLogger's tab as an active Hyperlink + * + * @param String sURL to print out + * + */ + public void outputLink(final String sURL){ + if (sURL == null) return; + + rp.post(new Runnable() { + public void run() { + log.select(); + try { + OutputWriter out = log.getOut(); + + OutputListener listener = new OutputListener() { + public void outputLineAction(OutputEvent ev) { + try { + HtmlBrowser.URLDisplayer.getDefault().showURL(new URL(sURL)); + } catch (IOException ex) { + // Ignore + } + } + public void outputLineSelected(OutputEvent ev) {} + public void outputLineCleared(OutputEvent ev) {} + }; + out.println(sURL, listener, true); + out.flush(); + } catch (IOException ex) { + // Ignore + } + } + }); + } + + /** + * Select and Clear OutputLogger's tab + * + * @param list to print out + * + */ + public void clearOutput(){ + rp.post(new Runnable() { + public void run() { + log.select(); + OutputWriter out = log.getOut(); + + try { + out.reset(); + } catch (IOException ex) { + // Ignore Exception + } + out.flush(); + } + }); + } + + private static class NullLogger extends OutputLogger { + + public void closeLog() { + } + + public void flushLog() { + } + + public void output(List list){ + } + + public void output(String msg){ + } + public void outputInRed(String msg){ + } + public void outputLink(final String sURL){ + } + public void clearOutput(){ + } + } + +} diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/VersionsCache.java --- a/mercurial/src/org/netbeans/modules/mercurial/VersionsCache.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/VersionsCache.java Thu Feb 21 11:08:54 2008 +0000 @@ -75,31 +75,35 @@ public class VersionsCache { public File getFileRevision(File base, String revision) throws IOException { if(revision.equals("-1")) return null; // NOI18N + File repository = Mercurial.getInstance().getTopmostManagedParent(base); + OutputLogger logger = OutputLogger.getLogger(repository.getAbsolutePath()); if (Setup.REVISION_BASE.equals(revision)) { try { File tempFile = File.createTempFile("tmp", "-" + base.getName()); //NOI18N - File repository = Mercurial.getInstance().getTopmostManagedParent(base); - HgCommand.doCat(repository, base, tempFile); + HgCommand.doCat(repository, base, tempFile, logger); if (tempFile.length() == 0) return null; return tempFile; } catch (HgException e) { IOException ioe = new IOException(); ioe.initCause(e); throw ioe; + } finally { + logger.closeLog(); } } else if (Setup.REVISION_CURRENT.equals(revision)) { return base; } else { try { File tempFile = File.createTempFile("tmp", "-" + base.getName()); //NOI18N - File repository = Mercurial.getInstance().getTopmostManagedParent(base); - HgCommand.doCat(repository, base, tempFile, revision); + HgCommand.doCat(repository, base, tempFile, revision, logger); if (tempFile.length() == 0) return null; return tempFile; } catch (HgException e) { IOException ioe = new IOException(); ioe.initCause(e); throw ioe; + } finally { + logger.closeLog(); } } } diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/annotate/AnnotateAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/annotate/AnnotateAction.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/annotate/AnnotateAction.java Thu Feb 21 11:08:54 2008 +0000 @@ -54,6 +54,7 @@ import org.netbeans.modules.mercurial.Hg import org.netbeans.modules.mercurial.HgException; import org.netbeans.modules.mercurial.HgProgressSupport; import org.netbeans.modules.mercurial.Mercurial; +import org.netbeans.modules.mercurial.OutputLogger; import org.netbeans.modules.mercurial.FileStatusCache; import org.netbeans.modules.mercurial.FileInformation; import org.netbeans.modules.mercurial.util.HgUtils; @@ -138,15 +139,16 @@ public class AnnotateAction extends Cont RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(repository); HgProgressSupport support = new HgProgressSupport() { public void perform() { - HgUtils.outputMercurialTabInRed( + OutputLogger logger = getLogger(); + logger.outputInRed( NbBundle.getMessage(AnnotateAction.class, "MSG_ANNOTATE_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(AnnotateAction.class, "MSG_ANNOTATE_TITLE_SEP")); // NOI18N computeAnnotations(repository, file, this, ab); - HgUtils.outputMercurialTab("\t" + file.getAbsolutePath()); // NOI18N - HgUtils.outputMercurialTabInRed( + logger.output("\t" + file.getAbsolutePath()); // NOI18N + logger.outputInRed( NbBundle.getMessage(AnnotateAction.class, "MSG_ANNOTATE_DONE")); // NOI18N } @@ -158,7 +160,7 @@ public class AnnotateAction extends Cont private void computeAnnotations(File repository, File file, HgProgressSupport progress, AnnotationBar ab) { List list = null; try { - list = HgCommand.doAnnotate(repository, file); + list = HgCommand.doAnnotate(repository, file, progress.getLogger()); } catch (HgException ex) { NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); DialogDisplayer.getDefault().notifyLater(e); @@ -170,7 +172,7 @@ public class AnnotateAction extends Cont if (list == null) return; AnnotateLine [] lines = toAnnotateLines(list); try { - list = HgCommand.doLogShort(repository, file); + list = HgCommand.doLogShort(repository, file, progress.getLogger()); } catch (HgException ex) { NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); DialogDisplayer.getDefault().notifyLater(e); diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/annotate/AnnotationBar.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/annotate/AnnotationBar.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/annotate/AnnotationBar.java Thu Feb 21 11:08:54 2008 +0000 @@ -433,7 +433,7 @@ final class AnnotationBar extends JCompo RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(root); HgProgressSupport support = new HgProgressSupport() { public void perform() { - RevertModificationsAction.performRevert(root, revStr, file, doBackup); + RevertModificationsAction.performRevert(root, revStr, file, doBackup, this.getLogger()); } }; support.start(rp, root.getAbsolutePath(), NbBundle.getMessage(AnnotationBar.class, "MSG_Revert_Progress")); // NOI18N diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/clone/CloneAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/clone/CloneAction.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/clone/CloneAction.java Thu Feb 21 11:08:54 2008 +0000 @@ -55,6 +55,7 @@ import org.netbeans.modules.mercurial.Hg import org.netbeans.modules.mercurial.HgException; import org.netbeans.modules.mercurial.HgProgressSupport; import org.netbeans.modules.mercurial.Mercurial; +import org.netbeans.modules.mercurial.OutputLogger; import org.netbeans.modules.mercurial.HgModuleConfig; import org.netbeans.modules.mercurial.config.HgConfigFiles; import org.netbeans.modules.mercurial.util.HgCommand; @@ -144,6 +145,7 @@ public class CloneAction extends Context Runnable doOpenProject = new Runnable () { public void run() { // Open and set focus on the cloned project if possible + OutputLogger logger = getLogger(); try { FileObject cloneProj = FileUtil.toFileObject(clonePrjFile); Project prj = null; @@ -154,7 +156,7 @@ public class CloneAction extends Context hg.versionedFilesChanged(); hg.refreshAllAnnotations(); }else{ - HgUtils.outputMercurialTabInRed( NbBundle.getMessage(CloneAction.class, + logger.outputInRed( NbBundle.getMessage(CloneAction.class, "MSG_EXTERNAL_CLONE_PRJ_NOT_FOUND_CANT_SETASMAIN")); // NOI18N } @@ -162,43 +164,44 @@ public class CloneAction extends Context NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(new HgException(ex.toString())); DialogDisplayer.getDefault().notifyLater(e); } finally{ - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(CloneAction.class, "MSG_CLONE_DONE")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.outputInRed(NbBundle.getMessage(CloneAction.class, "MSG_CLONE_DONE")); // NOI18N + logger.output(""); // NOI18N } } }; public void perform() { + OutputLogger logger = getLogger(); try { // TODO: We need to annotate the cloned project // See http://qa.netbeans.org/issues/show_bug.cgi?id=112870 - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(CloneAction.class, "MSG_CLONE_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(CloneAction.class, "MSG_CLONE_TITLE_SEP")); // NOI18N - List list = HgCommand.doClone(source, target); + List list = HgCommand.doClone(source, target, logger); if(list != null && !list.isEmpty()){ HgUtils.createIgnored(cloneFolder); - HgUtils.outputMercurialTab(list); + logger.output(list); if (prjName != null) { - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(CloneAction.class, "MSG_CLONE_FROM", prjName, source)); // NOI18N - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(CloneAction.class, "MSG_CLONE_TO", prjName, target)); // NOI18N } else { - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(CloneAction.class, "MSG_EXTERNAL_CLONE_FROM", source)); // NOI18N - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(CloneAction.class, "MSG_EXTERNAL_CLONE_TO", target)); // NOI18N } - HgUtils.outputMercurialTab(""); // NOI18N + logger.output(""); // NOI18N if (isLocalClone){ SwingUtilities.invokeLater(doOpenProject); @@ -231,8 +234,8 @@ public class CloneAction extends Context fixLocalPullPushPathsOnWindows(cloneFolder.getAbsolutePath(), defaultPull, defaultPush); } if(!isLocalClone){ - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(CloneAction.class, "MSG_CLONE_DONE")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.outputInRed(NbBundle.getMessage(CloneAction.class, "MSG_CLONE_DONE")); // NOI18N + logger.output(""); // NOI18N } } } diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/commit/CommitAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/commit/CommitAction.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/commit/CommitAction.java Thu Feb 21 11:08:54 2008 +0000 @@ -46,6 +46,7 @@ import org.netbeans.modules.versioning.s import org.netbeans.modules.versioning.spi.VCSContext; import org.netbeans.modules.versioning.util.Utils; import org.netbeans.modules.mercurial.Mercurial; +import org.netbeans.modules.mercurial.OutputLogger; import org.netbeans.modules.mercurial.FileStatusCache; import org.netbeans.modules.mercurial.FileInformation; import org.netbeans.modules.mercurial.HgFileNode; @@ -105,11 +106,13 @@ public class CommitAction extends Contex public void performAction(ActionEvent e) { final File root = HgUtils.getRootFile(context); if (root == null) { - HgUtils.outputMercurialTabInRed( NbBundle.getMessage(CommitAction.class,"MSG_COMMIT_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( NbBundle.getMessage(CommitAction.class,"MSG_COMMIT_TITLE_SEP")); // NOI18N - HgUtils.outputMercurialTabInRed( + OutputLogger logger = OutputLogger.getLogger(Mercurial.MERCURIAL_OUTPUT_TAB_TITLE); + logger.outputInRed( NbBundle.getMessage(CommitAction.class,"MSG_COMMIT_TITLE")); // NOI18N + logger.outputInRed( NbBundle.getMessage(CommitAction.class,"MSG_COMMIT_TITLE_SEP")); // NOI18N + logger.outputInRed( NbBundle.getMessage(CommitAction.class, "MSG_COMMIT_NOT_SUPPORTED_INVIEW_INFO")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.output(""); // NOI18N + logger.closeLog(); JOptionPane.showMessageDialog(null, NbBundle.getMessage(CommitAction.class, "MSG_COMMIT_NOT_SUPPORTED_INVIEW"),// NOI18N NbBundle.getMessage(CommitAction.class, "MSG_COMMIT_NOT_SUPPORTED_INVIEW_TITLE"),// NOI18N @@ -230,7 +233,8 @@ public class CommitAction extends Contex RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(repository.getAbsolutePath()); HgProgressSupport support = new HgProgressSupport() { public void perform() { - performCommit(message, commitFiles, ctx, this, prjName); + OutputLogger logger = getLogger(); + performCommit(message, commitFiles, ctx, this, prjName, logger); } }; support.start(rp, repository.getAbsolutePath(), org.openide.util.NbBundle.getMessage(CommitAction.class, "LBL_Commit_Progress")); // NOI18N @@ -314,7 +318,7 @@ public class CommitAction extends Contex } private static void performCommit(String message, Map commitFiles, - VCSContext ctx, HgProgressSupport support, String prjName) { + VCSContext ctx, HgProgressSupport support, String prjName, OutputLogger logger) { FileStatusCache cache = Mercurial.getInstance().getFileStatusCache(); final File repository = HgUtils.getRootFile(ctx); List addCandidates = new ArrayList(); @@ -351,41 +355,41 @@ public class CommitAction extends Contex } try { - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(CommitAction.class, "MSG_COMMIT_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(CommitAction.class, "MSG_COMMIT_TITLE_SEP")); // NOI18N - HgUtils.outputMercurialTab(message); // NOI18N + logger.output(message); // NOI18N if (addCandidates.size() > 0 ) { - HgCommand.doAdd(repository, addCandidates); + HgCommand.doAdd(repository, addCandidates, logger); for (File f : addCandidates) { - HgUtils.outputMercurialTab("hg add " + f.getName()); //NOI18N + logger.output("hg add " + f.getName()); //NOI18N } } - HgCommand.doCommit(repository, commitCandidates, message); + HgCommand.doCommit(repository, commitCandidates, message, logger); HgRepositoryContextCache.setHasHistory(ctx); if (commitCandidates.size() == 1) { - HgUtils.outputMercurialTab( + logger.output( NbBundle.getMessage(CommitAction.class, "MSG_COMMIT_INIT_SEP_ONE", commitCandidates.size(), prjName)); // NOI18N } else { - HgUtils.outputMercurialTab( + logger.output( NbBundle.getMessage(CommitAction.class, "MSG_COMMIT_INIT_SEP", commitCandidates.size(), prjName)); // NOI18N } for (File f : commitCandidates) { - HgUtils.outputMercurialTab("\t" + f.getAbsolutePath()); // NOI18N + logger.output("\t" + f.getAbsolutePath()); // NOI18N } } catch (HgException ex) { NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); DialogDisplayer.getDefault().notifyLater(e); } finally { cache.refreshCached(ctx); - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(CommitAction.class, "MSG_COMMIT_DONE")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.outputInRed(NbBundle.getMessage(CommitAction.class, "MSG_COMMIT_DONE")); // NOI18N + logger.output(""); // NOI18N } } } diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/create/CreateAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/create/CreateAction.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/create/CreateAction.java Thu Feb 21 11:08:54 2008 +0000 @@ -45,6 +45,7 @@ import java.util.logging.Level; import java.util.logging.Level; import org.netbeans.modules.mercurial.HgException; import org.netbeans.modules.mercurial.Mercurial; +import org.netbeans.modules.mercurial.OutputLogger; import org.netbeans.modules.mercurial.util.HgUtils; import org.netbeans.modules.versioning.spi.VCSContext; import org.netbeans.modules.versioning.util.Utils; @@ -149,15 +150,17 @@ public class CreateAction extends Contex File projFile = HgUtils.getProjectFile(proj); if (projFile == null) { - HgUtils.outputMercurialTabInRed( NbBundle.getMessage(CreateAction.class,"MSG_CREATE_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( NbBundle.getMessage(CreateAction.class,"MSG_CREATE_TITLE_SEP")); // NOI18N - HgUtils.outputMercurialTabInRed( + OutputLogger logger = OutputLogger.getLogger(Mercurial.MERCURIAL_OUTPUT_TAB_TITLE); + logger.outputInRed( NbBundle.getMessage(CreateAction.class,"MSG_CREATE_TITLE")); // NOI18N + logger.outputInRed( NbBundle.getMessage(CreateAction.class,"MSG_CREATE_TITLE_SEP")); // NOI18N + logger.outputInRed( NbBundle.getMessage(CreateAction.class, "MSG_CREATE_NOT_SUPPORTED_INVIEW_INFO")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.output(""); // NOI18N JOptionPane.showMessageDialog(null, NbBundle.getMessage(CreateAction.class, "MSG_CREATE_NOT_SUPPORTED_INVIEW"),// NOI18N NbBundle.getMessage(CreateAction.class, "MSG_CREATE_NOT_SUPPORTED_INVIEW_TITLE"),// NOI18N JOptionPane.INFORMATION_MESSAGE); + logger.closeLog(); return; } String projName = HgProjectUtils.getProjectName(projFile); @@ -166,13 +169,6 @@ public class CreateAction extends Contex root = getCommonAncestor(files); root = getCommonAncestor(root, projFile); if (root == null) return; - - HgUtils.outputMercurialTabInRed( - NbBundle.getMessage(CreateAction.class, - "MSG_CREATE_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( - NbBundle.getMessage(CreateAction.class, - "MSG_CREATE_TITLE_SEP")); // NOI18N final File rootToManage = root; final String prjName = projName; @@ -183,10 +179,18 @@ public class CreateAction extends Contex public void perform() { try { - HgUtils.outputMercurialTab( + OutputLogger logger = getLogger(); + logger.outputInRed( + NbBundle.getMessage(CreateAction.class, + "MSG_CREATE_TITLE")); // NOI18N + logger.outputInRed( + NbBundle.getMessage(CreateAction.class, + "MSG_CREATE_TITLE_SEP")); // NOI18N + + logger.output( NbBundle.getMessage(CreateAction.class, "MSG_CREATE_INIT", prjName, rootToManage)); // NOI18N - HgCommand.doCreate(rootToManage); + HgCommand.doCreate(rootToManage, logger); hg.versionedFilesChanged(); hg.refreshAllAnnotations(); } catch (HgException ex) { @@ -201,6 +205,7 @@ public class CreateAction extends Contex HgProgressSupport supportAdd = new HgProgressSupport() { public void perform() { + OutputLogger logger = getLogger(); try { File[] files = HgUtils.getProjectRootFiles(proj); FileStatusCache cache = hg.getFileStatusCache(); @@ -212,27 +217,27 @@ public class CreateAction extends Contex repositoryFiles = HgCommand.getUnknownStatus(rootToManage, rootFile); Calendar end = Calendar.getInstance(); Mercurial.LOG.log(Level.FINE, "getUnknownStatus took {0} millisecs", end.getTimeInMillis() - start.getTimeInMillis()); // NOI18N - HgUtils.outputMercurialTab( + logger.output( NbBundle.getMessage(CreateAction.class, "MSG_CREATE_ADD", repositoryFiles.keySet().size(), rootFile.getAbsolutePath())); // NOI18N start = Calendar.getInstance(); cache.addToCache(repositoryFiles.keySet()); end = Calendar.getInstance(); Mercurial.LOG.log(Level.FINE, "addUnknownsToCache took {0} millisecs", end.getTimeInMillis() - start.getTimeInMillis()); // NOI18N - if (repositoryFiles.keySet().size() < HgUtils.MAX_LINES_TO_PRINT) { + if (repositoryFiles.keySet().size() < OutputLogger.MAX_LINES_TO_PRINT) { for(File f: repositoryFiles.keySet()){ - HgUtils.outputMercurialTab("\t" + f.getAbsolutePath()); // NOI18N + logger.output("\t" + f.getAbsolutePath()); // NOI18N } } } HgUtils.createIgnored(rootToManage); - HgUtils.outputMercurialTab(""); // NOI18N - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(CreateAction.class, "MSG_CREATE_DONE_WARNING")); // NOI18N + logger.output(""); // NOI18N + logger.outputInRed(NbBundle.getMessage(CreateAction.class, "MSG_CREATE_DONE_WARNING")); // NOI18N } catch (HgException ex) { NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); DialogDisplayer.getDefault().notifyLater(e); } finally { - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(CreateAction.class, "MSG_CREATE_DONE")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.outputInRed(NbBundle.getMessage(CreateAction.class, "MSG_CREATE_DONE")); // NOI18N + logger.output(""); // NOI18N } } }; diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/diff/DiffAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/diff/DiffAction.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/diff/DiffAction.java Thu Feb 21 11:08:54 2008 +0000 @@ -50,6 +50,7 @@ import org.netbeans.modules.mercurial.Fi import org.netbeans.modules.mercurial.FileInformation; import org.netbeans.modules.mercurial.FileStatusCache; import org.netbeans.modules.mercurial.Mercurial; +import org.netbeans.modules.mercurial.OutputLogger; import org.netbeans.modules.mercurial.util.HgUtils; import org.netbeans.modules.mercurial.ui.actions.ContextAction; import org.openide.nodes.Node; @@ -78,11 +79,13 @@ public class DiffAction extends ContextA boolean bNotManaged = (root == null) || ( files == null || files.length == 0); if (bNotManaged) { - HgUtils.outputMercurialTabInRed( NbBundle.getMessage(DiffAction.class,"MSG_DIFF_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( NbBundle.getMessage(DiffAction.class,"MSG_DIFF_TITLE_SEP")); // NOI18N - HgUtils.outputMercurialTabInRed( + OutputLogger logger = OutputLogger.getLogger(Mercurial.MERCURIAL_OUTPUT_TAB_TITLE); + logger.outputInRed( NbBundle.getMessage(DiffAction.class,"MSG_DIFF_TITLE")); // NOI18N + logger.outputInRed( NbBundle.getMessage(DiffAction.class,"MSG_DIFF_TITLE_SEP")); // NOI18N + logger.outputInRed( NbBundle.getMessage(DiffAction.class, "MSG_DIFF_NOT_SUPPORTED_INVIEW_INFO")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.output(""); // NOI18N + logger.closeLog(); JOptionPane.showMessageDialog(null, NbBundle.getMessage(DiffAction.class, "MSG_DIFF_NOT_SUPPORTED_INVIEW"),// NOI18N NbBundle.getMessage(DiffAction.class, "MSG_DIFF_NOT_SUPPORTED_INVIEW_TITLE"),// NOI18N diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/diff/ExportDiffAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/diff/ExportDiffAction.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/diff/ExportDiffAction.java Thu Feb 21 11:08:54 2008 +0000 @@ -50,6 +50,7 @@ import org.netbeans.modules.mercurial.Hg import org.netbeans.modules.mercurial.HgException; import org.netbeans.modules.mercurial.HgProgressSupport; import org.netbeans.modules.mercurial.Mercurial; +import org.netbeans.modules.mercurial.OutputLogger; import org.netbeans.modules.mercurial.HgModuleConfig; import org.netbeans.modules.mercurial.util.HgUtils; import org.netbeans.modules.mercurial.util.HgCommand; @@ -104,29 +105,30 @@ public class ExportDiffAction extends Co RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(root.getAbsolutePath()); HgProgressSupport support = new HgProgressSupport() { public void perform() { - performExport(root, revStr, outputFileName); + OutputLogger logger = getLogger(); + performExport(root, revStr, outputFileName, logger); } }; support.start(rp, root.getAbsolutePath(), org.openide.util.NbBundle.getMessage(ExportDiffAction.class, "LBL_ExportDiff_Progress")); // NOI18N } - private static void performExport(File repository, String revStr, String outputFileName) { + private static void performExport(File repository, String revStr, String outputFileName, OutputLogger logger) { try { - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(ExportDiffAction.class, "MSG_EXPORT_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(ExportDiffAction.class, "MSG_EXPORT_TITLE_SEP")); // NOI18N if (NbBundle.getMessage(ExportDiffAction.class, "MSG_Revision_Default").startsWith(revStr)) { - HgUtils.outputMercurialTab( + logger.output( NbBundle.getMessage(ExportDiffAction.class, "MSG_EXPORT_NOTHING")); // NOI18N } else { - List list = HgCommand.doExport(repository, revStr, outputFileName); - HgUtils.outputMercurialTab(list); // NOI18N + List list = HgCommand.doExport(repository, revStr, outputFileName, logger); + logger.output(list); // NOI18N if (!list.isEmpty() && list.size() > 1) { File outFile = new File(list.get(1)); if (outFile != null && outFile.canRead()) { @@ -138,8 +140,8 @@ public class ExportDiffAction extends Co NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); DialogDisplayer.getDefault().notifyLater(e); } finally { - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(ExportDiffAction.class, "MSG_EXPORT_DONE")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.outputInRed(NbBundle.getMessage(ExportDiffAction.class, "MSG_EXPORT_DONE")); // NOI18N + logger.output(""); // NOI18N } } } diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/diff/ImportDiffAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/diff/ImportDiffAction.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/diff/ImportDiffAction.java Thu Feb 21 11:08:54 2008 +0000 @@ -50,6 +50,7 @@ import org.netbeans.modules.mercurial.Hg import org.netbeans.modules.mercurial.HgException; import org.netbeans.modules.mercurial.HgProgressSupport; import org.netbeans.modules.mercurial.Mercurial; +import org.netbeans.modules.mercurial.OutputLogger; import org.netbeans.modules.mercurial.HgModuleConfig; import org.netbeans.modules.mercurial.util.HgUtils; import org.netbeans.modules.mercurial.util.HgRepositoryContextCache; @@ -107,7 +108,8 @@ public class ImportDiffAction extends Co RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(root.getAbsolutePath()); HgProgressSupport support = new HgProgressSupport() { public void perform() { - performImport(root, patchFile); + OutputLogger logger = getLogger(); + performImport(root, patchFile, logger); } }; support.start(rp, root.getAbsolutePath(), org.openide.util.NbBundle.getMessage(ImportDiffAction.class, "LBL_ImportDiff_Progress")); // NOI18N @@ -115,25 +117,25 @@ public class ImportDiffAction extends Co } } - private static void performImport(File repository, File patchFile) { + private static void performImport(File repository, File patchFile, OutputLogger logger) { try { - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(ImportDiffAction.class, "MSG_IMPORT_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(ImportDiffAction.class, "MSG_IMPORT_TITLE_SEP")); // NOI18N - List list = HgCommand.doImport(repository, patchFile); + List list = HgCommand.doImport(repository, patchFile, logger); Mercurial.getInstance().changesetChanged(repository); - HgUtils.outputMercurialTab(list); // NOI18N + logger.output(list); // NOI18N } catch (HgException ex) { NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); DialogDisplayer.getDefault().notifyLater(e); } finally { - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(ImportDiffAction.class, "MSG_IMPORT_DONE")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.outputInRed(NbBundle.getMessage(ImportDiffAction.class, "MSG_IMPORT_DONE")); // NOI18N + logger.output(""); // NOI18N } } } diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/ignore/IgnoreAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/ignore/IgnoreAction.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/ignore/IgnoreAction.java Thu Feb 21 11:08:54 2008 +0000 @@ -134,41 +134,42 @@ public class IgnoreAction extends Contex RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(repository.getAbsolutePath()); HgProgressSupport support = new HgProgressSupport() { public void perform() { + OutputLogger logger = getLogger(); try { mActionStatus = getActionStatus(files); if (mActionStatus == UNDEFINED) { - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(IgnoreAction.class, "MSG_IGNORE_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(IgnoreAction.class, "MSG_IGNORE_TITLE_SEP")); // NOI18N - HgUtils.outputMercurialTab( + logger.output( NbBundle.getMessage(IgnoreAction.class, "MSG_IGNORE_ONLY_LOCALLY_NEW")); // NOI18N - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(IgnoreAction.class, "MSG_IGNORE_DONE")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.output(""); // NOI18N return; } if (mActionStatus == IGNORING) { HgUtils.addIgnored(repository, files); - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(IgnoreAction.class, "MSG_IGNORE_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(IgnoreAction.class, "MSG_IGNORE_TITLE_SEP")); // NOI18N - HgUtils.outputMercurialTab( + logger.output( NbBundle.getMessage(IgnoreAction.class, "MSG_IGNORE_INIT_SEP", repository.getName())); // NOI18N } else { HgUtils.removeIgnored(repository, files); - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(IgnoreAction.class, "MSG_UNIGNORE_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(IgnoreAction.class, "MSG_UNIGNORE_TITLE_SEP")); // NOI18N - HgUtils.outputMercurialTab( + logger.output( NbBundle.getMessage(IgnoreAction.class, "MSG_UNIGNORE_INIT_SEP", repository.getName())); // NOI18N } @@ -179,18 +180,18 @@ public class IgnoreAction extends Contex // refresh files manually for (File file : files) { Mercurial.getInstance().getFileStatusCache().refresh(file, FileStatusCache.REPOSITORY_STATUS_UNKNOWN); - HgUtils.outputMercurialTab("\t" + file.getAbsolutePath()); // NOI18N + logger.output("\t" + file.getAbsolutePath()); // NOI18N } if (mActionStatus == IGNORING) { - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(IgnoreAction.class, "MSG_IGNORE_DONE")); // NOI18N } else { - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(IgnoreAction.class, "MSG_UNIGNORE_DONE")); // NOI18N } - HgUtils.outputMercurialTab(""); // NOI18N + logger.output(""); // NOI18N } }; support.start(rp, repository.getAbsolutePath(), org.openide.util.NbBundle.getMessage(IgnoreAction.class, "LBL_Ignore_Progress")); // NOI18N diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/log/HgLogMessage.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/log/HgLogMessage.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/log/HgLogMessage.java Thu Feb 21 11:08:54 2008 +0000 @@ -46,6 +46,7 @@ import org.netbeans.modules.mercurial.Fi import org.netbeans.modules.mercurial.FileInformation; import org.netbeans.modules.mercurial.FileStatus; import org.netbeans.modules.mercurial.Mercurial; +import org.netbeans.modules.mercurial.OutputLogger; import org.netbeans.modules.mercurial.util.HgUtils; /** @@ -120,8 +121,10 @@ public class HgLogMessage { FileInformation fi = Mercurial.getInstance().getFileStatusCache().getStatus(file); FileStatus fs = fi != null? fi.getStatus(file): null; if (fs != null && fs.isCopied()) { - HgUtils.outputMercurialTabInRed("*** Copied: " + s + " : " + - fs.getFile() != null ? fs.getFile().getAbsolutePath() : "no filepath"); + OutputLogger logger = OutputLogger.getLogger(Mercurial.MERCURIAL_OUTPUT_TAB_TITLE); + + logger.outputInRed("*** Copied: " + s + " : " + fs.getFile() != null ? fs.getFile().getAbsolutePath() : "no filepath"); + logger.closeLog(); } } diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchExecutor.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchExecutor.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchExecutor.java Thu Feb 21 11:08:54 2008 +0000 @@ -49,6 +49,7 @@ import java.io.File; import java.io.File; import org.netbeans.modules.mercurial.HgProgressSupport; import org.netbeans.modules.mercurial.Mercurial; +import org.netbeans.modules.mercurial.OutputLogger; import org.netbeans.modules.mercurial.util.HgCommand; import org.netbeans.modules.mercurial.util.HgUtils; @@ -86,25 +87,26 @@ class SearchExecutor implements Runnable filterUsername = criteria.getUsername() != null; filterMessage = criteria.getCommitMessage() != null; + OutputLogger logger = OutputLogger.getLogger(Mercurial.MERCURIAL_OUTPUT_TAB_TITLE); if (master.isIncomingSearch()) { - HgUtils.outputMercurialTabInRed( NbBundle.getMessage(SearchHistoryAction.class, + logger.outputInRed( NbBundle.getMessage(SearchHistoryAction.class, "MSG_LogIncoming_Title")); // NOI18N }else if (master.isOutSearch()) { - HgUtils.outputMercurialTabInRed( NbBundle.getMessage(SearchHistoryAction.class, + logger.outputInRed( NbBundle.getMessage(SearchHistoryAction.class, "MSG_LogOut_Title")); // NOI18N } else { - HgUtils.outputMercurialTabInRed( NbBundle.getMessage(SearchHistoryAction.class, + logger.outputInRed( NbBundle.getMessage(SearchHistoryAction.class, "MSG_Log_Title")); // NOI18N } - HgUtils.outputMercurialTabInRed( NbBundle.getMessage(SearchHistoryAction.class, + logger.outputInRed( NbBundle.getMessage(SearchHistoryAction.class, "MSG_Log_Title_Sep")); // NOI18N - HgUtils.outputMercurialTab( NbBundle.getMessage(SearchHistoryAction.class, + logger.output( NbBundle.getMessage(SearchHistoryAction.class, "MSG_LOG_EXEC_CONTEXT_SEP")); // NOI18N pathToRoot = new HashMap(); if (searchingUrl()) { String rootPath = Mercurial.getInstance().getTopmostManagedParent(master.getRoots()[0]).toString(); pathToRoot.put(rootPath, master.getRoots()[0]); - HgUtils.outputMercurialTab(rootPath); + logger.output(rootPath); } else { workFiles = new HashMap>(); for (File file : master.getRoots()) { @@ -116,10 +118,10 @@ class SearchExecutor implements Runnable workFiles.put(rootPath, set); } set.add(file); - HgUtils.outputMercurialTab(file.getAbsolutePath()); + logger.output(file.getAbsolutePath()); } } - HgUtils.outputMercurialTab(""); // NOI18N + logger.output(""); // NOI18N } diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchHistoryAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchHistoryAction.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchHistoryAction.java Thu Feb 21 11:08:54 2008 +0000 @@ -49,6 +49,7 @@ import java.io.File; import java.io.File; import java.util.*; import org.netbeans.modules.mercurial.FileInformation; +import org.netbeans.modules.mercurial.OutputLogger; import org.netbeans.modules.mercurial.ui.actions.ContextAction; import org.netbeans.modules.mercurial.util.HgUtils; import org.netbeans.modules.versioning.spi.VCSContext; @@ -94,21 +95,24 @@ public class SearchHistoryAction extends SwingUtilities.invokeLater(new Runnable() { public void run() { if (context == null) return; - HgUtils.outputMercurialTabInRed( + File root = HgUtils.getRootFile(context); + OutputLogger logger = OutputLogger.getLogger(root.getAbsolutePath()); + logger.outputInRed( NbBundle.getMessage(SearchHistoryAction.class, "MSG_Log_Title")); // NOI18N - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(SearchHistoryAction.class, "MSG_Log_Title_Sep")); // NOI18N File[] files = context.getFiles().toArray(new File[0]); - HgUtils.outputMercurialTab( + logger.output( NbBundle.getMessage(SearchHistoryAction.class, "MSG_LOG_CONTEXT_SEP")); // NOI18N for(File f: files){ - HgUtils.outputMercurialTab(f.getAbsolutePath()); + logger.output(f.getAbsolutePath()); } - HgUtils.outputMercurialTabInRed(""); // NOI18N - SearchHistoryTopComponent tc = new SearchHistoryTopComponent(context); + logger.outputInRed(""); // NOI18N + logger.closeLog(); + SearchHistoryTopComponent tc = new SearchHistoryTopComponent(context); tc.setDisplayName(title); tc.open(); tc.requestActive(); diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/log/SummaryView.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/log/SummaryView.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/log/SummaryView.java Thu Feb 21 11:08:54 2008 +0000 @@ -437,7 +437,7 @@ class SummaryView implements MouseListen revertFiles.add(event.getFile()); } RevertModificationsAction.performRevert( - root, revision.getLog().getRevision(), revertFiles, doBackup); + root, revision.getLog().getRevision(), revertFiles, doBackup, progress.getLogger()); revertFiles.clear(); } @@ -467,7 +467,7 @@ class SummaryView implements MouseListen if(revEvents != null && !revEvents.isEmpty()){ // Assuming all files in a given repository reverting to same revision RevertModificationsAction.performRevert( - root, revEvents.get(0).getLogInfoHeader().getLog().getRevision(), revertFiles, doBackup); + root, revEvents.get(0).getLogInfoHeader().getLog().getRevision(), revertFiles, doBackup, progress.getLogger()); } } } diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/merge/MergeAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/merge/MergeAction.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/merge/MergeAction.java Thu Feb 21 11:08:54 2008 +0000 @@ -44,6 +44,7 @@ import java.util.List; import java.util.List; import org.netbeans.modules.mercurial.HgException; import org.netbeans.modules.mercurial.Mercurial; +import org.netbeans.modules.mercurial.OutputLogger; import org.netbeans.modules.versioning.spi.VCSContext; import javax.swing.*; import java.awt.event.ActionEvent; @@ -85,11 +86,13 @@ public class MergeAction extends Context public void performAction(ActionEvent ev) { final File root = HgUtils.getRootFile(context); if (root == null) { - HgUtils.outputMercurialTabInRed( NbBundle.getMessage(MergeAction.class,"MSG_MERGE_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( NbBundle.getMessage(MergeAction.class,"MSG_MERGE_TITLE_SEP")); // NOI18N - HgUtils.outputMercurialTabInRed( + OutputLogger logger = OutputLogger.getLogger(Mercurial.MERCURIAL_OUTPUT_TAB_TITLE); + logger.outputInRed( NbBundle.getMessage(MergeAction.class,"MSG_MERGE_TITLE")); // NOI18N + logger.outputInRed( NbBundle.getMessage(MergeAction.class,"MSG_MERGE_TITLE_SEP")); // NOI18N + logger.outputInRed( NbBundle.getMessage(MergeAction.class, "MSG_MERGE_NOT_SUPPORTED_INVIEW_INFO")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.output(""); // NOI18N + logger.closeLog(); JOptionPane.showMessageDialog(null, NbBundle.getMessage(MergeAction.class, "MSG_MERGE_NOT_SUPPORTED_INVIEW"),// NOI18N NbBundle.getMessage(MergeAction.class, "MSG_MERGE_NOT_SUPPORTED_INVIEW_TITLE"),// NOI18N @@ -100,15 +103,16 @@ public class MergeAction extends Context RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(repository); HgProgressSupport support = new HgProgressSupport() { public void perform() { + OutputLogger logger = getLogger(); try { List headList = HgCommand.getHeadRevisions(root); String revStr = null; if (headList.size() <= 1) { - HgUtils.outputMercurialTabInRed( NbBundle.getMessage(MergeAction.class,"MSG_MERGE_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( NbBundle.getMessage(MergeAction.class,"MSG_MERGE_TITLE_SEP")); // NOI18N - HgUtils.outputMercurialTab( NbBundle.getMessage(MergeAction.class,"MSG_NOTHING_TO_MERGE")); // NOI18N - HgUtils.outputMercurialTabInRed( NbBundle.getMessage(MergeAction.class, "MSG_MERGE_DONE")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.outputInRed( NbBundle.getMessage(MergeAction.class,"MSG_MERGE_TITLE")); // NOI18N + logger.outputInRed( NbBundle.getMessage(MergeAction.class,"MSG_MERGE_TITLE_SEP")); // NOI18N + logger.output( NbBundle.getMessage(MergeAction.class,"MSG_NOTHING_TO_MERGE")); // NOI18N + logger.outputInRed( NbBundle.getMessage(MergeAction.class, "MSG_MERGE_DONE")); // NOI18N + logger.output(""); // NOI18N JOptionPane.showMessageDialog(null, NbBundle.getMessage(MergeAction.class,"MSG_NOTHING_TO_MERGE"),// NOI18N NbBundle.getMessage(MergeAction.class,"MSG_MERGE_TITLE"),// NOI18N @@ -121,13 +125,13 @@ public class MergeAction extends Context } revStr = mergeDlg.getSelectionRevision(); } - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(MergeAction.class, "MSG_MERGE_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(MergeAction.class, "MSG_MERGE_TITLE_SEP")); // NOI18N - doMergeAction(root, revStr); + doMergeAction(root, revStr, logger); HgUtils.forceStatusRefreshProject(context); - HgUtils.outputMercurialTab(""); // NOI18N + logger.output(""); // NOI18N } catch (HgException ex) { NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); DialogDisplayer.getDefault().notifyLater(e); @@ -137,17 +141,17 @@ public class MergeAction extends Context support.start(rp, repository, NbBundle.getMessage(MergeAction.class, "MSG_MERGE_PROGRESS")); // NOI18N } - public static boolean doMergeAction(File root, String revStr) throws HgException { + public static boolean doMergeAction(File root, String revStr, OutputLogger logger) throws HgException { List listMerge = HgCommand.doMerge(root, revStr); Boolean bConflicts = false; Boolean bMergeFailed = false; if (listMerge != null && !listMerge.isEmpty()) { - HgUtils.outputMercurialTab(listMerge); + logger.output(listMerge); for (String line : listMerge) { if (HgCommand.isMergeAbortUncommittedMsg(line)){ bMergeFailed = true; - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(MergeAction.class, + logger.outputInRed(NbBundle.getMessage(MergeAction.class, "MSG_MERGE_FAILED")); // NOI18N JOptionPane.showMessageDialog(null, NbBundle.getMessage(MergeAction.class,"MSG_MERGE_UNCOMMITTED"), // NOI18N @@ -158,7 +162,7 @@ public class MergeAction extends Context if (HgCommand.isMergeAbortMultipleHeadsMsg(line)){ bMergeFailed = true; - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(MergeAction.class, + logger.outputInRed(NbBundle.getMessage(MergeAction.class, "MSG_MERGE_FAILED")); // NOI18N break; } @@ -174,7 +178,7 @@ public class MergeAction extends Context }else{ filepath = line.substring(HgCommand.HG_MERGE_CONFLICT_ERR.length()); } - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(MergeAction.class, "MSG_MERGE_CONFLICT", filepath)); // NOI18N + logger.outputInRed(NbBundle.getMessage(MergeAction.class, "MSG_MERGE_CONFLICT", filepath)); // NOI18N HgCommand.createConflictFile(filepath); } @@ -183,53 +187,37 @@ public class MergeAction extends Context NbBundle.getMessage(MergeAction.class, "MSG_MERGE_UNAVAILABLE"), // NOI18N NbBundle.getMessage(MergeAction.class, "MSG_MERGE_TITLE"), // NOI18N JOptionPane.WARNING_MESSAGE); - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(MergeAction.class, "MSG_MERGE_INFO"));// NOI18N - HgUtils.outputMercurialTabLink( + logger.outputLink( NbBundle.getMessage(MergeAction.class, "MSG_MERGE_INFO_URL")); // NOI18N } } if (bConflicts) { - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(MergeAction.class, + logger.outputInRed(NbBundle.getMessage(MergeAction.class, "MSG_MERGE_DONE_CONFLICTS")); // NOI18N } if (!bMergeFailed && !bConflicts) { - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(MergeAction.class, + logger.outputInRed(NbBundle.getMessage(MergeAction.class, "MSG_MERGE_DONE")); // NOI18N } } return true; } - public static void printMergeWarning(OutputWriter outRed, List list){ + public static void printMergeWarning(List list, OutputLogger logger){ if(list == null || list.isEmpty() || list.size() <= 1) return; if (list.size() == 2) { - outRed.println(NbBundle.getMessage(MergeAction.class, + logger.outputInRed(NbBundle.getMessage(MergeAction.class, "MSG_MERGE_WARN_NEEDED", list)); // NOI18N - outRed.println(NbBundle.getMessage(MergeAction.class, + logger.outputInRed(NbBundle.getMessage(MergeAction.class, "MSG_MERGE_DO_NEEDED")); // NOI18N } else { - outRed.println(NbBundle.getMessage(MergeAction.class, + logger.outputInRed(NbBundle.getMessage(MergeAction.class, "MSG_MERGE_WARN_MULTIPLE_HEADS", list.size(), list)); // NOI18N - outRed.println(NbBundle.getMessage(MergeAction.class, - "MSG_MERGE_DONE_MULTIPLE_HEADS")); // NOI18N - } - } - - public static void printMergeWarning(List list){ - if(list == null || list.isEmpty() || list.size() <= 1) return; - - if (list.size() == 2) { - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(MergeAction.class, - "MSG_MERGE_WARN_NEEDED", list)); // NOI18N - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(MergeAction.class, - "MSG_MERGE_DO_NEEDED")); // NOI18N - } else { - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(MergeAction.class, - "MSG_MERGE_WARN_MULTIPLE_HEADS", list.size(), list)); // NOI18N - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(MergeAction.class, + logger.outputInRed(NbBundle.getMessage(MergeAction.class, "MSG_MERGE_DONE_MULTIPLE_HEADS")); // NOI18N } } diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/pull/FetchAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/pull/FetchAction.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/pull/FetchAction.java Thu Feb 21 11:08:54 2008 +0000 @@ -43,6 +43,7 @@ import org.netbeans.modules.mercurial.ui import org.netbeans.modules.mercurial.ui.view.*; import org.netbeans.modules.versioning.spi.VCSContext; import org.netbeans.modules.mercurial.Mercurial; +import org.netbeans.modules.mercurial.OutputLogger; import org.netbeans.modules.mercurial.HgException; import org.netbeans.modules.mercurial.util.HgCommand; import org.netbeans.modules.mercurial.util.HgUtils; @@ -87,31 +88,32 @@ public class FetchAction extends Context RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(root); HgProgressSupport support = new HgProgressSupport() { - public void perform() { performFetch(root); } }; + OutputLogger logger = getLogger(); + public void perform() { performFetch(root, logger); } }; support.start(rp, root.getAbsolutePath(), org.openide.util.NbBundle.getMessage(FetchAction.class, "MSG_FETCH_PROGRESS")); // NOI18N } - static void performFetch(File root) { + static void performFetch(File root, OutputLogger logger) { try { - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(FetchAction.class, "MSG_FETCH_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(FetchAction.class, "MSG_FETCH_TITLE_SEP")); // NOI18N + logger.outputInRed(NbBundle.getMessage(FetchAction.class, "MSG_FETCH_TITLE")); // NOI18N + logger.outputInRed(NbBundle.getMessage(FetchAction.class, "MSG_FETCH_TITLE_SEP")); // NOI18N - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(FetchAction.class, + logger.outputInRed(NbBundle.getMessage(FetchAction.class, "MSG_FETCH_LAUNCH_INFO", root.getAbsolutePath())); // NOI18N List list; - list = HgCommand.doFetch(root); + list = HgCommand.doFetch(root, logger); if (list != null && !list.isEmpty()) { - HgUtils.outputMercurialTab(HgUtils.replaceHttpPassword(list)); + logger.output(HgUtils.replaceHttpPassword(list)); } } catch (HgException ex) { NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); DialogDisplayer.getDefault().notifyLater(e); }finally{ - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(FetchAction.class, "MSG_FETCH_DONE")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.outputInRed(NbBundle.getMessage(FetchAction.class, "MSG_FETCH_DONE")); // NOI18N + logger.output(""); // NOI18N } } diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/pull/PullAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/pull/PullAction.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/pull/PullAction.java Thu Feb 21 11:08:54 2008 +0000 @@ -53,6 +53,7 @@ import org.netbeans.modules.mercurial.Hg import org.netbeans.modules.mercurial.HgException; import org.netbeans.modules.mercurial.HgProgressSupport; import org.netbeans.modules.mercurial.Mercurial; +import org.netbeans.modules.mercurial.OutputLogger; import org.netbeans.modules.mercurial.ui.merge.MergeAction; import org.netbeans.modules.mercurial.ui.actions.ContextAction; import org.netbeans.modules.mercurial.util.HgCommand; @@ -96,22 +97,24 @@ public class PullAction extends ContextA public void performAction(ActionEvent e) { final File root = HgUtils.getRootFile(context); if (root == null) { - HgUtils.outputMercurialTabInRed( NbBundle.getMessage(PullAction.class,"MSG_PULL_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( NbBundle.getMessage(PullAction.class,"MSG_PULL_TITLE_SEP")); // NOI18N - HgUtils.outputMercurialTabInRed( + OutputLogger logger = OutputLogger.getLogger(Mercurial.MERCURIAL_OUTPUT_TAB_TITLE); + logger.outputInRed( NbBundle.getMessage(PullAction.class,"MSG_PULL_TITLE")); // NOI18N + logger.outputInRed( NbBundle.getMessage(PullAction.class,"MSG_PULL_TITLE_SEP")); // NOI18N + logger.outputInRed( NbBundle.getMessage(PullAction.class, "MSG_PULL_NOT_SUPPORTED_INVIEW_INFO")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.output(""); // NOI18N JOptionPane.showMessageDialog(null, NbBundle.getMessage(PullAction.class, "MSG_PULL_NOT_SUPPORTED_INVIEW"),// NOI18N NbBundle.getMessage(PullAction.class, "MSG_PULL_NOT_SUPPORTED_INVIEW_TITLE"),// NOI18N JOptionPane.INFORMATION_MESSAGE); + logger.closeLog(); return; } pull(context); } public static boolean confirmWithLocalChanges(File rootFile, Class bundleLocation, String title, String query, - List listIncoming) { + List listIncoming, OutputLogger logger) { FileStatusCache cache = Mercurial.getInstance().getFileStatusCache(); File[] roots = new File[1]; roots[0] = rootFile; @@ -144,8 +147,8 @@ public class PullAction extends ContextA } if (listIncomingAndLocalMod != null && listIncomingAndLocalMod.size() > 0) { - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(PullAction.class, "MSG_PULL_OVERWRITE_LOCAL")); // NOI18N - HgUtils.outputMercurialTab(listIncomingAndLocalMod); + logger.outputInRed(NbBundle.getMessage(PullAction.class, "MSG_PULL_OVERWRITE_LOCAL")); // NOI18N + logger.output(listIncomingAndLocalMod); int response = JOptionPane.showOptionDialog(null, NbBundle.getMessage(bundleLocation, query), NbBundle.getMessage(bundleLocation, title), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); @@ -183,7 +186,7 @@ public class PullAction extends ContextA RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(repository); HgProgressSupport support = new HgProgressSupport() { - public void perform() { getDefaultAndPerformPull(ctx, root); } }; + public void perform() { getDefaultAndPerformPull(ctx, root, this.getLogger()); } }; support.start(rp, repository, org.openide.util.NbBundle.getMessage(PullAction.class, "MSG_PULL_PROGRESS")); // NOI18N } @@ -192,15 +195,15 @@ public class PullAction extends ContextA return HgUtils.getRootFile(context) != null; } - static void getDefaultAndPerformPull(VCSContext ctx, File root) { + static void getDefaultAndPerformPull(VCSContext ctx, File root, OutputLogger logger) { final String pullPath = HgCommand.getPullDefault(root); // If the repository has no default pull path then inform user if(pullPath == null) { - HgUtils.outputMercurialTabInRed( NbBundle.getMessage(PullAction.class,"MSG_PULL_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( NbBundle.getMessage(PullAction.class,"MSG_PULL_TITLE_SEP")); // NOI18N - HgUtils.outputMercurialTab(NbBundle.getMessage(PullAction.class, "MSG_NO_DEFAULT_PULL_SET_MSG")); // NOI18N - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(PullAction.class, "MSG_PULL_DONE")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.outputInRed( NbBundle.getMessage(PullAction.class,"MSG_PULL_TITLE")); // NOI18N + logger.outputInRed( NbBundle.getMessage(PullAction.class,"MSG_PULL_TITLE_SEP")); // NOI18N + logger.output(NbBundle.getMessage(PullAction.class, "MSG_NO_DEFAULT_PULL_SET_MSG")); // NOI18N + logger.outputInRed(NbBundle.getMessage(PullAction.class, "MSG_PULL_DONE")); // NOI18N + logger.output(""); // NOI18N JOptionPane.showMessageDialog(null, NbBundle.getMessage(PullAction.class,"MSG_NO_DEFAULT_PULL_SET"), NbBundle.getMessage(PullAction.class,"MSG_PULL_TITLE"), @@ -213,20 +216,20 @@ public class PullAction extends ContextA final String fromPrjName = HgProjectUtils.getProjectName(new File(pullPath)); Project proj = HgUtils.getProject(ctx); final String toPrjName = HgProjectUtils.getProjectName(proj); - performPull(fromPrjName != null ? PullType.LOCAL : PullType.OTHER, ctx, root, pullPath, fromPrjName, toPrjName); + performPull(fromPrjName != null ? PullType.LOCAL : PullType.OTHER, ctx, root, pullPath, fromPrjName, toPrjName, logger); } - static void performPull(PullType type, VCSContext ctx, File root, String pullPath, String fromPrjName, String toPrjName) { + static void performPull(PullType type, VCSContext ctx, File root, String pullPath, String fromPrjName, String toPrjName, OutputLogger logger) { if(root == null || pullPath == null) return; File bundleFile = null; try { - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(PullAction.class, "MSG_PULL_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(PullAction.class, "MSG_PULL_TITLE_SEP")); // NOI18N + logger.outputInRed(NbBundle.getMessage(PullAction.class, "MSG_PULL_TITLE")); // NOI18N + logger.outputInRed(NbBundle.getMessage(PullAction.class, "MSG_PULL_TITLE_SEP")); // NOI18N List listIncoming; if(type == PullType.LOCAL){ - listIncoming = HgCommand.doIncoming(root); + listIncoming = HgCommand.doIncoming(root, logger); }else{ for (int i = 0; i < 10000; i++) { if (!new File(root.getParentFile(), root.getName() + "_bundle" + i).exists()) { // NOI18N @@ -234,16 +237,16 @@ public class PullAction extends ContextA break; } } - listIncoming = HgCommand.doIncoming(root, pullPath, bundleFile); + listIncoming = HgCommand.doIncoming(root, pullPath, bundleFile, logger); } if (listIncoming == null || listIncoming.isEmpty()) return; boolean bNoChanges = HgCommand.isNoChanges(listIncoming.get(listIncoming.size() - 1)); // Warn User when there are Local Changes present that Pull will overwrite - if (!bNoChanges && !confirmWithLocalChanges(root, PullAction.class, "MSG_PULL_LOCALMODS_CONFIRM_TITLE", "MSG_PULL_LOCALMODS_CONFIRM_QUERY", listIncoming)) { // NOI18N - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(PullAction.class, "MSG_PULL_LOCALMODS_CANCEL")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + if (!bNoChanges && !confirmWithLocalChanges(root, PullAction.class, "MSG_PULL_LOCALMODS_CONFIRM_TITLE", "MSG_PULL_LOCALMODS_CONFIRM_QUERY", listIncoming, logger)) { // NOI18N + logger.outputInRed(NbBundle.getMessage(PullAction.class, "MSG_PULL_LOCALMODS_CANCEL")); // NOI18N + logger.output(""); // NOI18N return; } @@ -253,9 +256,9 @@ public class PullAction extends ContextA list = listIncoming; } else { if(type == PullType.LOCAL){ - list = HgCommand.doPull(root); + list = HgCommand.doPull(root, logger); }else{ - list = HgCommand.doUnbundle(root, bundleFile); + list = HgCommand.doUnbundle(root, bundleFile, logger); } } @@ -265,19 +268,19 @@ public class PullAction extends ContextA annotateChangeSets(HgUtils.replaceHttpPassword(listIncoming), PullAction.class, "MSG_CHANGESETS_TO_PULL"); // NOI18N } - HgUtils.outputMercurialTab(HgUtils.replaceHttpPassword(list)); + logger.output(HgUtils.replaceHttpPassword(list)); if (fromPrjName != null) { - HgUtils.outputMercurialTabInRed(NbBundle.getMessage( + logger.outputInRed(NbBundle.getMessage( PullAction.class, "MSG_PULL_FROM", fromPrjName, HgUtils.stripDoubleSlash(HgUtils.replaceHttpPassword(pullPath)))); // NOI18N } else { - HgUtils.outputMercurialTabInRed(NbBundle.getMessage( + logger.outputInRed(NbBundle.getMessage( PullAction.class, "MSG_PULL_FROM_NONAME", HgUtils.stripDoubleSlash(HgUtils.replaceHttpPassword(pullPath)))); // NOI18N } if (toPrjName != null) { - HgUtils.outputMercurialTabInRed(NbBundle.getMessage( + logger.outputInRed(NbBundle.getMessage( PullAction.class, "MSG_PULL_TO", toPrjName, root)); // NOI18N } else { - HgUtils.outputMercurialTabInRed(NbBundle.getMessage( + logger.outputInRed(NbBundle.getMessage( PullAction.class, "MSG_PULL_TO_NONAME", root)); // NOI18N } @@ -295,13 +298,13 @@ public class PullAction extends ContextA } } if (bConfirmMerge) { - HgUtils.outputMercurialTab(""); // NOI18N - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(PullAction.class, "MSG_PULL_MERGE_DO")); // NOI18N - MergeAction.doMergeAction(root, null); + logger.output(""); // NOI18N + logger.outputInRed(NbBundle.getMessage(PullAction.class, "MSG_PULL_MERGE_DO")); // NOI18N + MergeAction.doMergeAction(root, null, logger); } else { List headRevList = HgCommand.getHeadRevisions(root); if (headRevList != null && headRevList.size() > 1){ - MergeAction.printMergeWarning(headRevList); + MergeAction.printMergeWarning(headRevList, logger); } } } @@ -323,8 +326,8 @@ public class PullAction extends ContextA if (bundleFile != null) { bundleFile.delete(); } - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(PullAction.class, "MSG_PULL_DONE")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.outputInRed(NbBundle.getMessage(PullAction.class, "MSG_PULL_DONE")); // NOI18N + logger.output(""); // NOI18N } } } diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/pull/PullOtherAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/pull/PullOtherAction.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/pull/PullOtherAction.java Thu Feb 21 11:08:54 2008 +0000 @@ -126,7 +126,7 @@ public class PullOtherAction extends Con RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(root); HgProgressSupport support = new HgProgressSupport() { public void perform() { - PullAction.performPull(PullAction.PullType.OTHER, ctx, root, pullPath, fromPrjName, toPrjName); } }; + PullAction.performPull(PullAction.PullType.OTHER, ctx, root, pullPath, fromPrjName, toPrjName, this.getLogger()); } }; support.start(rp, repository, org.openide.util.NbBundle.getMessage(PullAction.class, "MSG_PULL_PROGRESS")); // NOI18N diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/push/PushAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/push/PushAction.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/push/PushAction.java Thu Feb 21 11:08:54 2008 +0000 @@ -51,6 +51,7 @@ import org.netbeans.modules.mercurial.Hg import org.netbeans.modules.mercurial.HgException; import org.netbeans.modules.mercurial.HgProgressSupport; import org.netbeans.modules.mercurial.Mercurial; +import org.netbeans.modules.mercurial.OutputLogger; import org.netbeans.modules.mercurial.ui.merge.MergeAction; import org.netbeans.modules.mercurial.ui.pull.PullAction; import org.netbeans.modules.mercurial.ui.actions.ContextAction; @@ -86,15 +87,17 @@ public class PushAction extends ContextA public void performAction(ActionEvent e) { final File root = HgUtils.getRootFile(context); if (root == null) { - HgUtils.outputMercurialTabInRed( NbBundle.getMessage(PushAction.class,"MSG_PUSH_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( NbBundle.getMessage(PushAction.class,"MSG_PUSH_TITLE_SEP")); // NOI18N - HgUtils.outputMercurialTabInRed( + OutputLogger logger = OutputLogger.getLogger(Mercurial.MERCURIAL_OUTPUT_TAB_TITLE); + logger.outputInRed( NbBundle.getMessage(PushAction.class,"MSG_PUSH_TITLE")); // NOI18N + logger.outputInRed( NbBundle.getMessage(PushAction.class,"MSG_PUSH_TITLE_SEP")); // NOI18N + logger.outputInRed( NbBundle.getMessage(PushAction.class, "MSG_PUSH_NOT_SUPPORTED_INVIEW_INFO")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.output(""); // NOI18N JOptionPane.showMessageDialog(null, NbBundle.getMessage(PushAction.class, "MSG_PUSH_NOT_SUPPORTED_INVIEW"),// NOI18N NbBundle.getMessage(PushAction.class, "MSG_PUSH_NOT_SUPPORTED_INVIEW_TITLE"),// NOI18N JOptionPane.INFORMATION_MESSAGE); + logger.closeLog(); return; } @@ -114,24 +117,24 @@ public class PushAction extends ContextA RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(repository); HgProgressSupport support = new HgProgressSupport() { - public void perform() { getDefaultAndPerformPush(ctx, root); } }; + public void perform() { getDefaultAndPerformPush(ctx, root, this.getLogger()); } }; support.start(rp, repository, org.openide.util.NbBundle.getMessage(PushAction.class, "MSG_PUSH_PROGRESS")); // NOI18N } - static void getDefaultAndPerformPush(VCSContext ctx, File root) { + static void getDefaultAndPerformPush(VCSContext ctx, File root, OutputLogger logger) { // If the repository has no default pull path then inform user String tmpPushPath = HgRepositoryContextCache.getPushDefault(ctx); if(tmpPushPath == null) { tmpPushPath = HgRepositoryContextCache.getPullDefault(ctx); } if(tmpPushPath == null) { - HgUtils.outputMercurialTabInRed( NbBundle.getMessage(PushAction.class,"MSG_PUSH_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( NbBundle.getMessage(PushAction.class,"MSG_PUSH_TITLE_SEP")); // NOI18N - HgUtils.outputMercurialTab(NbBundle.getMessage(PushAction.class, "MSG_NO_DEFAULT_PUSH_SET_MSG")); // NOI18N - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(PushAction.class, "MSG_PUSH_DONE")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.outputInRed( NbBundle.getMessage(PushAction.class,"MSG_PUSH_TITLE")); // NOI18N + logger.outputInRed( NbBundle.getMessage(PushAction.class,"MSG_PUSH_TITLE_SEP")); // NOI18N + logger.output(NbBundle.getMessage(PushAction.class, "MSG_NO_DEFAULT_PUSH_SET_MSG")); // NOI18N + logger.outputInRed(NbBundle.getMessage(PushAction.class, "MSG_PUSH_DONE")); // NOI18N + logger.output(""); // NOI18N JOptionPane.showMessageDialog(null, NbBundle.getMessage(PushAction.class,"MSG_NO_DEFAULT_PUSH_SET"), NbBundle.getMessage(PushAction.class,"MSG_PUSH_TITLE"), @@ -141,15 +144,15 @@ public class PushAction extends ContextA final String pushPath = tmpPushPath; final String fromPrjName = HgProjectUtils.getProjectName(root); final String toPrjName = HgProjectUtils.getProjectName(new File(pushPath)); - performPush(root, pushPath, fromPrjName, toPrjName); + performPush(root, pushPath, fromPrjName, toPrjName, logger); } - static void performPush(File root, String pushPath, String fromPrjName, String toPrjName) { + static void performPush(File root, String pushPath, String fromPrjName, String toPrjName, OutputLogger logger) { try { - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(PushAction.class, "MSG_PUSH_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(PushAction.class, "MSG_PUSH_TITLE_SEP")); // NOI18N + logger.outputInRed(NbBundle.getMessage(PushAction.class, "MSG_PUSH_TITLE")); // NOI18N + logger.outputInRed(NbBundle.getMessage(PushAction.class, "MSG_PUSH_TITLE_SEP")); // NOI18N - List listOutgoing = HgCommand.doOutgoing(root, pushPath); + List listOutgoing = HgCommand.doOutgoing(root, pushPath, logger); if ((listOutgoing == null) || listOutgoing.isEmpty()) { return; } @@ -161,9 +164,9 @@ public class PushAction extends ContextA if (bLocalPush) { // Warn user if there are local changes which Push will overwrite if (!bNoChanges && !PullAction.confirmWithLocalChanges(pushFile, PushAction.class, - "MSG_PUSH_LOCALMODS_CONFIRM_TITLE", "MSG_PUSH_LOCALMODS_CONFIRM_QUERY", listOutgoing)) { // NOI18N - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(PushAction.class, "MSG_PUSH_LOCALMODS_CANCEL")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + "MSG_PUSH_LOCALMODS_CONFIRM_TITLE", "MSG_PUSH_LOCALMODS_CONFIRM_QUERY", listOutgoing, logger)) { // NOI18N + logger.outputInRed(NbBundle.getMessage(PushAction.class, "MSG_PUSH_LOCALMODS_CANCEL")); // NOI18N + logger.output(""); // NOI18N return; } } @@ -172,56 +175,50 @@ public class PushAction extends ContextA if (bNoChanges) { list = listOutgoing; } else { - list = HgCommand.doPush(root, pushPath); + list = HgCommand.doPush(root, pushPath, logger); } if (!list.isEmpty() && HgCommand.isErrorAbortPush(list.get(list.size() - 1))) { - HgUtils.outputMercurialTab(list); - HgUtils.outputMercurialTab(""); + logger.output(list); + logger.output(""); HgUtils.warningDialog(PushAction.class, "MSG_PUSH_ERROR_TITLE", "MSG_PUSH_ERROR_QUERY"); // NOI18N - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(PushAction.class, "MSG_PUSH_ERROR_CANCELED")); // NOI18N + logger.outputInRed(NbBundle.getMessage(PushAction.class, "MSG_PUSH_ERROR_CANCELED")); // NOI18N return; } if (list != null && !list.isEmpty()) { if (!HgCommand.isNoChanges(listOutgoing.get(listOutgoing.size() - 1))) { - InputOutput io = IOProvider.getDefault().getIO(Mercurial.MERCURIAL_OUTPUT_TAB_TITLE, false); - io.select(); - OutputWriter out = io.getOut(); - OutputWriter outRed = io.getErr(); - outRed.println(NbBundle.getMessage(PushAction.class, "MSG_CHANGESETS_TO_PUSH")); // NOI18N + logger.outputInRed(NbBundle.getMessage(PushAction.class, "MSG_CHANGESETS_TO_PUSH")); // NOI18N for (String s : listOutgoing) { if (s.indexOf(Mercurial.CHANGESET_STR) == 0) { - outRed.println(s); + logger.outputInRed(s); } else if (!s.equals("")) { // NOI18N - out.println(HgUtils.replaceHttpPassword(s)); + logger.output(HgUtils.replaceHttpPassword(s)); } } - out.println(""); // NOI18N - out.close(); - outRed.close(); + logger.output(""); // NOI18N } - HgUtils.outputMercurialTab(HgUtils.replaceHttpPassword(list)); + logger.output(HgUtils.replaceHttpPassword(list)); if (toPrjName == null) { - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(PushAction.class, "MSG_PUSH_TO_NONAME", bLocalPush ? HgUtils.stripDoubleSlash(pushPath) : HgUtils.replaceHttpPassword(pushPath))); // NOI18N } else { - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(PushAction.class, "MSG_PUSH_TO", toPrjName, bLocalPush ? HgUtils.stripDoubleSlash(pushPath) : HgUtils.replaceHttpPassword(pushPath))); // NOI18N } if (fromPrjName == null ){ - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(PushAction.class, "MSG_PUSH_FROM_NONAME", root)); // NOI18N } else { - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(PushAction.class, "MSG_PUSH_FROM", fromPrjName, root)); // NOI18N } @@ -235,13 +232,13 @@ public class PushAction extends ContextA } if (bLocalPush) { list = HgCommand.doUpdateAll(pushFile, false, null, false); - HgUtils.outputMercurialTab(list); + logger.output(list); if (toPrjName != null) { - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(PushAction.class, "MSG_PUSH_UPDATE_DONE", toPrjName, HgUtils.stripDoubleSlash(pushPath))); // NOI18N } else { - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(PushAction.class, "MSG_PUSH_UPDATE_DONE_NONAME", HgUtils.stripDoubleSlash(pushPath))); // NOI18N } @@ -255,15 +252,15 @@ public class PushAction extends ContextA } if (bConfirmMerge) { - HgUtils.outputMercurialTab(""); // NOI18N - HgUtils.outputMercurialTabInRed( + logger.output(""); // NOI18N + logger.outputInRed( NbBundle.getMessage(PushAction.class, "MSG_PUSH_MERGE_DO")); // NOI18N - MergeAction.doMergeAction(pushFile, null); + MergeAction.doMergeAction(pushFile, null, logger); } else { List headRevList = HgCommand.getHeadRevisions(pushPath); if (headRevList != null && headRevList.size() > 1) { - MergeAction.printMergeWarning(headRevList); + MergeAction.printMergeWarning(headRevList, logger); } } } @@ -280,8 +277,8 @@ public class PushAction extends ContextA NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); DialogDisplayer.getDefault().notifyLater(e); } finally { - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(PushAction.class, "MSG_PUSH_DONE")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.outputInRed(NbBundle.getMessage(PushAction.class, "MSG_PUSH_DONE")); // NOI18N + logger.output(""); // NOI18N } } diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/push/PushOtherAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/push/PushOtherAction.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/push/PushOtherAction.java Thu Feb 21 11:08:54 2008 +0000 @@ -127,7 +127,7 @@ public class PushOtherAction extends Con RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(root); HgProgressSupport support = new HgProgressSupport() { public void perform() { - PushAction.performPush(root, pushPath, fromPrjName, toPrjName); + PushAction.performPush(root, pushPath, fromPrjName, toPrjName, this.getLogger()); } }; diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/rollback/BackoutAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/rollback/BackoutAction.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/rollback/BackoutAction.java Thu Feb 21 11:08:54 2008 +0000 @@ -50,6 +50,7 @@ import org.netbeans.modules.mercurial.Hg import org.netbeans.modules.mercurial.HgException; import org.netbeans.modules.mercurial.HgProgressSupport; import org.netbeans.modules.mercurial.Mercurial; +import org.netbeans.modules.mercurial.OutputLogger; import org.netbeans.modules.mercurial.util.HgCommand; import org.netbeans.modules.mercurial.util.HgUtils; import org.netbeans.modules.mercurial.FileStatusCache; @@ -107,17 +108,18 @@ public class BackoutAction extends Conte HgProgressSupport support = new HgProgressSupport() { public void perform() { + OutputLogger logger = getLogger(); try { - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(BackoutAction.class, "MSG_BACKOUT_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(BackoutAction.class, "MSG_BACKOUT_TITLE_SEP")); // NOI18N - HgUtils.outputMercurialTab( + logger.output( NbBundle.getMessage(BackoutAction.class, "MSG_BACKOUT_INFO_SEP", revStr, root.getAbsolutePath())); // NOI18N - List list = HgCommand.doBackout(root, revStr, doMerge, commitMsgStr); + List list = HgCommand.doBackout(root, revStr, doMerge, commitMsgStr, logger); if(list != null && !list.isEmpty()){ boolean bMergeNeededDueToBackout = HgCommand.isBackoutMergeNeededMsg(list.get(list.size() - 1)); @@ -125,20 +127,20 @@ public class BackoutAction extends Conte list.remove(list.size() - 1); list.remove(list.size() - 1); } - HgUtils.outputMercurialTab(list); + logger.output(list); if(HgCommand.isUncommittedChangesBackout(list.get(0))){ - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(BackoutAction.class, "MSG_UNCOMMITTED_CHANGES_BACKOUT")); // NOI18N return; } else if(HgCommand.isMergeChangesetBackout(list.get(0))){ - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(BackoutAction.class, "MSG_MERGE_CSET_BACKOUT",revStr)); // NOI18N return; } else if(HgCommand.isNoRevStrip(list.get(0))){ - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(BackoutAction.class, "MSG_NO_REV_BACKOUT",revStr)); // NOI18N return; @@ -151,13 +153,13 @@ public class BackoutAction extends Conte BackoutAction.class, "MSG_BACKOUT_MERGE_CONFIRM_TITLE", "MSG_BACKOUT_MERGE_CONFIRM_QUERY"); // NOI18N } if (bConfirmMerge) { - HgUtils.outputMercurialTab(""); // NOI18N - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(BackoutAction.class, "MSG_BACKOUT_MERGE_DO")); // NOI18N - MergeAction.doMergeAction(root, null); + logger.output(""); // NOI18N + logger.outputInRed(NbBundle.getMessage(BackoutAction.class, "MSG_BACKOUT_MERGE_DO")); // NOI18N + MergeAction.doMergeAction(root, null, logger); } else { List headRevList = HgCommand.getHeadRevisions(root); if (headRevList != null && headRevList.size() > 1) { - MergeAction.printMergeWarning(headRevList); + MergeAction.printMergeWarning(headRevList, logger); } } HgUtils.forceStatusRefreshProject(ctx); @@ -172,10 +174,10 @@ public class BackoutAction extends Conte NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); DialogDisplayer.getDefault().notifyLater(e); } finally { - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(BackoutAction.class, "MSG_BACKOUT_DONE")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.output(""); // NOI18N } } }; diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/rollback/RollbackAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/rollback/RollbackAction.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/rollback/RollbackAction.java Thu Feb 21 11:08:54 2008 +0000 @@ -50,6 +50,7 @@ import org.netbeans.modules.mercurial.Hg import org.netbeans.modules.mercurial.HgException; import org.netbeans.modules.mercurial.HgProgressSupport; import org.netbeans.modules.mercurial.Mercurial; +import org.netbeans.modules.mercurial.OutputLogger; import org.netbeans.modules.mercurial.util.HgCommand; import org.netbeans.modules.mercurial.util.HgUtils; import org.netbeans.modules.mercurial.FileStatusCache; @@ -88,14 +89,15 @@ public class RollbackAction extends Cont HgProgressSupport support = new HgProgressSupport() { public void perform() { + OutputLogger logger = getLogger(); try { - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(RollbackAction.class, "MSG_ROLLBACK_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(RollbackAction.class, "MSG_ROLLBACK_TITLE_SEP")); // NOI18N - HgUtils.outputMercurialTab( + logger.output( NbBundle.getMessage(StripAction.class, "MSG_ROLLBACK_INFO_SEP", root.getAbsolutePath())); // NOI18N int response = JOptionPane.showOptionDialog(null, @@ -104,23 +106,23 @@ public class RollbackAction extends Cont JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (response == JOptionPane.NO_OPTION) { - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(RollbackAction.class, "MSG_ROLLBACK_CANCELED", root.getAbsolutePath())); // NOI18N return; } - List list = HgCommand.doRollback(root); + List list = HgCommand.doRollback(root, logger); if(list != null && !list.isEmpty()){ - //HgUtils.clearOutputMercurialTab(); + //logger.clearOutput(); if(HgCommand.isNoRollbackPossible(list.get(0))){ - HgUtils.outputMercurialTab( + logger.output( NbBundle.getMessage(RollbackAction.class, "MSG_NO_ROLLBACK")); // NOI18N }else{ - HgUtils.outputMercurialTab(list.get(0)); + logger.output(list.get(0)); if (HgCommand.hasHistory(root)) { response = JOptionPane.showOptionDialog(null, NbBundle.getMessage(RollbackAction.class,"MSG_ROLLBACK_CONFIRM_UPDATE_QUERY") , // NOI18N @@ -128,7 +130,7 @@ public class RollbackAction extends Cont JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,null, null, null); if( response == JOptionPane.YES_OPTION){ - HgUtils.outputMercurialTab( + logger.output( NbBundle.getMessage(RollbackAction.class, "MSG_ROLLBACK_FORCE_UPDATE", root.getAbsolutePath())); // NOI18N list = HgCommand.doUpdateAll(root, true, null); @@ -141,7 +143,7 @@ public class RollbackAction extends Cont Mercurial.getInstance().changesetChanged(root); if (list != null && !list.isEmpty()){ - HgUtils.outputMercurialTab(list); + logger.output(list); } } else { HgUtils.forceStatusRefreshProject(ctx); @@ -155,7 +157,7 @@ public class RollbackAction extends Cont } } - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(RollbackAction.class, "MSG_ROLLBACK_INFO")); // NOI18N } @@ -163,10 +165,10 @@ public class RollbackAction extends Cont NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); DialogDisplayer.getDefault().notifyLater(e); } finally { - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(RollbackAction.class, "MSG_ROLLBACK_DONE")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.output(""); // NOI18N } } }; diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/rollback/StripAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/rollback/StripAction.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/rollback/StripAction.java Thu Feb 21 11:08:54 2008 +0000 @@ -50,6 +50,7 @@ import org.netbeans.modules.mercurial.Hg import org.netbeans.modules.mercurial.HgException; import org.netbeans.modules.mercurial.HgProgressSupport; import org.netbeans.modules.mercurial.Mercurial; +import org.netbeans.modules.mercurial.OutputLogger; import org.netbeans.modules.mercurial.util.HgCommand; import org.netbeans.modules.mercurial.util.HgUtils; import org.netbeans.modules.mercurial.FileStatusCache; @@ -99,31 +100,32 @@ public class StripAction extends Context HgProgressSupport support = new HgProgressSupport() { public void perform() { + OutputLogger logger = getLogger(); try { - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(StripAction.class, "MSG_STRIP_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(StripAction.class, "MSG_STRIP_TITLE_SEP")); // NOI18N - HgUtils.outputMercurialTab( + logger.output( NbBundle.getMessage(StripAction.class, "MSG_STRIP_INFO_SEP", revStr, root.getAbsolutePath())); // NOI18N - List list = HgCommand.doStrip(root, revStr, false, doBackup); + List list = HgCommand.doStrip(root, revStr, false, doBackup, logger); if(list != null && !list.isEmpty()){ - HgUtils.outputMercurialTab(list); + logger.output(list); if(HgCommand.isNoRevStrip(list.get(0))){ - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(StripAction.class, "MSG_NO_REV_STRIP",revStr)); // NOI18N }else if(HgCommand.isLocalChangesStrip(list.get(0))){ - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(StripAction.class, "MSG_LOCAL_CHANGES_STRIP")); // NOI18N }else if(HgCommand.isMultipleHeadsStrip(list.get(0))){ - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(StripAction.class, "MSG_MULTI_HEADS_STRIP")); // NOI18N }else{ @@ -139,10 +141,10 @@ public class StripAction extends Context savingTo = savingTo != null? savingTo.substring(HG_STIP_SAVE_BUNDLE.length()): null; File savingFile = new File(savingTo); if(savingFile != null && savingFile.exists() && savingFile.canRead()){ - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(StripAction.class, "MSG_STRIP_RESTORE_INFO")); // NOI18N - HgUtils.outputMercurialTab( + logger.output( NbBundle.getMessage(StripAction.class, "MSG_STRIP_RESTORE_INFO2", savingFile.getAbsoluteFile())); // NOI18N } @@ -152,10 +154,10 @@ public class StripAction extends Context NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); DialogDisplayer.getDefault().notifyLater(e); } finally { - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(StripAction.class, "MSG_STRIP_DONE")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.output(""); // NOI18N } } }; diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/update/RevertModificationsAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/update/RevertModificationsAction.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/update/RevertModificationsAction.java Thu Feb 21 11:08:54 2008 +0000 @@ -47,6 +47,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionEvent; import org.netbeans.modules.versioning.spi.VCSContext; import org.netbeans.modules.mercurial.Mercurial; +import org.netbeans.modules.mercurial.OutputLogger; import org.netbeans.modules.mercurial.FileStatusCache; import org.netbeans.modules.mercurial.FileInformation; import org.netbeans.modules.mercurial.util.HgUtils; @@ -96,7 +97,7 @@ public class RevertModificationsAction e RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(repository); HgProgressSupport support = new HgProgressSupport() { public void perform() { - performRevert(repository, revStr, files, doBackup); + performRevert(repository, revStr, files, doBackup, this.getLogger()); } }; support.start(rp, repository.getAbsolutePath(), org.openide.util.NbBundle.getMessage(UpdateAction.class, "MSG_Revert_Progress")); // NOI18N @@ -104,52 +105,52 @@ public class RevertModificationsAction e return; } - public static void performRevert(File repository, String revStr, File file, boolean doBackup) { + public static void performRevert(File repository, String revStr, File file, boolean doBackup, OutputLogger logger) { List revertFiles = new ArrayList(); revertFiles.add(file); - performRevert(repository, revStr, revertFiles, doBackup); + performRevert(repository, revStr, revertFiles, doBackup, logger); } - public static void performRevert(File repository, String revStr, File[] files, boolean doBackup) { + public static void performRevert(File repository, String revStr, File[] files, boolean doBackup, OutputLogger logger) { List revertFiles = new ArrayList(); for (File file : files) { revertFiles.add(file); } - performRevert(repository, revStr, revertFiles, doBackup); + performRevert(repository, revStr, revertFiles, doBackup, logger); } - public static void performRevert(File repository, String revStr, List revertFiles, boolean doBackup) { + public static void performRevert(File repository, String revStr, List revertFiles, boolean doBackup, OutputLogger logger) { try{ - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(RevertModificationsAction.class, "MSG_REVERT_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(RevertModificationsAction.class, "MSG_REVERT_TITLE_SEP")); // NOI18N // No revisions to revert too if (NbBundle.getMessage(RevertModificationsAction.class, "MSG_Revision_Default").startsWith(revStr)) { - HgUtils.outputMercurialTab( + logger.output( NbBundle.getMessage(RevertModificationsAction.class, "MSG_REVERT_NOTHING")); // NOI18N - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(RevertModificationsAction.class, "MSG_REVERT_DONE")); // NOI18N - HgUtils.outputMercurialTabInRed(""); // NOI18N + logger.outputInRed(""); // NOI18N return; } - HgUtils.outputMercurialTab( + logger.output( NbBundle.getMessage(RevertModificationsAction.class, "MSG_REVERT_REVISION_STR", revStr)); // NOI18N for (File file : revertFiles) { - HgUtils.outputMercurialTab(file.getAbsolutePath()); + logger.output(file.getAbsolutePath()); } - HgUtils.outputMercurialTab(""); // NOI18N + logger.output(""); // NOI18N - HgCommand.doRevert(repository, revertFiles, revStr, doBackup); + HgCommand.doRevert(repository, revertFiles, revStr, doBackup, logger); FileStatusCache cache = Mercurial.getInstance().getFileStatusCache(); File[] conflictFiles = cache.listFiles(revertFiles.toArray(new File[0]), FileInformation.STATUS_VERSIONED_CONFLICT); if (conflictFiles.length != 0) { @@ -174,10 +175,10 @@ public class RevertModificationsAction e rootObj.getFileSystem().refresh(true); } catch (java.lang.Exception exc) { } - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(RevertModificationsAction.class, "MSG_REVERT_DONE")); // NOI18N - HgUtils.outputMercurialTabInRed(""); // NOI18N + logger.outputInRed(""); // NOI18N } diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/update/UpdateAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/update/UpdateAction.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/update/UpdateAction.java Thu Feb 21 11:08:54 2008 +0000 @@ -45,6 +45,7 @@ import org.netbeans.modules.mercurial.Hg import org.netbeans.modules.mercurial.HgException; import org.netbeans.modules.mercurial.HgProgressSupport; import org.netbeans.modules.mercurial.Mercurial; +import org.netbeans.modules.mercurial.OutputLogger; import org.netbeans.modules.mercurial.util.HgUtils; import org.netbeans.modules.mercurial.ui.actions.ContextAction; import org.netbeans.modules.versioning.spi.VCSContext; @@ -95,23 +96,24 @@ public class UpdateAction extends Contex HgProgressSupport support = new HgProgressSupport() { public void perform() { boolean bNoUpdates = true; + OutputLogger logger = getLogger(); try { - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(UpdateAction.class, "MSG_UPDATE_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(UpdateAction.class, "MSG_UPDATE_TITLE_SEP")); // NOI18N - HgUtils.outputMercurialTab( + logger.output( NbBundle.getMessage(UpdateAction.class, "MSG_UPDATE_INFO_SEP", revStr, root.getAbsolutePath())); // NOI18N List list = HgCommand.doUpdateAll(root, doForcedUpdate, revStr); if (list != null && !list.isEmpty()){ bNoUpdates = HgCommand.isNoUpdates(list.get(0)); - //HgUtils.clearOutputMercurialTab(); - HgUtils.outputMercurialTab(list); - HgUtils.outputMercurialTab(""); // NOI18N + //logger.clearOutput(); + logger.output(list); + logger.output(""); // NOI18N } // refresh filesystem to take account of changes FileObject rootObj = FileUtil.toFileObject(root); @@ -129,10 +131,10 @@ public class UpdateAction extends Contex if(!bNoUpdates) HgUtils.forceStatusRefreshProject(ctx); - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(UpdateAction.class, "MSG_UPDATE_DONE")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.output(""); // NOI18N } }; support.start(rp, repository, org.openide.util.NbBundle.getMessage(UpdateAction.class, "MSG_Update_Progress")); // NOI18N diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/ui/view/ViewAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/view/ViewAction.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/view/ViewAction.java Thu Feb 21 11:08:54 2008 +0000 @@ -42,6 +42,7 @@ package org.netbeans.modules.mercurial.u import org.netbeans.modules.versioning.spi.VCSContext; import org.netbeans.modules.mercurial.Mercurial; +import org.netbeans.modules.mercurial.OutputLogger; import org.netbeans.modules.mercurial.HgException; import org.netbeans.modules.mercurial.util.HgCommand; import org.netbeans.modules.mercurial.util.HgUtils; @@ -87,9 +88,10 @@ public class ViewAction extends ContextA } static void performView(File root) { + OutputLogger logger = OutputLogger.getLogger(root.getAbsolutePath()); try { - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(ViewAction.class, "MSG_VIEW_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(ViewAction.class, "MSG_VIEW_TITLE_SEP")); // NOI18N + logger.outputInRed(NbBundle.getMessage(ViewAction.class, "MSG_VIEW_TITLE")); // NOI18N + logger.outputInRed(NbBundle.getMessage(ViewAction.class, "MSG_VIEW_TITLE_SEP")); // NOI18N String hgkCommand = HgCommand.HGK_COMMAND; if(Utilities.isWindows()){ @@ -109,13 +111,14 @@ public class ViewAction extends ContextA HgConfigFiles.HG_EXTENSIONS, HgConfigFiles.HG_EXTENSIONS_HGK); if(!bHgkFound){ - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(ViewAction.class, "MSG_VIEW_HGK_NOT_FOUND_INFO")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.output(""); // NOI18N JOptionPane.showMessageDialog(null, NbBundle.getMessage(ViewAction.class, "MSG_VIEW_HGK_NOT_FOUND"),// NOI18N NbBundle.getMessage(ViewAction.class, "MSG_VIEW_HGK_NOT_FOUND_TITLE"),// NOI18N JOptionPane.INFORMATION_MESSAGE); + logger.closeLog(); return; } if(!bHgkPropExists){ @@ -124,21 +127,23 @@ public class ViewAction extends ContextA ViewAction.class, "MSG_VIEW_SETHGK_PROP_CONFIRM_TITLE", // NOI18N "MSG_VIEW_SETHGK_PROP_CONFIRM_QUERY"); // NOI18N if (bConfirmSetHgkProp) { - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(ViewAction.class, "MSG_VIEW_SETHGK_PROP_DO_INFO")); // NOI18N HgConfigFiles.getInstance().setProperty(HgConfigFiles.HG_EXTENSIONS_HGK, ""); // NOI18N }else{ - HgUtils.outputMercurialTabInRed( + logger.outputInRed( NbBundle.getMessage(ViewAction.class, "MSG_VIEW_NOTSETHGK_PROP_INFO")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N + logger.output(""); // NOI18N + logger.closeLog(); return; } } - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(ViewAction.class, + logger.outputInRed(NbBundle.getMessage(ViewAction.class, "MSG_VIEW_LAUNCH_INFO", root.getAbsolutePath())); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N - HgCommand.doView(root); + logger.output(""); // NOI18N + HgCommand.doView(root, logger); + logger.closeLog(); } catch (HgException ex) { NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); DialogDisplayer.getDefault().notifyLater(e); diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/util/HgCommand.java --- a/mercurial/src/org/netbeans/modules/mercurial/util/HgCommand.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/util/HgCommand.java Thu Feb 21 11:08:54 2008 +0000 @@ -66,6 +66,7 @@ import org.netbeans.modules.mercurial.Fi import org.netbeans.modules.mercurial.FileStatus; import org.netbeans.modules.mercurial.HgException; import org.netbeans.modules.mercurial.Mercurial; +import org.netbeans.modules.mercurial.OutputLogger; import org.netbeans.api.queries.SharabilityQuery; import org.netbeans.modules.mercurial.HgModuleConfig; import org.netbeans.modules.mercurial.config.HgConfigFiles; @@ -361,7 +362,7 @@ public class HgCommand { * @return hg update output * @throws org.netbeans.modules.mercurial.HgException */ - public static List doRollback(File repository) throws HgException { + public static List doRollback(File repository, OutputLogger logger) throws HgException { if (repository == null ) return null; List command = new ArrayList(); @@ -372,12 +373,12 @@ public class HgCommand { List list = exec(command); if (list.isEmpty()) - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_ROLLBACK_FAILED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_ROLLBACK_FAILED"), logger); return list; } public static List doBackout(File repository, String revision, - boolean doMerge, String commitMsg) throws HgException { + boolean doMerge, String commitMsg, OutputLogger logger) throws HgException { if (repository == null ) return null; List env = new ArrayList(); List command = new ArrayList(); @@ -411,13 +412,13 @@ public class HgCommand { list = exec(command); } if (list.isEmpty()) - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_BACKOUT_FAILED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_BACKOUT_FAILED"), logger); return list; } public static List doStrip(File repository, String revision, - boolean doForceMultiHead, boolean doBackup) throws HgException { + boolean doForceMultiHead, boolean doBackup, OutputLogger logger) throws HgException { if (repository == null ) return null; List command = new ArrayList(); @@ -439,7 +440,7 @@ public class HgCommand { List list = exec(command); if (list.isEmpty()) - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_STRIP_FAILED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_STRIP_FAILED"), logger); return list; } @@ -476,8 +477,8 @@ public class HgCommand { * @return hg pull output * @throws org.netbeans.modules.mercurial.HgException */ - public static List doPull(File repository) throws HgException { - return doPull(repository, null); + public static List doPull(File repository, OutputLogger logger) throws HgException { + return doPull(repository, null, logger); } /** @@ -491,7 +492,7 @@ public class HgCommand { * @return hg pull output * @throws org.netbeans.modules.mercurial.HgException */ - public static List doPull(File repository, String from) throws HgException { + public static List doPull(File repository, String from, OutputLogger logger) throws HgException { if (repository == null ) return null; List command = new ArrayList(); @@ -506,7 +507,7 @@ public class HgCommand { List list; String defaultPull = new HgConfigFiles(repository).getDefaultPull(false); - String proxy = getGlobalProxyIfNeeded(defaultPull, true); + String proxy = getGlobalProxyIfNeeded(defaultPull, true, logger); if(proxy != null){ List env = new ArrayList(); env.add(HG_PROXY_ENV + proxy); @@ -517,7 +518,7 @@ public class HgCommand { if (!list.isEmpty() && isErrorAbort(list.get(list.size() -1))) { - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); } return list; } @@ -533,7 +534,7 @@ public class HgCommand { * @return hg unbundle output * @throws org.netbeans.modules.mercurial.HgException */ - public static List doUnbundle(File repository, File bundle) throws HgException { + public static List doUnbundle(File repository, File bundle, OutputLogger logger) throws HgException { if (repository == null ) return null; List command = new ArrayList(); @@ -549,7 +550,7 @@ public class HgCommand { List list = exec(command); if (!list.isEmpty() && isErrorAbort(list.get(list.size() -1))) { - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); } return list; } @@ -562,8 +563,8 @@ public class HgCommand { * @return hg incoming output * @throws org.netbeans.modules.mercurial.HgException */ - public static List doIncoming(File repository) throws HgException { - return doIncoming(repository, null, null); + public static List doIncoming(File repository, OutputLogger logger) throws HgException { + return doIncoming(repository, null, null, logger); } /** @@ -576,7 +577,7 @@ public class HgCommand { * @return hg incoming output * @throws org.netbeans.modules.mercurial.HgException */ - public static List doIncoming(File repository, String from, File bundle) throws HgException { + public static List doIncoming(File repository, String from, File bundle, OutputLogger logger) throws HgException { if (repository == null ) return null; List command = new ArrayList(); @@ -595,7 +596,7 @@ public class HgCommand { List list; String defaultPull = new HgConfigFiles(repository).getDefaultPull(false); - String proxy = getGlobalProxyIfNeeded(defaultPull, false); + String proxy = getGlobalProxyIfNeeded(defaultPull, false, null); if(proxy != null){ List env = new ArrayList(); env.add(HG_PROXY_ENV + proxy); @@ -606,7 +607,7 @@ public class HgCommand { if (!list.isEmpty() && isErrorAbort(list.get(list.size() -1))) { - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); } return list; } @@ -620,7 +621,7 @@ public class HgCommand { * @return hg outgoing output * @throws org.netbeans.modules.mercurial.HgException */ - public static List doOutgoing(File repository, String to) throws HgException { + public static List doOutgoing(File repository, String to, OutputLogger logger) throws HgException { if (repository == null ) return null; List command = new ArrayList(); @@ -633,7 +634,7 @@ public class HgCommand { List list; String defaultPush = new HgConfigFiles(repository).getDefaultPush(false); - String proxy = getGlobalProxyIfNeeded(defaultPush, false); + String proxy = getGlobalProxyIfNeeded(defaultPush, false, null); if(proxy != null){ List env = new ArrayList(); env.add(HG_PROXY_ENV + proxy); @@ -643,7 +644,7 @@ public class HgCommand { } if (!list.isEmpty() && isErrorAbort(list.get(list.size() -1))) { - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); } return list; } @@ -657,7 +658,7 @@ public class HgCommand { * @return hg push output * @throws org.netbeans.modules.mercurial.HgException */ - public static List doPush(File repository, String to) throws HgException { + public static List doPush(File repository, String to, OutputLogger logger) throws HgException { if (repository == null || to == null ) return null; List command = new ArrayList(); @@ -669,7 +670,7 @@ public class HgCommand { List list; String defaultPush = new HgConfigFiles(repository).getDefaultPush(false); - String proxy = getGlobalProxyIfNeeded(defaultPush, true); + String proxy = getGlobalProxyIfNeeded(defaultPush, true, logger); if(proxy != null){ List env = new ArrayList(); env.add(HG_PROXY_ENV + proxy); @@ -682,7 +683,7 @@ public class HgCommand { if (!list.isEmpty() && !isErrorAbortPush(list.get(list.size() -1)) && isErrorAbort(list.get(list.size() -1))) { - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); } return list; } @@ -693,7 +694,7 @@ public class HgCommand { * @param File repository of the mercurial repository's root directory * @throws org.netbeans.modules.mercurial.HgException */ - public static List doView(File repository) throws HgException { + public static List doView(File repository, OutputLogger logger) throws HgException { if (repository == null) return null; List command = new ArrayList(); List env = new ArrayList(); @@ -719,13 +720,13 @@ public class HgCommand { else if (isErrorHgkNotFound(list.get(0))) { throw new HgException(NbBundle.getMessage(HgCommand.class, "MSG_WARN_HGK_NOT_FOUND_TEXT")); } else if (isErrorAbort(list.get(list.size() -1))) { - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); } } return list; } - private static String getGlobalProxyIfNeeded(String defaultPath, boolean bOutputDetails){ + private static String getGlobalProxyIfNeeded(String defaultPath, boolean bOutputDetails, OutputLogger logger){ String proxy = null; if(defaultPath != null && (defaultPath.startsWith("http:") || defaultPath.startsWith("https:"))){ // NOI18N @@ -750,7 +751,7 @@ public class HgCommand { } } if(proxy != null && bOutputDetails){ - HgUtils.outputMercurialTab(NbBundle.getMessage(HgCommand.class, "MSG_USING_PROXY_INFO", proxy)); // NOI18N + logger.output(NbBundle.getMessage(HgCommand.class, "MSG_USING_PROXY_INFO", proxy)); // NOI18N } return proxy; } @@ -760,7 +761,7 @@ public class HgCommand { * @param File repository of the mercurial repository's root directory * @throws org.netbeans.modules.mercurial.HgException */ - public static List doFetch(File repository) throws HgException { + public static List doFetch(File repository, OutputLogger logger) throws HgException { if (repository == null) return null; List command = new ArrayList(); @@ -773,7 +774,7 @@ public class HgCommand { List list; String defaultPull = new HgConfigFiles(repository).getDefaultPull(false); - String proxy = getGlobalProxyIfNeeded(defaultPull, true); + String proxy = getGlobalProxyIfNeeded(defaultPull, true, logger); if(proxy != null){ List env = new ArrayList(); env.add(HG_PROXY_ENV + proxy); @@ -784,7 +785,7 @@ public class HgCommand { if (!list.isEmpty()) { if (isErrorAbort(list.get(list.size() -1))) { - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); } } return list; @@ -834,15 +835,18 @@ public class HgCommand { final List messages = new ArrayList(0); final File root = new File(rootUrl); + OutputLogger logger = OutputLogger.getLogger(rootUrl); try { List list = new LinkedList(); - list = HgCommand.doIncomingForSearch(root); + list = HgCommand.doIncomingForSearch(root, logger); processLogMessages(list, messages); } catch (HgException ex) { NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); DialogDisplayer.getDefault().notifyLater(e); + } finally { + logger.closeLog(); } return messages.toArray(new HgLogMessage[0]); @@ -852,15 +856,18 @@ public class HgCommand { final List messages = new ArrayList(0); final File root = new File(rootUrl); + OutputLogger logger = OutputLogger.getLogger(rootUrl); try { List list = new LinkedList(); - list = HgCommand.doOut(root); + list = HgCommand.doOut(root, logger); processLogMessages(list, messages); } catch (HgException ex) { NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); DialogDisplayer.getDefault().notifyLater(e); + } finally { + logger.closeLog(); } return messages.toArray(new HgLogMessage[0]); @@ -870,6 +877,7 @@ public class HgCommand { final List messages = new ArrayList(0); final File root = new File(rootUrl); + OutputLogger logger = OutputLogger.getLogger(rootUrl); try { String headRev = HgCommand.getLastRevision(root, null); if (headRev == null) { @@ -879,12 +887,14 @@ public class HgCommand { List list = new LinkedList(); list = HgCommand.doLogForHistory(root, files != null ? new ArrayList(files) : null, - fromRevision, toRevision, headRev); + fromRevision, toRevision, headRev, logger); processLogMessages(list, messages); } catch (HgException ex) { NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); DialogDisplayer.getDefault().notifyLater(e); + } finally { + logger.closeLog(); } return messages.toArray(new HgLogMessage[0]); @@ -996,8 +1006,8 @@ public class HgCommand { * @return List list of the log entries for the specified file. * @throws org.netbeans.modules.mercurial.HgException */ - public static List doLogShort(File repository, File file) throws HgException { - return doLog(repository, file, HG_LOG_TEMPLATE_SHORT_CMD, false); + public static List doLogShort(File repository, File file, OutputLogger logger) throws HgException { + return doLog(repository, file, HG_LOG_TEMPLATE_SHORT_CMD, false, logger); } /** @@ -1008,8 +1018,8 @@ public class HgCommand { * @return List list of the log entries for the specified file. * @throws org.netbeans.modules.mercurial.HgException */ - public static List doLogLong(File repository, File file) throws HgException { - return doLog(repository, file, HG_LOG_TEMPLATE_LONG_CMD, false); + public static List doLogLong(File repository, File file, OutputLogger logger) throws HgException { + return doLog(repository, file, HG_LOG_TEMPLATE_LONG_CMD, false, logger); } /** @@ -1022,7 +1032,7 @@ public class HgCommand { * @return List list of the log entries for the specified file. * @throws org.netbeans.modules.mercurial.HgException */ - public static List doLog(File repository, File file, String LOG_TEMPLATE, boolean bDebug) throws HgException { + public static List doLog(File repository, File file, String LOG_TEMPLATE, boolean bDebug, OutputLogger logger) throws HgException { if (repository == null ) return null; List command = new ArrayList(); @@ -1043,9 +1053,9 @@ public class HgCommand { List list = exec(command); if (!list.isEmpty()) { if (isErrorNoRepository(list.get(0))) { - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); } else if (isErrorAbort(list.get(0))) { - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); } } return list; @@ -1061,7 +1071,7 @@ public class HgCommand { * @return List list of the log entries for the specified file. * @throws org.netbeans.modules.mercurial.HgException */ - public static List doLog(File repository, List files, String LOG_TEMPLATE, boolean bDebug) throws HgException { + public static List doLog(File repository, List files, String LOG_TEMPLATE, boolean bDebug, OutputLogger logger) throws HgException { if (repository == null ) return null; if (files != null && files.isEmpty()) return null; @@ -1099,9 +1109,9 @@ public class HgCommand { List list = exec(command); if (!list.isEmpty()) { if (isErrorNoRepository(list.get(0))) { - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); } else if (isErrorAbort(list.get(0))) { - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); } } return list; @@ -1118,7 +1128,7 @@ public class HgCommand { * @throws org.netbeans.modules.mercurial.HgException */ public static List doLogForHistory(File repository, List files, - String from, String to, String headRev) throws HgException { + String from, String to, String headRev, OutputLogger logger) throws HgException { if (repository == null ) return null; if (files != null && files.isEmpty()) return null; @@ -1163,9 +1173,9 @@ public class HgCommand { List list = exec(command); if (!list.isEmpty()) { if (isErrorNoRepository(list.get(0))) { - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); } else if (isErrorAbort(list.get(0))) { - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); } } return list; @@ -1178,7 +1188,7 @@ public class HgCommand { * @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 { + public static List doOut(File repository, OutputLogger logger) throws HgException { if (repository == null ) return null; List command = new ArrayList(); @@ -1193,7 +1203,7 @@ public class HgCommand { List list; String defaultPush = new HgConfigFiles(repository).getDefaultPush(false); - String proxy = getGlobalProxyIfNeeded(defaultPush, false); + String proxy = getGlobalProxyIfNeeded(defaultPush, false, null); if(proxy != null){ List env = new ArrayList(); env.add(HG_PROXY_ENV + proxy); @@ -1205,9 +1215,9 @@ public class HgCommand { if(isErrorNoDefaultPush(list.get(0))){ // Ignore }else if (isErrorNoRepository(list.get(0))) { - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); } else if (isErrorAbort(list.get(0))) { - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); } } return list; @@ -1220,7 +1230,7 @@ public class HgCommand { * @return List list of the out entries for the specified repo. * @throws org.netbeans.modules.mercurial.HgException */ - public static List doIncomingForSearch(File repository) throws HgException { + public static List doIncomingForSearch(File repository, OutputLogger logger) throws HgException { if (repository == null ) return null; List command = new ArrayList(); @@ -1234,7 +1244,7 @@ public class HgCommand { List list = exec(command); String defaultPull = new HgConfigFiles(repository).getDefaultPull(false); - String proxy = getGlobalProxyIfNeeded(defaultPull, false); + String proxy = getGlobalProxyIfNeeded(defaultPull, false, null); if(proxy != null){ List env = new ArrayList(); env.add(HG_PROXY_ENV + proxy); @@ -1247,9 +1257,9 @@ public class HgCommand { if (isErrorNoDefaultPath(list.get(0))) { // Ignore } else if (isErrorNoRepository(list.get(0))) { - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); } else if (isErrorAbort(list.get(0)) || isErrorAbort(list.get(list.size() - 1))) { - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); } } return list; @@ -1383,8 +1393,8 @@ public class HgCommand { * @param File outFile to contain the contents of the file * @throws org.netbeans.modules.mercurial.HgException */ - public static void doCat(File repository, File file, File outFile) throws HgException { - doCat(repository, file, outFile, "tip", false); //NOI18N + public static void doCat(File repository, File file, File outFile, OutputLogger logger) throws HgException { + doCat(repository, file, outFile, "tip", false, logger); //NOI18N } /** @@ -1399,11 +1409,11 @@ public class HgCommand { * @return List list of all the log entries * @throws org.netbeans.modules.mercurial.HgException */ - public static void doCat(File repository, File file, File outFile, String revision) throws HgException { - doCat(repository, file, outFile, revision, true); //NOI18N + public static void doCat(File repository, File file, File outFile, String revision, OutputLogger logger) throws HgException { + doCat(repository, file, outFile, revision, true, logger); //NOI18N } - public static void doCat(File repository, File file, File outFile, String revision, boolean retry) throws HgException { + public static void doCat(File repository, File file, File outFile, String revision, boolean retry, OutputLogger logger) throws HgException { if (repository == null) return; if (file == null) return; @@ -1425,9 +1435,9 @@ public class HgCommand { if (!list.isEmpty()) { if (isErrorNoRepository(list.get(0))) { - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); } else if (isErrorAbort(list.get(0))) { - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); } } if (outFile.length() == 0 && retry) { @@ -1435,7 +1445,7 @@ public class HgCommand { String newRevision = Integer.toString(Integer.parseInt(revision)+1); File prevFile = getPreviousName(repository, file, newRevision); if (prevFile != null) { - doCat(repository, prevFile, outFile, revision, false); //NOI18N + doCat(repository, prevFile, outFile, revision, false, logger); //NOI18N } } } @@ -1449,7 +1459,7 @@ public class HgCommand { * @return void * @throws org.netbeans.modules.mercurial.HgException */ - public static void doCreate(File root) throws HgException { + public static void doCreate(File root, OutputLogger logger) throws HgException { if (root == null ) return; List command = new ArrayList(); @@ -1459,7 +1469,7 @@ public class HgCommand { List list = exec(command); if (!list.isEmpty()) - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_CREATE_FAILED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_CREATE_FAILED"), logger); } /** @@ -1470,9 +1480,9 @@ public class HgCommand { * @return clone output * @throws org.netbeans.modules.mercurial.HgException */ - public static List doClone(File repository, String target) throws HgException { + public static List doClone(File repository, String target, OutputLogger logger) throws HgException { if (repository == null) return null; - return doClone(repository.getAbsolutePath(), target); + return doClone(repository.getAbsolutePath(), target, logger); } /** @@ -1483,7 +1493,7 @@ public class HgCommand { * @return clone output * @throws org.netbeans.modules.mercurial.HgException */ - public static List doClone(String repository, String target) throws HgException { + public static List doClone(String repository, String target, OutputLogger logger) throws HgException { if (repository == null || target == null) return null; // Ensure that parent directory of target exists, creating if necessary @@ -1517,11 +1527,11 @@ public class HgCommand { List list = exec(command); if (!list.isEmpty()) { if (isErrorNoRepository(list.get(0))){ - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); }else if (isErrorNoResponse(list.get(list.size() -1))){ - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_RESPONSE_ERR")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_RESPONSE_ERR"), logger); }else if (isErrorAbort(list.get(list.size() -1))){ - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); } } return list; @@ -1536,7 +1546,7 @@ public class HgCommand { * @return void * @throws org.netbeans.modules.mercurial.HgException */ - public static void doCommit(File repository, List commitFiles, String commitMessage) throws HgException { + public static void doCommit(File repository, List commitFiles, String commitMessage, OutputLogger logger) throws HgException { List command = new ArrayList(); command.add(getHgCommand()); @@ -1581,7 +1591,7 @@ public class HgCommand { if (!list.isEmpty() && (isErrorNotTracked(list.get(0)) || isErrorCannotReadCommitMsg(list.get(0)))) - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMIT_FAILED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMIT_FAILED"), logger); }catch (IOException ex){ throw new HgException(NbBundle.getMessage(HgCommand.class, "MSG_FAILED_TO_READ_COMMIT_MESSAGE")); @@ -1604,11 +1614,11 @@ public class HgCommand { * @return void * @throws org.netbeans.modules.mercurial.HgException */ - public static void doRename(File repository, File sourceFile, File destFile) throws HgException { - doRename(repository, sourceFile, destFile, false); + public static void doRename(File repository, File sourceFile, File destFile, OutputLogger logger) throws HgException { + doRename(repository, sourceFile, destFile, false, logger); } - private static void doRename(File repository, File sourceFile, File destFile, boolean bAfter) throws HgException { + private static void doRename(File repository, File sourceFile, File destFile, boolean bAfter, OutputLogger logger) throws HgException { if (repository == null) return; List command = new ArrayList(); @@ -1628,7 +1638,7 @@ public class HgCommand { if (!list.isEmpty() && isErrorAbort(list.get(list.size() -1))) { if (!bAfter || !isErrorAbortNoFilesToCopy(list.get(list.size() -1))) { - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_RENAME_FAILED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_RENAME_FAILED"), logger); } } } @@ -1643,8 +1653,8 @@ public class HgCommand { * @return void * @throws org.netbeans.modules.mercurial.HgException */ - public static void doRenameAfter(File repository, File sourceFile, File destFile) throws HgException { - doRename(repository, sourceFile, destFile, true); + public static void doRenameAfter(File repository, File sourceFile, File destFile, OutputLogger logger) throws HgException { + doRename(repository, sourceFile, destFile, true, logger); } /** @@ -1657,7 +1667,7 @@ public class HgCommand { * @return void * @throws org.netbeans.modules.mercurial.HgException */ - public static void doAdd(File repository, List addFiles) throws HgException { + public static void doAdd(File repository, List addFiles, OutputLogger logger) throws HgException { if (repository == null) return; if (addFiles.size() == 0) return; List command = new ArrayList(); @@ -1676,7 +1686,7 @@ public class HgCommand { } List list = exec(command); if (!list.isEmpty() && isErrorAlreadyTracked(list.get(0))) - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_ALREADY_TRACKED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_ALREADY_TRACKED"), logger); } /** @@ -1689,7 +1699,7 @@ public class HgCommand { * @throws org.netbeans.modules.mercurial.HgException */ public static void doRevert(File repository, List revertFiles, - String revision, boolean doBackup) throws HgException { + String revision, boolean doBackup, OutputLogger logger) throws HgException { if (repository == null) return; if (revertFiles.size() == 0) return; @@ -1712,7 +1722,7 @@ public class HgCommand { } List list = exec(command); if (!list.isEmpty() && isErrorNoChangeNeeded(list.get(0))) - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_REVERT_FAILED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_REVERT_FAILED"), logger); } /** @@ -1725,7 +1735,7 @@ public class HgCommand { * @return void * @throws org.netbeans.modules.mercurial.HgException */ - public static void doAdd(File repository, File file) throws HgException { + public static void doAdd(File repository, File file, OutputLogger logger) throws HgException { if (repository == null) return; if (file == null) return; if (file.isDirectory()) return; @@ -1742,7 +1752,7 @@ public class HgCommand { command.add(file.getAbsolutePath()); List list = exec(command); if (!list.isEmpty() && isErrorAlreadyTracked(list.get(0))) - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_ALREADY_TRACKED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_ALREADY_TRACKED"), logger); } /** @@ -1754,7 +1764,7 @@ public class HgCommand { * @return List list of the annotated lines of the file * @throws org.netbeans.modules.mercurial.HgException */ - public static List doAnnotate(File repository, File file, String revision) throws HgException { + public static List doAnnotate(File repository, File file, String revision, OutputLogger logger) throws HgException { if (repository == null) return null; List command = new ArrayList(); @@ -1774,14 +1784,14 @@ public class HgCommand { List list = exec(command); if (!list.isEmpty()) { if (isErrorNoRepository(list.get(0))) { - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); } else if (isErrorNoSuchFile(list.get(0))) { // This can happen if we have multiple heads and the wrong // one was picked by default hg annotation if (revision == null) { String rev = getLastRevision(repository, file); if (rev != null) { - list = doAnnotate(repository, file, rev); + list = doAnnotate(repository, file, rev, logger); } else { list = null; } @@ -1793,8 +1803,8 @@ public class HgCommand { return list; } - public static List doAnnotate(File repository, File file) throws HgException { - return doAnnotate(repository, file, null); + public static List doAnnotate(File repository, File file, OutputLogger logger) throws HgException { + return doAnnotate(repository, file, null, logger); } /** @@ -2258,7 +2268,7 @@ public class HgCommand { * @param f path to be removed from the repository * @throws org.netbeans.modules.mercurial.HgException */ - public static void doRemove(File repository, File f) throws HgException { + public static void doRemove(File repository, File f, OutputLogger logger) throws HgException { List command = new ArrayList(); command.add(getHgCommand()); @@ -2270,7 +2280,7 @@ public class HgCommand { List list = exec(command); if (!list.isEmpty() && isErrorAlreadyTracked(list.get(0))) - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_ALREADY_TRACKED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_ALREADY_TRACKED"), logger); } /** @@ -2281,7 +2291,7 @@ public class HgCommand { * @param outputFileName path of the output file * @throws org.netbeans.modules.mercurial.HgException */ - public static List doExport(File repository, String revStr, String outputFileName) throws HgException { + public static List doExport(File repository, String revStr, String outputFileName, OutputLogger logger) throws HgException { // Ensure that parent directory of target exists, creating if necessary File fileTarget = new File (outputFileName); File parentTarget = fileTarget.getParentFile(); @@ -2310,7 +2320,7 @@ public class HgCommand { List list = exec(command); if (!list.isEmpty() && isErrorAbort(list.get(list.size() -1))) { - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_EXPORT_FAILED")); + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_EXPORT_FAILED"), logger); } return list; } @@ -2322,7 +2332,7 @@ public class HgCommand { * @param File patchFile of the patch file * @throws org.netbeans.modules.mercurial.HgException */ - public static List doImport(File repository, File patchFile) throws HgException { + public static List doImport(File repository, File patchFile, OutputLogger logger) throws HgException { List command = new ArrayList(); command.add(getHgCommand()); @@ -2337,8 +2347,8 @@ public class HgCommand { List list = exec(command); if (!list.isEmpty() && isErrorAbort(list.get(list.size() -1))) { - HgUtils.outputMercurialTab(list); // need the failure info from import - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_IMPORT_FAILED")); + logger.output(list); // need the failure info from import + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_IMPORT_FAILED"), logger); } return list; } @@ -2504,8 +2514,14 @@ public class HgCommand { } List list = exec(command); - if (!list.isEmpty() && isErrorNoRepository(list.get(0))) - handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); + if (!list.isEmpty() && isErrorNoRepository(list.get(0))) { + OutputLogger logger = OutputLogger.getLogger(repository.getAbsolutePath()); + try { + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); + } finally { + logger.closeLog(); + } + } return list; } /** @@ -2644,12 +2660,12 @@ public class HgCommand { return defaultPath + File.separatorChar + HG_COMMAND; } - private static void handleError(List command, List list, String message) throws HgException{ + private static void handleError(List command, List list, String message, OutputLogger logger) throws HgException{ if (command != null && list != null){ Mercurial.LOG.log(Level.WARNING, "command: " + HgUtils.replaceHttpPassword(command)); // NOI18N Mercurial.LOG.log(Level.WARNING, "output: " + HgUtils.replaceHttpPassword(list)); // NOI18N - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ERR")); // NOI18N - HgUtils.outputMercurialTab(NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_INFO_ERR", + logger.outputInRed(NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ERR")); // NOI18N + logger.output(NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_INFO_ERR", HgUtils.replaceHttpPassword(command), HgUtils.replaceHttpPassword(list))); // NOI18N } diff -r c174e5a9390d -r c1ae42bfee9b mercurial/src/org/netbeans/modules/mercurial/util/HgUtils.java --- a/mercurial/src/org/netbeans/modules/mercurial/util/HgUtils.java Thu Feb 21 12:05:29 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/util/HgUtils.java Thu Feb 21 11:08:54 2008 +0000 @@ -50,7 +50,6 @@ import java.io.IOException; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; -import java.net.URL; import java.text.SimpleDateFormat; import java.util.List; import java.util.Arrays; @@ -78,9 +77,6 @@ import org.openide.windows.OutputEvent; import org.openide.windows.OutputEvent; import org.openide.windows.TopComponent; import org.netbeans.modules.versioning.spi.VCSContext; -import org.openide.windows.IOProvider; -import org.openide.windows.InputOutput; -import org.openide.windows.OutputWriter; import java.util.Calendar; import java.util.Date; import java.util.HashMap; @@ -98,9 +94,6 @@ import org.netbeans.api.project.FileOwne import org.netbeans.api.project.FileOwnerQuery; import org.netbeans.api.project.ProjectManager; import org.netbeans.api.queries.SharabilityQuery; -import org.netbeans.modules.mercurial.HgProgressSupport; -import org.openide.awt.HtmlBrowser; -import org.openide.util.RequestProcessor; import org.openide.util.Utilities; import org.openide.windows.OutputListener; @@ -124,10 +117,6 @@ public class HgUtils { private static final String HG_IGNORE_CONFLICT_ANY_FILES = "\\.conflict\\~$"; // NOI18N private static final String FILENAME_HGIGNORE = ".hgignore"; // NOI18N - - public static final int MAX_LINES_TO_PRINT = 500; - - private static final String MSG_TOO_MANY_LINES = "The number of output lines is greater than 500; see message log for complete output"; private static HashMap> ignorePatterns; @@ -1072,127 +1061,6 @@ itor tabs #66700). } } - - /** - * Print contents of list to Mercurial Output Tab - * - * @param list to print out - * - */ - public static void outputMercurialTab(List list){ - if( list.isEmpty()) return; - - InputOutput io = IOProvider.getDefault().getIO(Mercurial.MERCURIAL_OUTPUT_TAB_TITLE, false); - io.select(); - OutputWriter out = io.getOut(); - - int lines = list.size(); - if (lines > MAX_LINES_TO_PRINT) { - out.println(list.get(1)); - out.println(list.get(2)); - out.println(list.get(3)); - out.println("..."); - out.println(list.get(list.size() -1)); - out.println(MSG_TOO_MANY_LINES); - for (String s : list){ - Mercurial.LOG.log(Level.WARNING, s); - } - } else { - for (String s : list){ - out.println(s); - - } - } - out.close(); - } - - /** - * Print msg to Mercurial Output Tab - * - * @param String msg to print out - * - */ - public static void outputMercurialTab(String msg){ - if( msg == null) return; - - InputOutput io = IOProvider.getDefault().getIO(Mercurial.MERCURIAL_OUTPUT_TAB_TITLE, false); - io.select(); - OutputWriter out = io.getOut(); - - out.println(msg); - out.close(); - } - - /** - * Print msg to Mercurial Output Tab in Red - * - * @param String msg to print out - * - */ - public static void outputMercurialTabInRed(String msg){ - if( msg == null) return; - - InputOutput io = IOProvider.getDefault().getIO(Mercurial.MERCURIAL_OUTPUT_TAB_TITLE, false); - io.select(); - OutputWriter out = io.getErr(); - - out.println(msg); - out.close(); - } - - /** - * Print URL to Mercurial Output Tab as an active Hyperlink - * - * @param String sURL to print out - * - */ - public static void outputMercurialTabLink(final String sURL){ - if (sURL == null) return; - - try { - InputOutput io = IOProvider.getDefault().getIO(Mercurial.MERCURIAL_OUTPUT_TAB_TITLE, false); - io.select(); - OutputWriter out = io.getOut(); - - OutputListener listener = new OutputListener() { - public void outputLineAction(OutputEvent ev) { - try { - HtmlBrowser.URLDisplayer.getDefault().showURL(new URL(sURL)); - } catch (IOException ex) { - // Ignore - } - } - public void outputLineSelected(OutputEvent ev) {} - public void outputLineCleared(OutputEvent ev) {} - }; - out.println(sURL, listener, true); - out.close(); - } catch (IOException ex) { - // Ignore - } - } - - /** - * Select and Clear Mercurial Output Tab - * - * @param list to print out - * - */ - public static void clearOutputMercurialTab(){ - InputOutput io = IOProvider.getDefault().getIO( - Mercurial.MERCURIAL_OUTPUT_TAB_TITLE, false); - - io.select(); - OutputWriter out = io.getOut(); - - try { - out.reset(); - } catch (IOException ex) { - // Ignore Exception - } - out.close(); - } - /** * This utility class should not be instantiated anywhere. */