diff options
author | Mathias Kinzler | 2010-03-29 14:22:51 +0000 |
---|---|---|
committer | Mathias Kinzler | 2010-03-29 14:22:51 +0000 |
commit | 1aa2a8552f15015fbbd645689df882981863e0a1 (patch) | |
tree | b05740bad64e44b3766d652b4b87459a9dc2d593 | |
parent | b43494e82a187fbd6be96bf4b11cf96da66e1dcb (diff) | |
download | egit-1aa2a8552f15015fbbd645689df882981863e0a1.tar.gz egit-1aa2a8552f15015fbbd645689df882981863e0a1.tar.xz egit-1aa2a8552f15015fbbd645689df882981863e0a1.zip |
Replace System.out with proper tracing
Bug: 306793
Change-Id: I2afb00b153506b653d088517c2adc8ea841412f2
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
25 files changed, 431 insertions, 137 deletions
diff --git a/org.eclipse.egit.core/.options b/org.eclipse.egit.core/.options index ef2dc61043..36f7a0db3d 100644 --- a/org.eclipse.egit.core/.options +++ b/org.eclipse.egit.core/.options @@ -1 +1,6 @@ -org.eclipse.egit.core/trace/verbose = false +# Main Debug Trace switch +org.eclipse.egit.core/debug = false +# General trace location for the EGit Core Plugin +org.eclipse.egit.core/debug/core = false +# General trace location for the EGit UI Plugin +org.eclipse.egit.core/debug/ui = false diff --git a/org.eclipse.egit.core/META-INF/MANIFEST.MF b/org.eclipse.egit.core/META-INF/MANIFEST.MF index 029397b3b3..44a6adaf72 100644 --- a/org.eclipse.egit.core/META-INF/MANIFEST.MF +++ b/org.eclipse.egit.core/META-INF/MANIFEST.MF @@ -12,6 +12,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)", org.eclipse.core.filesystem;bundle-version="[1.2.0,2.0.0)" Export-Package: org.eclipse.egit.core;version="0.8.0", org.eclipse.egit.core.internal.storage;version="0.8.0";x-friends:="org.eclipse.egit.ui", + org.eclipse.egit.core.internal.trace;version="0.8.0";x-friends:="org.eclipse.egit.ui", org.eclipse.egit.core.internal.util;version="0.8.0";x-friends:="org.eclipse.egit.ui", org.eclipse.egit.core.op;version="0.8.0", org.eclipse.egit.core.project;version="0.8.0" diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java index bbc3c50935..572c14628e 100644 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java @@ -9,19 +9,23 @@ *******************************************************************************/ package org.eclipse.egit.core; +import java.util.Hashtable; + import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.Status; +import org.eclipse.egit.core.internal.trace.GitTraceLocation; import org.eclipse.egit.core.project.GitProjectData; +import org.eclipse.osgi.service.debug.DebugOptions; +import org.eclipse.osgi.service.debug.DebugOptionsListener; import org.osgi.framework.BundleContext; /** * The plugin class for the org.eclipse.egit.core plugin. This * is a singleton class. */ -public class Activator extends Plugin { +public class Activator extends Plugin implements DebugOptionsListener { private static Activator plugin; /** @@ -61,25 +65,6 @@ public class Activator extends Plugin { new Status(IStatus.ERROR, getPluginId(), 0, message, thr)); } - private static boolean isOptionSet(final String optionId) { - final String option = getPluginId() + optionId; - final String value = Platform.getDebugOption(option); - return value != null && value.equals("true"); //$NON-NLS-1$ - } - - /** - * Utility method for debug logging. - * - * @param what - */ - public static void trace(final String what) { - if (getDefault().traceVerbose) { - System.out.println("[" + getPluginId() + "] " + what); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - private boolean traceVerbose; - /** * Construct the {@link Activator} singleton instance */ @@ -89,7 +74,12 @@ public class Activator extends Plugin { public void start(final BundleContext context) throws Exception { super.start(context); - traceVerbose = isOptionSet("/trace/verbose"); //$NON-NLS-1$ + // register this as DebugOptions listener + Hashtable<String, String> props = new Hashtable<String, String>(4); + // we want to get notified about our own DebugOptions + props.put(DebugOptions.LISTENER_SYMBOLICNAME, context.getBundle().getSymbolicName()); + context.registerService(DebugOptionsListener.class.getName(), this, props); + GitProjectData.reconfigureWindowCache(); GitProjectData.attachToWorkspace(true); } @@ -99,4 +89,8 @@ public class Activator extends Plugin { super.stop(context); plugin = null; } + + public void optionsChanged(DebugOptions options) { + GitTraceLocation.initializeFromOptions(options, isDebugging()); + } } diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/UpdateJob.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/UpdateJob.java index 85561b0eb0..6c78fc023d 100644 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/UpdateJob.java +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/UpdateJob.java @@ -30,6 +30,7 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.egit.core.Activator; import org.eclipse.egit.core.CoreText; +import org.eclipse.egit.core.internal.trace.GitTraceLocation; import org.eclipse.egit.core.project.RepositoryMapping; import org.eclipse.jgit.errors.NotSupportedException; import org.eclipse.jgit.lib.GitIndex; @@ -83,9 +84,13 @@ public class UpdateJob extends Job { } } long t1=System.currentTimeMillis(); - System.out.println("Counted " + count[0] //$NON-NLS-1$ - + " items to update in " //$NON-NLS-1$ - + (t1 - t0) / 1000.0 + "s"); //$NON-NLS-1$ + // TODO is this the right location? + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.CORE.getLocation(), + "Counted " + count[0] //$NON-NLS-1$ + + " items to update in " //$NON-NLS-1$ + + (t1 - t0) / 1000.0 + "s"); //$NON-NLS-1$ m.beginTask(CoreText.UpdateOperation_updating, count[0]); final IProgressMonitor fm = m; for (Object obj : rsrcList) { @@ -107,7 +112,8 @@ public class UpdateJob extends Job { fm.worked(1); } } catch (IOException e) { - e.printStackTrace(); + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e); throw Activator.error(CoreText.UpdateOperation_failed, e); } return true; @@ -131,13 +137,16 @@ public class UpdateJob extends Job { } catch (NotSupportedException e) { return Activator.error(e.getMessage(),e).getStatus(); } catch (RuntimeException e) { - e.printStackTrace(); + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e); return Activator.error(CoreText.UpdateOperation_failed, e).getStatus(); } catch (IOException e) { - e.printStackTrace(); + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e); return Activator.error(CoreText.UpdateOperation_failed, e).getStatus(); } catch (CoreException e) { - e.printStackTrace(); + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e); return Activator.error(CoreText.UpdateOperation_failed, e).getStatus(); } finally { try { @@ -148,7 +157,8 @@ public class UpdateJob extends Job { r.fireRepositoryChanged(); } } catch (IOException e) { - e.printStackTrace(); + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e); } finally { m.done(); } @@ -162,7 +172,10 @@ public class UpdateJob extends Job { } private void trace(final String m) { - Activator.trace("(UpdateJob)"+m); //$NON-NLS-1$ + // TODO is this the right location? + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.CORE.getLocation(), "(UpdateJob)" + m); } } diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/trace/GitTraceLocation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/trace/GitTraceLocation.java new file mode 100644 index 0000000000..92f8510f19 --- /dev/null +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/trace/GitTraceLocation.java @@ -0,0 +1,103 @@ +/*******************************************************************************
+ * Copyright (c) 2010 SAP AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mathias Kinzler (SAP AG) - initial implementation
+ *******************************************************************************/
+package org.eclipse.egit.core.internal.trace;
+
+import org.eclipse.egit.core.Activator;
+import org.eclipse.osgi.service.debug.DebugOptions;
+import org.eclipse.osgi.service.debug.DebugTrace;
+
+/**
+ * EGit Trace locations
+ *
+ */
+public enum GitTraceLocation implements ITraceLocation {
+ /** Core */
+ CORE("/debug/core"), //$NON-NLS-1$
+ /** UI */
+ UI("/debug/ui"); //$NON-NLS-1$
+
+ /**
+ * Initialize the locations
+ *
+ * @param options
+ * @param pluginIsDebugging
+ */
+ public static void initializeFromOptions(DebugOptions options, boolean pluginIsDebugging) {
+
+ // we evaluate the plug-in switch
+ if (pluginIsDebugging) {
+ myTrace = options.newDebugTrace(Activator.getPluginId());
+ for (GitTraceLocation loc : values()) {
+ boolean active = options.getBooleanOption(loc.getFullPath(), false);
+ loc.setActive(active);
+ }
+ } else {
+ // if the plug-in switch is off, we don't set the trace instance
+ // to null to avoid problems with possibly running trace calls
+ for (GitTraceLocation loc : values()) {
+ loc.setActive(false);
+ }
+ }
+ }
+
+ private final String location;
+ private final String fullPath;
+
+ private boolean active = false;
+ private static DebugTrace myTrace;
+
+ private GitTraceLocation(String path) {
+ this.fullPath = Activator.getPluginId() + path;
+ this.location = path;
+ }
+
+ /**
+ * Convenience method
+ *
+ * @return the debug trace (may be null)
+ *
+ **/
+ public static DebugTrace getTrace() {
+ return GitTraceLocation.myTrace;
+ }
+
+ /**
+ *
+ * @return <code>true</code> if this location is active
+ */
+ public boolean isActive() {
+ return this.active;
+ }
+
+ /**
+ * @return the full path
+ */
+ public String getFullPath() {
+ return this.fullPath;
+ }
+
+ public String getLocation() {
+ return this.location;
+ }
+
+ /**
+ * Sets the "active" flag for this location.
+ * <p>
+ * Used by the initializer
+ *
+ * @param active
+ * the "active" flag
+ */
+ private void setActive(boolean active) {
+ this.active = active;
+ }
+
+}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/trace/ITraceLocation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/trace/ITraceLocation.java new file mode 100644 index 0000000000..5465111206 --- /dev/null +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/trace/ITraceLocation.java @@ -0,0 +1,31 @@ +/*******************************************************************************
+ * Copyright (c) 2010 SAP AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mathias Kinzler (SAP AG) - initial implementation
+ *******************************************************************************/
+package org.eclipse.egit.core.internal.trace;
+
+/**
+ * Helper interface for trace location management
+ * <p>
+ * Additional methods could return a description or such...
+ *
+ */
+public interface ITraceLocation {
+
+ /**
+ * @return the location, e.g. "/debug/mainArea/subArea"
+ */
+ public String getLocation();
+
+ /**
+ * @return <code>true</code> if the location is active
+ */
+ public boolean isActive();
+
+}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/BranchOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/BranchOperation.java index e7b331322f..bf629a4b49 100644 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/BranchOperation.java +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/BranchOperation.java @@ -20,6 +20,7 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.egit.core.CoreText; +import org.eclipse.egit.core.internal.trace.GitTraceLocation; import org.eclipse.osgi.util.NLS; import org.eclipse.team.core.TeamException; import org.eclipse.jgit.errors.CheckoutConflictException; @@ -93,10 +94,15 @@ public class BranchOperation implements IWorkspaceRunnable { final File file = p.getLocation().toFile(); if (file.getAbsolutePath().startsWith(parentFile.getAbsolutePath())) { try { - System.out.println("Refreshing " + p); //$NON-NLS-1$ + // TODO is this the right location? + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.CORE.getLocation(), + "Refreshing " + p); //$NON-NLS-1$ p.refreshLocal(IResource.DEPTH_INFINITE, null); } catch (CoreException e) { - e.printStackTrace(); + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e); } } } diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConnectProviderOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConnectProviderOperation.java index 45c6707a6d..b1777ef7b8 100644 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConnectProviderOperation.java +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConnectProviderOperation.java @@ -25,9 +25,9 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.egit.core.Activator; import org.eclipse.egit.core.CoreText; import org.eclipse.egit.core.GitProvider; +import org.eclipse.egit.core.internal.trace.GitTraceLocation; import org.eclipse.egit.core.project.GitProjectData; import org.eclipse.egit.core.project.RepositoryFinder; import org.eclipse.egit.core.project.RepositoryMapping; @@ -90,7 +90,12 @@ public class ConnectProviderOperation implements IWorkspaceRunnable { m.setTaskName(NLS.bind( CoreText.ConnectProviderOperation_ConnectingProject, project.getName())); - Activator.trace("Locating repository for " + project); //$NON-NLS-1$ + // TODO is this the right location? + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.CORE.getLocation(), + "Locating repository for " + project); + Collection<RepositoryMapping> repos = new RepositoryFinder( project).find(new SubProgressMonitor(m, 40)); File suggestedRepo = projects.get(project); @@ -114,9 +119,12 @@ public class ConnectProviderOperation implements IWorkspaceRunnable { new SubProgressMonitor(m, 50)); m.worked(10); } else { - Activator - .trace("Attempted to share project without repository ignored :" //$NON-NLS-1$ - + project); + // TODO is this the right location? + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.CORE.getLocation(), + "Attempted to share project without repository ignored :" //$NON-NLS-1$ + + project); m.worked(60); } } diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/DisconnectProviderOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/DisconnectProviderOperation.java index 9a2dd3afb8..0fd4b71c83 100644 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/DisconnectProviderOperation.java +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/DisconnectProviderOperation.java @@ -19,8 +19,8 @@ import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.egit.core.Activator; import org.eclipse.egit.core.CoreText; +import org.eclipse.egit.core.internal.trace.GitTraceLocation; import org.eclipse.team.core.RepositoryProvider; /** @@ -56,8 +56,11 @@ public class DisconnectProviderOperation implements IWorkspaceRunnable { obj = ((IAdaptable)obj).getAdapter(IResource.class); if (obj instanceof IProject) { final IProject p = (IProject) obj; - - Activator.trace("disconnect " + p.getName()); //$NON-NLS-1$ + // TODO is this the right location? + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.CORE.getLocation(), + "disconnect " + p.getName()); //$NON-NLS-1$ unmarkTeamPrivate(p); RepositoryProvider.unmap(p); m.worked(100); @@ -82,7 +85,11 @@ public class DisconnectProviderOperation implements IWorkspaceRunnable { unmarkTeamPrivate((IContainer) c[k]); } if (c[k].isTeamPrivateMember()) { - Activator.trace("notTeamPrivate " + c[k]); //$NON-NLS-1$ + // TODO is this the right location? + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.CORE.getLocation(), + "notTeamPrivate " + c[k]); //$NON-NLS-1$ c[k].setTeamPrivateMember(false); } } diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ResetOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ResetOperation.java index a6bef45228..2642432547 100644 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ResetOperation.java +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ResetOperation.java @@ -20,6 +20,7 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.egit.core.CoreText; +import org.eclipse.egit.core.internal.trace.GitTraceLocation; import org.eclipse.jgit.lib.Commit; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.GitIndex; @@ -134,10 +135,15 @@ public class ResetOperation implements IWorkspaceRunnable { final File file = p.getLocation().toFile(); if (file.getAbsolutePath().startsWith(parentFile.getAbsolutePath())) { try { - System.out.println("Refreshing " + p); //$NON-NLS-1$ + // TODO is this the right location? + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.CORE.getLocation(), + "Refreshing " + p); //$NON-NLS-1$ p.refreshLocal(IResource.DEPTH_INFINITE, null); } catch (CoreException e) { - e.printStackTrace(); + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e); } } } diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/TrackOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/TrackOperation.java index 1d12422282..d46a143910 100644 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/TrackOperation.java +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/TrackOperation.java @@ -27,6 +27,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.egit.core.Activator; import org.eclipse.egit.core.CoreText; +import org.eclipse.egit.core.internal.trace.GitTraceLocation; import org.eclipse.egit.core.project.RepositoryMapping; import org.eclipse.osgi.util.NLS; import org.eclipse.team.core.Team; @@ -80,8 +81,14 @@ public class TrackOperation implements IWorkspaceRunnable { Entry entry = index.getEntry(repoPath); if (entry != null) { if (!entry.isAssumedValid()) { - System.out - .println("Already tracked - skipping"); //$NON-NLS-1$ + // TODO is this the right location? + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation + .getTrace() + .trace( + GitTraceLocation.CORE + .getLocation(), + "Already tracked - skipping"); //$NON-NLS-1$ continue; } } @@ -109,7 +116,8 @@ public class TrackOperation implements IWorkspaceRunnable { return false; } catch (IOException e) { - e.printStackTrace(); + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e); throw Activator.error(CoreText.AddOperation_failed, e); } return true; @@ -128,10 +136,12 @@ public class TrackOperation implements IWorkspaceRunnable { rm.getRepository().getIndex().write(); } } catch (RuntimeException e) { - e.printStackTrace(); + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e); throw Activator.error(CoreText.AddOperation_failed, e); } catch (IOException e) { - e.printStackTrace(); + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e); throw Activator.error(CoreText.AddOperation_failed, e); } finally { try { @@ -142,7 +152,8 @@ public class TrackOperation implements IWorkspaceRunnable { r.fireRepositoryChanged(); } } catch (IOException e) { - e.printStackTrace(); + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e); } finally { m.done(); } diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java index 821e879e5b..a2628b6c1f 100644 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java @@ -39,6 +39,7 @@ import org.eclipse.egit.core.Activator; import org.eclipse.egit.core.CoreText; import org.eclipse.egit.core.GitCorePreferences; import org.eclipse.egit.core.GitProvider; +import org.eclipse.egit.core.internal.trace.GitTraceLocation; import org.eclipse.osgi.util.NLS; import org.eclipse.team.core.RepositoryProvider; import org.eclipse.jgit.lib.Constants; @@ -191,7 +192,11 @@ public class GitProjectData { } static void trace(final String m) { - Activator.trace("(GitProjectData) " + m); //$NON-NLS-1$ + // TODO is this the right location? + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.CORE.getLocation(), + "(GitProjectData) " + m); //$NON-NLS-1$ } private synchronized static void cache(final IProject p, diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryFinder.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryFinder.java index ffe4fc0a93..481f7098a6 100644 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryFinder.java +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryFinder.java @@ -27,6 +27,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.egit.core.CoreText; +import org.eclipse.egit.core.internal.trace.GitTraceLocation; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.util.SystemReader; @@ -113,9 +114,12 @@ public class RepositoryFinder { if (c.isLinked() || c instanceof IProject) { File p = fsLoc.getParentFile(); while (p != null) { - System.out.println( - "Looking at candidate dir: " //$NON-NLS-1$ - + p); + // TODO is this the right location? + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.CORE.getLocation(), + "Looking at candidate dir: " //$NON-NLS-1$ + + p); final File pCfg = configFor(p); if (pCfg.isFile()) { register(c, pCfg.getParentFile()); diff --git a/org.eclipse.egit.ui/.options b/org.eclipse.egit.ui/.options deleted file mode 100644 index d18ab48657..0000000000 --- a/org.eclipse.egit.ui/.options +++ /dev/null @@ -1 +0,0 @@ -org.eclipse.egit.ui/trace/verbose = false diff --git a/org.eclipse.egit.ui/META-INF/MANIFEST.MF b/org.eclipse.egit.ui/META-INF/MANIFEST.MF index 53403f93d2..eca6df080f 100644 --- a/org.eclipse.egit.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.egit.ui/META-INF/MANIFEST.MF @@ -25,6 +25,7 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5 Import-Package: com.jcraft.jsch;version="[0.1.41,0.2.0)", org.eclipse.egit.core;version="[0.8.0,0.9.0)", org.eclipse.egit.core.internal.storage;version="[0.8.0,0.9.0)", + org.eclipse.egit.core.internal.trace;version="0.8.0", org.eclipse.egit.core.internal.util;version="[0.8.0,0.9.0)", org.eclipse.egit.core.op;version="[0.8.0,0.9.0)", org.eclipse.egit.core.project;version="[0.8.0,0.9.0)", diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java index d9b05fa4d2..3d18d88e0f 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java @@ -25,14 +25,19 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.egit.core.internal.trace.GitTraceLocation; import org.eclipse.egit.core.project.RepositoryMapping; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.jgit.lib.IndexChangedEvent; +import org.eclipse.jgit.lib.RefsChangedEvent; +import org.eclipse.jgit.lib.Repository; +import org.eclipse.jgit.lib.RepositoryListener; +import org.eclipse.jgit.transport.SshSessionFactory; import org.eclipse.jsch.core.IJSchService; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.widgets.Display; @@ -40,11 +45,6 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.ui.themes.ITheme; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; -import org.eclipse.jgit.lib.IndexChangedEvent; -import org.eclipse.jgit.lib.RefsChangedEvent; -import org.eclipse.jgit.lib.Repository; -import org.eclipse.jgit.lib.RepositoryListener; -import org.eclipse.jgit.transport.SshSessionFactory; /** * This is a plugin singleton mostly controlling logging. @@ -123,29 +123,6 @@ public class Activator extends AbstractUIPlugin { } /** - * @param optionId - * name of debug option - * @return whether a named debug option is set - */ - private static boolean isOptionSet(final String optionId) { - final String option = getPluginId() + optionId; - final String value = Platform.getDebugOption(option); - return value != null && value.equals("true"); //$NON-NLS-1$ - } - - /** - * Log a debug message - * - * @param what - * message to log - */ - public static void trace(final String what) { - if (getDefault().traceVerbose) { - System.out.println("[" + getPluginId() + "] " + what); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** * Get the theme used by this plugin. * * @return our theme. @@ -178,7 +155,6 @@ public class Activator extends AbstractUIPlugin { return getTheme().getFontRegistry().getBold(id); } - private boolean traceVerbose; private RCS rcs; private RIRefresh refreshJob; @@ -191,7 +167,6 @@ public class Activator extends AbstractUIPlugin { public void start(final BundleContext context) throws Exception { super.start(context); - traceVerbose = isOptionSet("/trace/verbose"); //$NON-NLS-1$ setupSSH(context); setupProxy(context); setupRepoChangeScanner(); @@ -325,7 +300,11 @@ public class Activator extends AbstractUIPlugin { if (!scanned.contains(r)) { if (monitor.isCanceled()) break; - trace("Scanning " + r + " for changes"); //$NON-NLS-1$ //$NON-NLS-2$ + // TODO is this the right location? + if (GitTraceLocation.UI.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.UI.getLocation(), + "Scanning " + r + " for changes"); //$NON-NLS-1$ //$NON-NLS-2$ scanned.add(r); ISchedulingRule rule = p.getWorkspace().getRuleFactory().modifyRule(p); getJobManager().beginRule(rule, monitor); @@ -339,10 +318,18 @@ public class Activator extends AbstractUIPlugin { monitor.worked(1); } monitor.done(); - trace("Rescheduling " + getName() + " job"); //$NON-NLS-1$ //$NON-NLS-2$ + // TODO is this the right location? + if (GitTraceLocation.UI.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.UI.getLocation(), + "Rescheduling " + getName() + " job"); //$NON-NLS-1$ //$NON-NLS-2$ schedule(REPO_SCAN_INTERVAL); } catch (Exception e) { - trace("Stopped rescheduling " + getName() + "job"); //$NON-NLS-1$ //$NON-NLS-2$ + // TODO is this the right location? + if (GitTraceLocation.UI.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.UI.getLocation(), + "Stopped rescheduling " + getName() + "job"); //$NON-NLS-1$ //$NON-NLS-2$ return new Status( IStatus.ERROR, getPluginId(), @@ -382,15 +369,23 @@ public class Activator extends AbstractUIPlugin { } public void stop(final BundleContext context) throws Exception { - trace("Trying to cancel " + rcs.getName() + " job"); //$NON-NLS-1$ //$NON-NLS-2$ + if (GitTraceLocation.UI.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.UI.getLocation(), + "Trying to cancel " + rcs.getName() + " job"); //$NON-NLS-1$ //$NON-NLS-2$ rcs.cancel(); - trace("Trying to cancel " + refreshJob.getName() + " job"); //$NON-NLS-1$ //$NON-NLS-2$ + if (GitTraceLocation.UI.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.UI.getLocation(), + "Trying to cancel " + refreshJob.getName() + " job"); //$NON-NLS-1$ //$NON-NLS-2$ refreshJob.cancel(); rcs.join(); refreshJob.join(); - trace("Jobs terminated"); //$NON-NLS-1$ + if (GitTraceLocation.UI.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.UI.getLocation(), "Jobs terminated"); //$NON-NLS-1$ super.stop(context); plugin = null; } diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/GitResourceNode.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/GitResourceNode.java index b41fc4deae..1060c5372f 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/GitResourceNode.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/GitResourceNode.java @@ -19,6 +19,7 @@ import org.eclipse.compare.CompareUI; import org.eclipse.compare.ITypedElement; import org.eclipse.compare.structuremergeviewer.IStructureComparator; import org.eclipse.core.runtime.CoreException; +import org.eclipse.egit.core.internal.trace.GitTraceLocation; import org.eclipse.swt.graphics.Image; import org.eclipse.jgit.lib.FileTreeEntry; import org.eclipse.jgit.lib.ObjectId; @@ -55,7 +56,8 @@ public class GitResourceNode extends BufferedContent implements IStructureCompar } } catch (IOException e) { // TODO: eclipse error handling - e.printStackTrace(); + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e); children = new GitResourceNode[0]; } } @@ -75,7 +77,8 @@ public class GitResourceNode extends BufferedContent implements IStructureCompar return new ByteArrayInputStream(bytes); } catch (IOException e) { // TODO: eclipse error handling - e.printStackTrace(); + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e); return null; } } diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/BranchAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/BranchAction.java index ad09e8f3e3..cc949c27c9 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/BranchAction.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/BranchAction.java @@ -14,6 +14,7 @@ import java.lang.reflect.InvocationTargetException; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.egit.core.internal.trace.GitTraceLocation; import org.eclipse.egit.core.op.BranchOperation; import org.eclipse.egit.ui.internal.decorators.GitLightweightDecorator; import org.eclipse.egit.ui.internal.dialogs.BranchSelectionDialog; @@ -58,20 +59,23 @@ public class BranchAction extends RepositoryAction { try { new BranchOperation(repository, refName).run(monitor); GitLightweightDecorator.refresh(); - } catch (final CoreException ce) { - ce.printStackTrace(); + } catch (final CoreException e) { + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e); Display.getDefault().asyncExec(new Runnable() { public void run() { - handle(ce, "Error while switching branches", "Unable to switch branches"); + handle(e, "Error while switching branches", "Unable to switch branches"); } }); } } }); } catch (InvocationTargetException e) { - e.printStackTrace(); + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e); } catch (InterruptedException e) { - e.printStackTrace(); + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e); } } diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitAction.java index d3e86e881a..59d45e025d 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitAction.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitAction.java @@ -24,6 +24,7 @@ import java.util.TimeZone; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.egit.core.internal.trace.GitTraceLocation; import org.eclipse.egit.core.project.GitProjectData; import org.eclipse.egit.core.project.RepositoryMapping; import org.eclipse.egit.ui.internal.dialogs.CommitDialog; @@ -160,7 +161,7 @@ public class CommitAction extends RepositoryAction { private void performCommit(CommitDialog commitDialog, String commitMessage) throws TeamException { - // System.out.println("Commit Message: " + commitMessage); + IFile[] selectedItems = commitDialog.getSelectedFiles(); HashMap<Repository, Tree> treeMap = new HashMap<Repository, Tree>(); @@ -238,7 +239,6 @@ public class CommitAction extends RepositoryAction { } for (IFile file : selectedItems) { - // System.out.println("\t" + file); IProject project = file.getProject(); RepositoryMapping repositoryMapping = RepositoryMapping.getMapping(project); @@ -249,7 +249,11 @@ public class CommitAction extends RepositoryAction { if (projTree == null) projTree = new Tree(repository); treeMap.put(repository, projTree); - System.out.println("Orig tree id: " + projTree.getId()); //$NON-NLS-1$ + // TODO is this the right Location? + if (GitTraceLocation.UI.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.UI.getLocation(), + "Orig tree id: " + projTree.getId()); //$NON-NLS-1$ } GitIndex index = repository.getIndex(); String repoRelativePath = repositoryMapping @@ -268,7 +272,11 @@ public class CommitAction extends RepositoryAction { if (!thisfile.isFile()) { index.remove(repositoryMapping.getWorkDir(), thisfile); index.write(); - System.out.println("Phantom file, so removing from index"); //$NON-NLS-1$ + // TODO is this the right Location? + if (GitTraceLocation.UI.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.UI.getLocation(), + "Phantom file, so removing from index"); //$NON-NLS-1$ continue; } else { if (idxEntry.update(thisfile)) @@ -282,9 +290,13 @@ public class CommitAction extends RepositoryAction { TreeEntry newMember = projTree.findBlobMember(repoRelativePath); newMember.setId(idxEntry.getObjectId()); - System.out.println("New member id for " + repoRelativePath //$NON-NLS-1$ - + ": " + newMember.getId() + " idx id: " //$NON-NLS-1$ //$NON-NLS-2$ - + idxEntry.getObjectId()); + // TODO is this the right Location? + if (GitTraceLocation.UI.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.UI.getLocation(), + "New member id for " + repoRelativePath //$NON-NLS-1$ + + ": " + newMember.getId() + " idx id: " //$NON-NLS-1$ //$NON-NLS-2$ + + idxEntry.getObjectId()); } } } @@ -302,7 +314,11 @@ public class CommitAction extends RepositoryAction { private void writeTreeWithSubTrees(Tree tree) throws TeamException { if (tree.getId() == null) { - System.out.println("writing tree for: " + tree.getFullName()); //$NON-NLS-1$ + // TODO is this the right Location? + if (GitTraceLocation.UI.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.UI.getLocation(), + "writing tree for: " + tree.getFullName()); //$NON-NLS-1$ try { for (TreeEntry entry : tree.members()) { if (entry.isModified()) { @@ -311,8 +327,12 @@ public class CommitAction extends RepositoryAction { } else { // this shouldn't happen.... not quite sure what to // do here :) - System.out.println("BAD JUJU: " //$NON-NLS-1$ - + entry.getFullName()); + // TODO is this the right Location? + if (GitTraceLocation.UI.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.UI.getLocation(), + "BAD JUJU: " //$NON-NLS-1$ + + entry.getFullName()); } } } @@ -359,10 +379,15 @@ public class CommitAction extends RepositoryAction { files.add((IFile) member); category.add((IFile) member); } else { - System.out.println("Couldn't find " + filename); //$NON-NLS-1$ + // TODO is this the right Location? + if (GitTraceLocation.UI.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.UI.getLocation(), + "Couldn't find " + filename); //$NON-NLS-1$ } - } catch (Exception t) { - t.printStackTrace(); + } catch (Exception e) { + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e); continue; } // if it's outside the workspace, bad things happen } @@ -382,7 +407,8 @@ public class CommitAction extends RepositoryAction { return true; } } catch (Exception e) { - e.printStackTrace(); + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e); } return false; } @@ -397,9 +423,11 @@ public class CommitAction extends RepositoryAction { return entry.isModified(map.getWorkDir()); return false; } catch (UnsupportedEncodingException e) { - e.printStackTrace(); + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e); } catch (IOException e) { - e.printStackTrace(); + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e); } return false; } diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetAction.java index 1245b140a1..2b264aff30 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetAction.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetAction.java @@ -14,6 +14,7 @@ import java.lang.reflect.InvocationTargetException; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.egit.core.internal.trace.GitTraceLocation; import org.eclipse.egit.core.op.ResetOperation; import org.eclipse.egit.core.op.ResetOperation.ResetType; import org.eclipse.egit.ui.internal.decorators.GitLightweightDecorator; @@ -57,9 +58,10 @@ public class ResetAction extends RepositoryAction { try { new ResetOperation(repository, refName, type).run(monitor); GitLightweightDecorator.refresh(); - } catch (CoreException ce) { - ce.printStackTrace(); - throw new InvocationTargetException(ce); + } catch (CoreException e) { + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e); + throw new InvocationTargetException(e); } } }); diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitDocument.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitDocument.java index 7bd11dbf00..b5e238eaec 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitDocument.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitDocument.java @@ -16,6 +16,7 @@ import org.eclipse.core.resources.IEncodedStorage; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.egit.core.GitProvider; +import org.eclipse.egit.core.internal.trace.GitTraceLocation; import org.eclipse.egit.core.project.RepositoryMapping; import org.eclipse.egit.ui.Activator; import org.eclipse.jface.text.Document; @@ -42,7 +43,11 @@ class GitDocument extends Document implements RepositoryListener { static Map<GitDocument,Repository> doc2repo = new WeakHashMap<GitDocument, Repository>(); static GitDocument create(final IResource resource) throws IOException { - Activator.trace("(GitDocument) create: " + resource); //$NON-NLS-1$ + // TODO is this the right location? + if (GitTraceLocation.UI.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.UI.getLocation(), + "(GitDocument) create: " + resource); //$NON-NLS-1$ GitDocument ret = null; if (RepositoryProvider.getProvider(resource.getProject()) instanceof GitProvider) { ret = new GitDocument(resource); @@ -65,13 +70,26 @@ class GitDocument extends Document implements RepositoryListener { lastBlob = blob != null ? blob.copy() : null; set(value); if (blob != null) - Activator.trace("(GitDocument) resolved " + resource + " to " + lastBlob + " in " + lastCommit + "/" + lastTree); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - else - Activator.trace("(GitDocument) unresolved " + resource); //$NON-NLS-1$ + // TODO is this the right location? + if (GitTraceLocation.UI.isActive()) + GitTraceLocation + .getTrace() + .trace( + GitTraceLocation.UI.getLocation(), + "(GitDocument) resolved " + resource + " to " + lastBlob + " in " + lastCommit + "/" + lastTree); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + else + // TODO is this the right location? + if (GitTraceLocation.UI.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.UI.getLocation(), + "(GitDocument) unresolved " + resource); //$NON-NLS-1$ } void populate() throws IOException { - Activator.trace("(GitDocument) populate: " + resource); //$NON-NLS-1$ + // TODO is this the right location? + if (GitTraceLocation.UI.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.UI.getLocation(),"(GitDocument) populate: " + resource); //$NON-NLS-1$ RepositoryMapping mapping = RepositoryMapping.getMapping(resource); if (mapping == null) { setResolved(null, null, null, ""); //$NON-NLS-1$ @@ -85,7 +103,11 @@ class GitDocument extends Document implements RepositoryListener { ObjectId commitId = repository.resolve(baseline); if (commitId != null) { if (commitId.equals(lastCommit)) { - Activator.trace("(GitDocument) already resolved"); //$NON-NLS-1$ + // TODO is this the right location? + if (GitTraceLocation.UI.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.UI.getLocation(), + "(GitDocument) already resolved"); //$NON-NLS-1$ return; } } else { @@ -105,7 +127,11 @@ class GitDocument extends Document implements RepositoryListener { } ObjectId treeId = baselineCommit.getTreeId(); if (treeId.equals(lastTree)) { - Activator.trace("(GitDocument) already resolved"); //$NON-NLS-1$ + // TODO is this the right location? + if (GitTraceLocation.UI.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.UI.getLocation(), + "(GitDocument) already resolved"); //$NON-NLS-1$ return; } Tree baselineTree = baselineCommit.getTree(); @@ -118,7 +144,11 @@ class GitDocument extends Document implements RepositoryListener { } TreeEntry blobEntry = baselineTree.findBlobMember(gitPath); if (blobEntry != null && !blobEntry.getId().equals(lastBlob)) { - Activator.trace("(GitDocument) compareTo: " + baseline); //$NON-NLS-1$ + // TODO is this the right location? + if (GitTraceLocation.UI.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.UI.getLocation(), + "(GitDocument) compareTo: " + baseline); //$NON-NLS-1$ ObjectLoader loader = repository.openBlob(blobEntry.getId()); byte[] bytes = loader.getBytes(); String charset; @@ -139,17 +169,31 @@ class GitDocument extends Document implements RepositoryListener { // to the content. We don't do that here. String s = new String(bytes, charset); setResolved(commitId, baselineTree.getId(), blobEntry.getId(), s); - Activator.trace("(GitDocument) has reference doc, size=" + s.length() + " bytes"); //$NON-NLS-1$ //$NON-NLS-2$ + // TODO is this the right location? + if (GitTraceLocation.UI.isActive()) + GitTraceLocation + .getTrace() + .trace( + GitTraceLocation.UI.getLocation(), + "(GitDocument) has reference doc, size=" + s.length() + " bytes"); //$NON-NLS-1$ //$NON-NLS-2$ } else { if (blobEntry == null) setResolved(null, null, null, ""); //$NON-NLS-1$ else - Activator.trace("(GitDocument) already resolved"); //$NON-NLS-1$ + // TODO is this the right location? + if (GitTraceLocation.UI.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.UI.getLocation(), + "(GitDocument) already resolved"); //$NON-NLS-1$ } } void dispose() { - Activator.trace("(GitDocument) dispose: " + resource); //$NON-NLS-1$ + // TODO is this the right location? + if (GitTraceLocation.UI.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.UI.getLocation(), + "(GitDocument) dispose: " + resource); //$NON-NLS-1$ doc2repo.remove(this); Repository repository = getRepository(); if (repository != null) diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitQuickDiffProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitQuickDiffProvider.java index c98026d91b..8b3f8cd1c9 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitQuickDiffProvider.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitQuickDiffProvider.java @@ -16,6 +16,7 @@ import java.util.WeakHashMap; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.egit.core.internal.trace.GitTraceLocation; import org.eclipse.egit.ui.Activator; import org.eclipse.egit.ui.UIText; import org.eclipse.jface.text.IDocument; @@ -43,12 +44,16 @@ public class GitQuickDiffProvider implements IQuickDiffReferenceProvider { * Create the GitQuickDiffProvider instance */ public GitQuickDiffProvider() { - Activator.trace("(GitQuickDiffProvider) constructor"); //$NON-NLS-1$ + // TODO is this the right location? + if (GitTraceLocation.UI.isActive()) + GitTraceLocation.getTrace().traceEntry(GitTraceLocation.UI.getLocation()); // Empty } public void dispose() { - Activator.trace("(GitQuickDiffProvider) dispose"); //$NON-NLS-1$ + // TODO is this the right location? + if (GitTraceLocation.UI.isActive()) + GitTraceLocation.getTrace().traceEntry(GitTraceLocation.UI.getLocation()); if (document != null) document.dispose(); } @@ -59,7 +64,11 @@ public class GitQuickDiffProvider implements IQuickDiffReferenceProvider { public IDocument getReference(IProgressMonitor monitor) throws CoreException { - Activator.trace("(GitQuickDiffProvider) file: " + resource); //$NON-NLS-1$ + // TODO is this the right location? + if (GitTraceLocation.UI.isActive()) + GitTraceLocation.getTrace().trace( + GitTraceLocation.UI.getLocation(), + "(GitQuickDiffProvider) file: " + resource); //$NON-NLS-1$ if (resource == null) return null; RepositoryProvider provider = RepositoryProvider.getProvider(resource @@ -81,7 +90,10 @@ public class GitQuickDiffProvider implements IQuickDiffReferenceProvider { } public void setActiveEditor(ITextEditor editor) { - Activator.trace("(GitQuickDiffProvider) setActiveEditor: " + editor.getTitle()); //$NON-NLS-1$ + // TODO is this the right location? + if (GitTraceLocation.UI.isActive()) + GitTraceLocation.getTrace().traceEntry( + GitTraceLocation.UI.getLocation(), editor.getTitle()); IEditorInput editorInput = editor.getEditorInput(); resource = ResourceUtil.getResource(editorInput); } diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java index dcc8c6cb1e..6a7b9210c6 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java @@ -26,6 +26,7 @@ import org.eclipse.core.resources.IProject; import org.eclipse.egit.core.Activator; import org.eclipse.egit.core.GitProvider; import org.eclipse.egit.core.internal.storage.GitFileHistoryProvider; +import org.eclipse.egit.core.internal.trace.GitTraceLocation; import org.eclipse.egit.core.project.RepositoryMapping; import org.eclipse.egit.ui.UIText; import org.eclipse.egit.ui.internal.GitCompareFileRevisionEditorInput; @@ -392,7 +393,8 @@ public class CommitDialog extends Dialog { filesViewer.refresh(true); } } catch (IOException e) { - e.printStackTrace(); + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e); return; } } diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java index d363dcfa2a..1d5a49c152 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java @@ -27,6 +27,7 @@ import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.JobChangeAdapter; import org.eclipse.egit.core.ResourceList; import org.eclipse.egit.core.internal.storage.GitFileRevision; +import org.eclipse.egit.core.internal.trace.GitTraceLocation; import org.eclipse.egit.core.project.RepositoryMapping; import org.eclipse.egit.ui.Activator; import org.eclipse.egit.ui.UIIcons; @@ -484,7 +485,14 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener { refschangedRunnable = new Runnable() { public void run() { if (!getControl().isDisposed()) { - Activator.trace("Executing async repository changed event"); //$NON-NLS-1$ + // TODO is this the right location? + if (GitTraceLocation.UI.isActive()) + GitTraceLocation + .getTrace() + .trace( + GitTraceLocation.UI + .getLocation(), + "Executing async repository changed event"); //$NON-NLS-1$ refschangedRunnable = null; inputSet(); } diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitProjectPropertyPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitProjectPropertyPage.java index 84337d8863..82b8dc206a 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitProjectPropertyPage.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitProjectPropertyPage.java @@ -12,6 +12,7 @@ import java.io.IOException; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.egit.core.internal.trace.GitTraceLocation; import org.eclipse.egit.core.project.RepositoryMapping; import org.eclipse.egit.ui.UIText; import org.eclipse.swt.SWT; @@ -80,7 +81,8 @@ public class GitProjectPropertyPage extends PropertyPage { try { fillValues(repository); } catch (IOException e) { - e.printStackTrace(); + if (GitTraceLocation.CORE.isActive()) + GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e); } } |