* [EGIT PATCH 7/9] Add a job to refresh projects when the index changes.
From: Robin Rosenberg @ 2008-07-10 22:40 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git, Marek Zawirski, Robin Rosenberg
In-Reply-To: <1215729651-26781-7-git-send-email-robin.rosenberg@dewire.com>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../src/org/spearce/egit/ui/Activator.java | 83 +++++++++++++++++++-
1 files changed, 79 insertions(+), 4 deletions(-)
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/Activator.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/Activator.java
index 3e02c44..39d3bc9 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/Activator.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/Activator.java
@@ -11,16 +11,19 @@ package org.spearce.egit.ui;
import java.net.Authenticator;
import java.net.ProxySelector;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.Set;
import org.eclipse.core.net.proxy.IProxyService;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
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.jsch.core.IJSchService;
@@ -30,7 +33,10 @@ import org.eclipse.ui.themes.ITheme;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.spearce.egit.core.project.RepositoryMapping;
+import org.spearce.jgit.lib.IndexChangedEvent;
+import org.spearce.jgit.lib.RefsChangedEvent;
import org.spearce.jgit.lib.Repository;
+import org.spearce.jgit.lib.RepositoryListener;
import org.spearce.jgit.transport.SshSessionFactory;
/**
@@ -137,6 +143,7 @@ public class Activator extends AbstractUIPlugin {
private boolean traceVerbose;
private RCS rcs;
+ private RIRefresh refreshJob;
/**
* Constructor for the egit ui plugin singleton
@@ -151,6 +158,70 @@ public class Activator extends AbstractUIPlugin {
setupSSH(context);
setupProxy(context);
setupRepoChangeScanner();
+ setupRepoIndexRefresh();
+ }
+
+ private void setupRepoIndexRefresh() {
+ refreshJob = new RIRefresh();
+ Repository.addAnyRepositoryChangedListener(refreshJob);
+ }
+
+ static class RIRefresh extends Job implements RepositoryListener {
+
+ RIRefresh() {
+ super("Git index refresh Job");
+ }
+
+ private Set<IProject> projectsToScan = new LinkedHashSet<IProject>();
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ monitor.beginTask("Refreshing git managed projects", projects.length);
+
+ while (projectsToScan.size() > 0) {
+ IProject p;
+ synchronized (projectsToScan) {
+ if (projectsToScan.size() == 0) {
+ }
+ p = projectsToScan.iterator().next();
+ projectsToScan.remove(p);
+ }
+ ISchedulingRule rule = p.getWorkspace().getRuleFactory().refreshRule(p);
+ try {
+ getJobManager().beginRule(rule, monitor);
+ p.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 1));
+ } catch (CoreException e) {
+ logError("Failed to refresh projects from index changes", e);
+ return new Status(IStatus.ERROR, getPluginId(), e.getMessage());
+ } finally {
+ getJobManager().endRule(rule);
+ }
+ }
+ monitor.done();
+ return Status.OK_STATUS;
+ }
+
+ public void indexChanged(IndexChangedEvent e) {
+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ Set<IProject> toRefresh= new HashSet<IProject>();
+ for (IProject p : projects) {
+ RepositoryMapping mapping = RepositoryMapping.getMapping(p);
+ if (mapping != null && mapping.getRepository() == e.getRepository()) {
+ toRefresh.add(p);
+ }
+ }
+ synchronized (projectsToScan) {
+ projectsToScan.addAll(toRefresh);
+ }
+ if (projectsToScan.size() > 0)
+ schedule();
+ }
+
+ public void refsChanged(RefsChangedEvent e) {
+ // Do not react here
+ }
+
}
static class RCS extends Job {
@@ -236,10 +307,14 @@ public class Activator extends AbstractUIPlugin {
public void stop(final BundleContext context) throws Exception {
trace("Trying to cancel " + rcs.getName() + " job");
- if (!rcs.cancel()) {
- rcs.join();
- }
- trace("rcs.getName() " + rcs.getName() + " cancelled ok");
+ rcs.cancel();
+ trace("Trying to cancel " + refreshJob.getName() + " job");
+ refreshJob.cancel();
+
+ rcs.join();
+ refreshJob.join();
+
+ trace("Jobs terminated");
super.stop(context);
plugin = null;
}
--
1.5.6.2.220.g44701
^ permalink raw reply related
* [EGIT PATCH 8/9] Make git dectected changes depend on the automatic refresh setting
From: Robin Rosenberg @ 2008-07-10 22:40 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git, Marek Zawirski, Robin Rosenberg
In-Reply-To: <1215729651-26781-8-git-send-email-robin.rosenberg@dewire.com>
This is the same setting that scans the workspace regularly for
changes in resources. We scan more often can can trigger sooner because
we can scan fewer files.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../src/org/spearce/egit/ui/Activator.java | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/Activator.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/Activator.java
index 39d3bc9..d8928cb 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/Activator.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/Activator.java
@@ -203,6 +203,11 @@ public class Activator extends AbstractUIPlugin {
}
public void indexChanged(IndexChangedEvent e) {
+ // Check the workspace setting "refresh automatically" setting first
+ if (!ResourcesPlugin.getPlugin().getPluginPreferences().getBoolean(
+ ResourcesPlugin.PREF_AUTO_REFRESH))
+ return;
+
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
Set<IProject> toRefresh= new HashSet<IProject>();
for (IProject p : projects) {
--
1.5.6.2.220.g44701
^ permalink raw reply related
* [EGIT PATCH 1/9] Create a listener structure for changes to refs and index
From: Robin Rosenberg @ 2008-07-10 22:40 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git, Marek Zawirski, Robin Rosenberg
In-Reply-To: <1215729651-26781-1-git-send-email-robin.rosenberg@dewire.com>
This version does not tell you which refs have changed, nor
what changes have happened. There is not scanning for externally
initiated changes either, though such changes can be found when
a JGit client wants to read index or refs information.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../egit/ui/internal/history/GitHistoryPage.java | 31 +++++++++-
.../src/org/spearce/jgit/lib/GitIndex.java | 3 +
.../org/spearce/jgit/lib/IndexChangedEvent.java | 55 +++++++++++++++++
.../src/org/spearce/jgit/lib/RefDatabase.java | 17 +++++
.../src/org/spearce/jgit/lib/RefsChangedEvent.java | 55 +++++++++++++++++
.../src/org/spearce/jgit/lib/Repository.java | 41 +++++++++++++
.../org/spearce/jgit/lib/RepositoryAdapter.java | 54 ++++++++++++++++
.../spearce/jgit/lib/RepositoryChangedEvent.java | 64 ++++++++++++++++++++
.../org/spearce/jgit/lib/RepositoryListener.java | 63 +++++++++++++++++++
9 files changed, 382 insertions(+), 1 deletions(-)
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/IndexChangedEvent.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/RefsChangedEvent.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryAdapter.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryChangedEvent.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryListener.java
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
index 6b55185..7e2f726 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
@@ -61,7 +61,10 @@ import org.spearce.egit.ui.UIIcons;
import org.spearce.egit.ui.UIPreferences;
import org.spearce.egit.ui.UIText;
import org.spearce.jgit.lib.AnyObjectId;
+import org.spearce.jgit.lib.IndexChangedEvent;
+import org.spearce.jgit.lib.RefsChangedEvent;
import org.spearce.jgit.lib.Repository;
+import org.spearce.jgit.lib.RepositoryListener;
import org.spearce.jgit.revplot.PlotCommit;
import org.spearce.jgit.revwalk.RevCommit;
import org.spearce.jgit.revwalk.RevFlag;
@@ -73,7 +76,7 @@ import org.spearce.jgit.treewalk.filter.PathFilterGroup;
import org.spearce.jgit.treewalk.filter.TreeFilter;
/** Graphical commit history viewer. */
-public class GitHistoryPage extends HistoryPage {
+public class GitHistoryPage extends HistoryPage implements RepositoryListener {
private static final String PREF_COMMENT_WRAP = UIPreferences.RESOURCEHISTORY_SHOW_COMMENT_WRAP;
private static final String PREF_COMMENT_FILL = UIPreferences.RESOURCEHISTORY_SHOW_COMMENT_FILL;
@@ -230,6 +233,32 @@ public class GitHistoryPage extends HistoryPage {
layout();
}
+ private Runnable refschangedRunnable;
+
+ public void refsChanged(final RefsChangedEvent e) {
+ if (getControl().isDisposed())
+ return;
+
+ synchronized (this) {
+ if (refschangedRunnable == null) {
+ refschangedRunnable = new Runnable() {
+ public void run() {
+ if (!getControl().isDisposed()) {
+ Activator.trace("Executing async repository changed event");
+ refschangedRunnable = null;
+ inputSet();
+ }
+ }
+ };
+ getControl().getDisplay().asyncExec(refschangedRunnable);
+ }
+ }
+ }
+
+ public void indexChanged(final IndexChangedEvent e) {
+ // We do not use index information here now
+ }
+
private void finishContextMenu() {
popupMgr.add(new Separator());
popupMgr.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java b/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java
index 5be404e..c7a4402 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java
@@ -146,6 +146,7 @@ public class GitIndex {
public void rereadIfNecessary() throws IOException {
if (cacheFile.exists() && cacheFile.lastModified() != lastCacheTime) {
read();
+ db.fireIndexChanged();
}
}
@@ -269,6 +270,8 @@ public class GitIndex {
"Could not rename temporary index file to index");
changed = false;
statDirty = false;
+ lastCacheTime = cacheFile.lastModified();
+ db.fireIndexChanged();
} finally {
if (!lock.delete())
throw new IOException(
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/IndexChangedEvent.java b/org.spearce.jgit/src/org/spearce/jgit/lib/IndexChangedEvent.java
new file mode 100644
index 0000000..30a40d1
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/IndexChangedEvent.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.spearce.jgit.lib;
+
+/**
+ * This class passes information about a changed Git index to a
+ * {@link RepositoryListener}
+ *
+ * Currently only a reference to the repository is passed.
+ */
+public class IndexChangedEvent extends RepositoryChangedEvent {
+ IndexChangedEvent(final Repository repository) {
+ super(repository);
+ }
+
+ @Override
+ public String toString() {
+ return "IndexChangedEvent[" + getRepository() + "]";
+ }
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java
index 9e3e020..4be33b8 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java
@@ -81,6 +81,10 @@ class RefDatabase {
private long packedRefsLength;
+ long lastRefModification;
+
+ long lastNotifiedRefModification;
+
RefDatabase(final Repository r) {
db = r;
gitDir = db.getDirectory();
@@ -132,6 +136,8 @@ class RefDatabase {
void stored(final String name, final ObjectId id, final long time) {
looseRefs.put(name, new CachedRef(Ref.Storage.LOOSE, name, id, time));
+ setModified();
+ db.fireRefsMaybeChanged();
}
/**
@@ -155,6 +161,12 @@ class RefDatabase {
}
if (!lck.commit())
throw new ObjectWritingException("Unable to write " + name);
+ setModified();
+ db.fireRefsMaybeChanged();
+ }
+
+ void setModified() {
+ lastRefModification = System.currentTimeMillis();
}
Ref readRef(final String partialName) throws IOException {
@@ -192,6 +204,7 @@ class RefDatabase {
readPackedRefs(avail);
readLooseRefs(avail, REFS_SLASH, refsDir);
readOneLooseRef(avail, Constants.HEAD, new File(gitDir, Constants.HEAD));
+ db.fireRefsMaybeChanged();
return avail;
}
@@ -321,6 +334,8 @@ class RefDatabase {
return r != null ? r : new Ref(Ref.Storage.LOOSE, target, null);
}
+ setModified();
+
final ObjectId id;
try {
id = ObjectId.fromString(line);
@@ -378,6 +393,7 @@ class RefDatabase {
packedRefsLastModified = currTime;
packedRefsLength = currLen;
packedRefs = newPackedRefs;
+ setModified();
} catch (FileNotFoundException noPackedRefs) {
// Ignore it and leave the new map empty.
//
@@ -414,4 +430,5 @@ class RefDatabase {
lastModified = mtime;
}
}
+
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/RefsChangedEvent.java b/org.spearce.jgit/src/org/spearce/jgit/lib/RefsChangedEvent.java
new file mode 100644
index 0000000..c8936c7
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RefsChangedEvent.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.spearce.jgit.lib;
+
+/**
+ * This class passes information about a changed Git index to a
+ * {@link RepositoryListener}
+ *
+ * Currently only a reference to the repository is passed.
+ */
+public class RefsChangedEvent extends RepositoryChangedEvent {
+ RefsChangedEvent(final Repository repository) {
+ super(repository);
+ }
+
+ @Override
+ public String toString() {
+ return "RefsChangedEvent[" + getRepository() + "]";
+ }
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
index 04d9b13..6f78652 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
@@ -49,7 +49,9 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
+import java.util.Vector;
import org.spearce.jgit.errors.IncorrectObjectTypeException;
import org.spearce.jgit.errors.RevisionSyntaxException;
@@ -92,6 +94,8 @@ public class Repository {
private GitIndex index;
+ private List<RepositoryListener> listeners = new Vector<RepositoryListener>(); // thread safe
+
/**
* Construct a representation of a Git repository.
*
@@ -1028,4 +1032,41 @@ public class Repository {
public File getWorkDir() {
return getDirectory().getParentFile();
}
+
+ /**
+ * Register a {@link RepositoryListener} which will be notified
+ * when ref changes are detected.
+ *
+ * @param l
+ */
+ public void addRepositoryChangedListener(final RepositoryListener l) {
+ listeners.add(l);
+ }
+
+ /**
+ * Remove a registered {@link RepositoryListener}
+ * @param l
+ */
+ public void removeRepositoryChangedListener(final RepositoryListener l) {
+ listeners.remove(l);
+ }
+
+ void fireRefsMaybeChanged() {
+ if (refs.lastRefModification != refs.lastNotifiedRefModification) {
+ refs.lastNotifiedRefModification = refs.lastRefModification;
+ final RefsChangedEvent event = new RefsChangedEvent(this);
+ for (final RepositoryListener l :
+ listeners.toArray(new RepositoryListener[listeners.size()])) {
+ l.refsChanged(event);
+ }
+ }
+ }
+
+ void fireIndexChanged() {
+ final IndexChangedEvent event = new IndexChangedEvent(this);
+ for (final RepositoryListener l :
+ listeners.toArray(new RepositoryListener[listeners.size()])) {
+ l.indexChanged(event);
+ }
+ }
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryAdapter.java b/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryAdapter.java
new file mode 100644
index 0000000..d1ff07d
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryAdapter.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.spearce.jgit.lib;
+
+/**
+ * A default {@link RepositoryListener} that does nothing except invoke an
+ * optional general method for any repository change.
+ */
+public class RepositoryAdapter implements RepositoryListener {
+
+ public void indexChanged(final IndexChangedEvent e) {
+ // Empty
+ }
+
+ public void refsChanged(final RefsChangedEvent e) {
+ // Empty
+ }
+
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryChangedEvent.java b/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryChangedEvent.java
new file mode 100644
index 0000000..b58df87
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryChangedEvent.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.spearce.jgit.lib;
+
+/**
+ * This class passes information about changed refs to a
+ * {@link RepositoryListener}
+ *
+ * Currently only a reference to the repository is passed.
+ */
+public class RepositoryChangedEvent {
+ private final Repository repository;
+
+ RepositoryChangedEvent(final Repository repository) {
+ this.repository = repository;
+ }
+
+ /**
+ * @return the repository that was changed
+ */
+ public Repository getRepository() {
+ return repository;
+ }
+
+ @Override
+ public String toString() {
+ return "RepositoryChangedEvent[" + repository + "]";
+ }
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryListener.java b/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryListener.java
new file mode 100644
index 0000000..ceb14ce
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryListener.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.spearce.jgit.lib;
+
+/**
+ * A RepositoryListener gets notification about changes in refs or repository.
+ * <p>
+ * It currently does <em>not</em> get notification about which items are
+ * changed.
+ */
+public interface RepositoryListener {
+ /**
+ * Invoked when a ref changes
+ *
+ * @param e
+ * information about the changes.
+ */
+ void refsChanged(RefsChangedEvent e);
+
+ /**
+ * Invoked when the index changes
+ *
+ * @param e
+ * information about the changes.
+ */
+ void indexChanged(IndexChangedEvent e);
+
+}
--
1.5.6.2.220.g44701
^ permalink raw reply related
* [EGIT PATCH 6/9] Change GitHistoryPage to listen on any repository.
From: Robin Rosenberg @ 2008-07-10 22:40 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git, Marek Zawirski, Robin Rosenberg
In-Reply-To: <1215729651-26781-6-git-send-email-robin.rosenberg@dewire.com>
This makes listening simpler.
---
.../egit/ui/internal/history/GitHistoryPage.java | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
index 418f3b6..e3ff8d4 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
@@ -234,11 +234,16 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
attachContextMenu(commentViewer.getControl());
attachContextMenu(fileViewer.getControl());
layout();
+
+ Repository.addAnyRepositoryChangedListener(this);
}
private Runnable refschangedRunnable;
public void refsChanged(final RefsChangedEvent e) {
+ if (e.getRepository() != db)
+ return;
+
if (getControl().isDisposed())
return;
@@ -480,6 +485,7 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
}
public void dispose() {
+ Repository.removeAnyRepositoryChangedListener(this);
cancelRefreshJob();
if (popupMgr != null) {
for (final IContributionItem i : popupMgr.getItems()) {
@@ -539,9 +545,6 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
revObjectSelectionProvider.setActiveRepository(null);
cancelRefreshJob();
- if (db != null)
- db.removeRepositoryChangedListener(this);
-
if (graph == null)
return false;
@@ -570,8 +573,6 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
if (db == null)
return false;
- db.addRepositoryChangedListener(this);
-
final AnyObjectId headId;
try {
headId = db.resolve("HEAD");
--
1.5.6.2.220.g44701
^ permalink raw reply related
* [EGIT PATCH 5/9] Add a job to periodically scan for repository changes
From: Robin Rosenberg @ 2008-07-10 22:40 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git, Marek Zawirski, Robin Rosenberg
In-Reply-To: <1215729651-26781-5-git-send-email-robin.rosenberg@dewire.com>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../src/org/spearce/egit/ui/Activator.java | 75 ++++++++++++++++++++
.../src/org/spearce/jgit/lib/Repository.java | 10 +++
2 files changed, 85 insertions(+), 0 deletions(-)
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/Activator.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/Activator.java
index 8d1b8cd..3e02c44 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/Activator.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/Activator.java
@@ -10,18 +10,27 @@ package org.spearce.egit.ui;
import java.net.Authenticator;
import java.net.ProxySelector;
+import java.util.HashSet;
+import java.util.Set;
import org.eclipse.core.net.proxy.IProxyService;
+import org.eclipse.core.resources.IProject;
+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.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jsch.core.IJSchService;
import org.eclipse.swt.graphics.Font;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.ui.themes.ITheme;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
+import org.spearce.egit.core.project.RepositoryMapping;
+import org.spearce.jgit.lib.Repository;
import org.spearce.jgit.transport.SshSessionFactory;
/**
@@ -127,6 +136,7 @@ public class Activator extends AbstractUIPlugin {
}
private boolean traceVerbose;
+ private RCS rcs;
/**
* Constructor for the egit ui plugin singleton
@@ -140,6 +150,66 @@ public class Activator extends AbstractUIPlugin {
traceVerbose = isOptionSet("/trace/verbose");
setupSSH(context);
setupProxy(context);
+ setupRepoChangeScanner();
+ }
+
+ static class RCS extends Job {
+ RCS() {
+ super("Repository Change Scanner");
+ }
+
+ // FIXME, need to be more intelligent about this to avoid too much work
+ private static final long REPO_SCAN_INTERVAL = 10000L;
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ // A repository can contain many projects, only scan once
+ // (a project could in theory be distributed among many
+ // repositories. We discard that as being ugly and stupid for
+ // the moment.
+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ monitor.beginTask("Scanning Git repositories for changes", projects.length);
+ Set<Repository> scanned = new HashSet<Repository>();
+ for (IProject p : projects) {
+ RepositoryMapping mapping = RepositoryMapping.getMapping(p);
+ if (mapping != null) {
+ Repository r = mapping.getRepository();
+ if (!scanned.contains(r)) {
+ if (monitor.isCanceled())
+ break;
+ trace("Scanning " + r + " for changes");
+ scanned.add(r);
+ ISchedulingRule rule = p.getWorkspace().getRuleFactory().modifyRule(p);
+ getJobManager().beginRule(rule, monitor);
+ try {
+ r.scanForRepoChanges();
+ } finally {
+ getJobManager().endRule(rule);
+ }
+ }
+ }
+ monitor.worked(1);
+ }
+ monitor.done();
+ trace("Rescheduling " + getName() + " job");
+ schedule(REPO_SCAN_INTERVAL);
+ } catch (Exception e) {
+ trace("Stopped rescheduling " + getName() + "job");
+ return new Status(
+ IStatus.ERROR,
+ getPluginId(),
+ 0,
+ "An error occurred while scanning for changes. Scanning aborted",
+ e);
+ }
+ return Status.OK_STATUS;
+ }
+ }
+
+ private void setupRepoChangeScanner() {
+ rcs = new RCS();
+ rcs.schedule(RCS.REPO_SCAN_INTERVAL);
}
private void setupSSH(final BundleContext context) {
@@ -165,6 +235,11 @@ public class Activator extends AbstractUIPlugin {
}
public void stop(final BundleContext context) throws Exception {
+ trace("Trying to cancel " + rcs.getName() + " job");
+ if (!rcs.cancel()) {
+ rcs.join();
+ }
+ trace("rcs.getName() " + rcs.getName() + " cancelled ok");
super.stop(context);
plugin = null;
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
index dfa3045..9b65154 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
@@ -1092,4 +1092,14 @@ public class Repository {
l.indexChanged(event);
}
}
+
+ /**
+ * Force a scan for changed refs.
+ *
+ * @throws IOException
+ */
+ public void scanForRepoChanges() throws IOException {
+ getAllRefs(); // This will look for changes to refs
+ getIndex(); // This will detect changes in the index
+ }
}
--
1.5.6.2.220.g44701
^ permalink raw reply related
* [EGIT PATCH 3/9] Connect the history page to the refs update subscription mechanism
From: Robin Rosenberg @ 2008-07-10 22:40 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git, Marek Zawirski, Robin Rosenberg
In-Reply-To: <1215729651-26781-3-git-send-email-robin.rosenberg@dewire.com>
Now the history page can get updated automatically without polling.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../egit/ui/internal/history/GitHistoryPage.java | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
index 7e2f726..418f3b6 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
@@ -168,6 +168,9 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
/** Last HEAD */
private AnyObjectId currentHeadId;
+ /** We need to remember the current repository */
+ private Repository db;
+
/**
* Highlight flag that can be applied to commits to make them stand out.
* <p>
@@ -536,6 +539,9 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
revObjectSelectionProvider.setActiveRepository(null);
cancelRefreshJob();
+ if (db != null)
+ db.removeRepositoryChangedListener(this);
+
if (graph == null)
return false;
@@ -543,7 +549,8 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
if (in == null || in.length == 0)
return false;
- Repository db = null;
+ db = null;
+
final ArrayList<String> paths = new ArrayList<String>(in.length);
for (final IResource r : in) {
final RepositoryMapping map = RepositoryMapping.getMapping(r);
@@ -563,6 +570,8 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
if (db == null)
return false;
+ db.addRepositoryChangedListener(this);
+
final AnyObjectId headId;
try {
headId = db.resolve("HEAD");
--
1.5.6.2.220.g44701
^ permalink raw reply related
* [EGIT PATCH 4/9] Add a method to listen to changes in any repository
From: Robin Rosenberg @ 2008-07-10 22:40 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git, Marek Zawirski, Robin Rosenberg
In-Reply-To: <1215729651-26781-4-git-send-email-robin.rosenberg@dewire.com>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../src/org/spearce/jgit/lib/Repository.java | 31 +++++++++++++++++--
1 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
index 6f78652..dfa3045 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
@@ -95,6 +95,7 @@ public class Repository {
private GitIndex index;
private List<RepositoryListener> listeners = new Vector<RepositoryListener>(); // thread safe
+ static private List<RepositoryListener> allListeners = new Vector<RepositoryListener>(); // thread safe
/**
* Construct a representation of a Git repository.
@@ -1051,12 +1052,32 @@ public class Repository {
listeners.remove(l);
}
+ /**
+ * Register a global {@link RepositoryListener} which will be notified
+ * when a ref changes in any repository are detected.
+ *
+ * @param l
+ */
+ public static void addAnyRepositoryChangedListener(final RepositoryListener l) {
+ allListeners.add(l);
+ }
+
+ /**
+ * Remove a globally registered {@link RepositoryListener}
+ * @param l
+ */
+ public static void removeAnyRepositoryChangedListener(final RepositoryListener l) {
+ allListeners.remove(l);
+ }
+
void fireRefsMaybeChanged() {
if (refs.lastRefModification != refs.lastNotifiedRefModification) {
refs.lastNotifiedRefModification = refs.lastRefModification;
final RefsChangedEvent event = new RefsChangedEvent(this);
- for (final RepositoryListener l :
- listeners.toArray(new RepositoryListener[listeners.size()])) {
+ List<RepositoryListener> all = new ArrayList<RepositoryListener>(
+ listeners);
+ all.addAll(allListeners);
+ for (final RepositoryListener l : all) {
l.refsChanged(event);
}
}
@@ -1064,8 +1085,10 @@ public class Repository {
void fireIndexChanged() {
final IndexChangedEvent event = new IndexChangedEvent(this);
- for (final RepositoryListener l :
- listeners.toArray(new RepositoryListener[listeners.size()])) {
+ List<RepositoryListener> all = new ArrayList<RepositoryListener>(
+ listeners);
+ all.addAll(allListeners);
+ for (final RepositoryListener l : all) {
l.indexChanged(event);
}
}
--
1.5.6.2.220.g44701
^ permalink raw reply related
* [EGIT PATCH 2/9] Cached modification times for symbolic refs too
From: Robin Rosenberg @ 2008-07-10 22:40 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git, Marek Zawirski, Robin Rosenberg
In-Reply-To: <1215729651-26781-2-git-send-email-robin.rosenberg@dewire.com>
We want to detect changes to symbolic refs like HEAD. When HEAD is
redirected to another branch, that's a change even if if the branch
head itself did not change.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../src/org/spearce/jgit/lib/RefDatabase.java | 48 +++++++++++---------
1 files changed, 27 insertions(+), 21 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java
index 4be33b8..17a74e5 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java
@@ -71,7 +71,8 @@ class RefDatabase {
private final File refsDir;
- private Map<String, CachedRef> looseRefs;
+ private Map<String, Ref> looseRefs;
+ private Map<String, Long> looseRefsMTime;
private final File packedRefsFile;
@@ -94,7 +95,8 @@ class RefDatabase {
}
void clearCache() {
- looseRefs = new HashMap<String, CachedRef>();
+ looseRefs = new HashMap<String, Ref>();
+ looseRefsMTime = new HashMap<String, Long>();
packedRefs = new HashMap<String, Ref>();
packedRefsLastModified = 0;
packedRefsLength = 0;
@@ -135,7 +137,8 @@ class RefDatabase {
}
void stored(final String name, final ObjectId id, final long time) {
- looseRefs.put(name, new CachedRef(Ref.Storage.LOOSE, name, id, time));
+ looseRefs.put(name, new Ref(Ref.Storage.LOOSE, name, id));
+ looseRefsMTime.put(name, time);
setModified();
db.fireRefsMaybeChanged();
}
@@ -203,7 +206,11 @@ class RefDatabase {
final HashMap<String, Ref> avail = new HashMap<String, Ref>();
readPackedRefs(avail);
readLooseRefs(avail, REFS_SLASH, refsDir);
- readOneLooseRef(avail, Constants.HEAD, new File(gitDir, Constants.HEAD));
+ try {
+ avail.put(Constants.HEAD, readRefBasic(Constants.HEAD, 0));
+ } catch (IOException e) {
+ // ignore here
+ }
db.fireRefsMaybeChanged();
return avail;
}
@@ -231,13 +238,15 @@ class RefDatabase {
final String refName, final File ent) {
// Unchanged and cached? Don't read it again.
//
- CachedRef ref = looseRefs.get(refName);
+ Ref ref = looseRefs.get(refName);
if (ref != null) {
- if (ref.lastModified == ent.lastModified()) {
+ Long cachedlastModified = looseRefsMTime.get(refName);
+ if (cachedlastModified != null && cachedlastModified == ent.lastModified()) {
avail.put(ref.getName(), ref);
return;
}
looseRefs.remove(refName);
+ looseRefsMTime.remove(refName);
}
// Recurse into the directory.
@@ -269,9 +278,9 @@ class RefDatabase {
return;
}
- ref = new CachedRef(Ref.Storage.LOOSE, refName, id, ent
- .lastModified());
+ ref = new Ref(Ref.Storage.LOOSE, refName, id);
looseRefs.put(ref.getName(), ref);
+ looseRefsMTime.put(ref.getName(), ent.lastModified());
avail.put(ref.getName(), ref);
} finally {
in.close();
@@ -297,13 +306,15 @@ class RefDatabase {
// Prefer loose ref to packed ref as the loose
// file can be more up-to-date than a packed one.
//
- CachedRef ref = looseRefs.get(name);
+ Ref ref = looseRefs.get(name);
final File loose = fileForRef(name);
final long mtime = loose.lastModified();
if (ref != null) {
- if (ref.lastModified == mtime)
+ Long cachedlastModified = looseRefsMTime.get(name);
+ if (cachedlastModified != null && cachedlastModified == mtime)
return ref;
looseRefs.remove(name);
+ looseRefsMTime.remove(name);
}
if (mtime == 0) {
@@ -331,6 +342,10 @@ class RefDatabase {
final String target = line.substring("ref: ".length());
final Ref r = readRefBasic(target, depth + 1);
+ Long cachedMtime = looseRefsMTime.get(name);
+ if (cachedMtime != null && cachedMtime != mtime)
+ setModified();
+ looseRefsMTime.put(name, mtime);
return r != null ? r : new Ref(Ref.Storage.LOOSE, target, null);
}
@@ -343,8 +358,9 @@ class RefDatabase {
throw new IOException("Not a ref: " + name + ": " + line);
}
- ref = new CachedRef(Ref.Storage.LOOSE, name, id, mtime);
+ ref = new Ref(Ref.Storage.LOOSE, name, id);
looseRefs.put(name, ref);
+ looseRefsMTime.put(name, mtime);
return ref;
}
@@ -421,14 +437,4 @@ class RefDatabase {
fileLocation), CHAR_ENC));
}
- private static class CachedRef extends Ref {
- final long lastModified;
-
- CachedRef(final Storage st, final String refName, final ObjectId id,
- final long mtime) {
- super(st, refName, id);
- lastModified = mtime;
- }
- }
-
}
--
1.5.6.2.220.g44701
^ permalink raw reply related
* [EGIT PATCH 0/9] Repository change listeners
From: Robin Rosenberg @ 2008-07-10 22:40 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git, Marek Zawirski, Robin Rosenberg
We want to make the UI react on changes to the repo, but the parts
of the code that makes the changes doesn't know who wants to react
on them. This adds a publish-subcribe mechanism, including detection
of externally made changes, e.g. by C Git.
-- robin
Robin Rosenberg (9):
Create a listener structure for changes to refs and index
Cached modification times for symbolic refs too
Connect the history page to the refs update subscription mechanism
Add a method to listen to changes in any repository
Add a job to periodically scan for repository changes
Change GitHistoryPage to listen on any repository.
Add a job to refresh projects when the index changes.
Make git dectected changes depend on the automatic refresh setting
Attach the resource decorator to the repository change event
mechanism
.../src/org/spearce/egit/ui/Activator.java | 155 ++++++++++++++++++++
.../internal/decorators/GitResourceDecorator.java | 29 ++++-
.../egit/ui/internal/history/GitHistoryPage.java | 43 +++++-
.../src/org/spearce/jgit/lib/GitIndex.java | 3 +
.../org/spearce/jgit/lib/IndexChangedEvent.java | 55 +++++++
.../src/org/spearce/jgit/lib/RefDatabase.java | 63 ++++++---
.../src/org/spearce/jgit/lib/RefsChangedEvent.java | 55 +++++++
.../src/org/spearce/jgit/lib/Repository.java | 74 ++++++++++
.../org/spearce/jgit/lib/RepositoryAdapter.java | 54 +++++++
.../spearce/jgit/lib/RepositoryChangedEvent.java | 64 ++++++++
.../org/spearce/jgit/lib/RepositoryListener.java | 63 ++++++++
11 files changed, 635 insertions(+), 23 deletions(-)
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/IndexChangedEvent.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/RefsChangedEvent.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryAdapter.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryChangedEvent.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryListener.java
^ permalink raw reply
* [EGIT PATCH 6/6] Add actions in history view to perform reset actions
From: Robin Rosenberg @ 2008-07-10 22:39 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git, Marek Zawirski, Robin Rosenberg
In-Reply-To: <1215729573-26536-6-git-send-email-robin.rosenberg@dewire.com>
Soft, mixed and hard reset supported
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
org.spearce.egit.ui/plugin.xml | 43 +++++++++++---------
.../actions/HardResetToRevisionAction.java | 26 ++++++++++++
.../actions/MixedResetToRevisionAction.java | 26 ++++++++++++
.../actions/SoftResetToRevisionAction.java | 26 ++++++++++++
4 files changed, 102 insertions(+), 19 deletions(-)
create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/HardResetToRevisionAction.java
create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/MixedResetToRevisionAction.java
create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/SoftResetToRevisionAction.java
diff --git a/org.spearce.egit.ui/plugin.xml b/org.spearce.egit.ui/plugin.xml
index 924c6e5..cfd4b80 100644
--- a/org.spearce.egit.ui/plugin.xml
+++ b/org.spearce.egit.ui/plugin.xml
@@ -97,29 +97,34 @@
menubarPath="team.main/group1"
tooltip="%CommitAction_tooltip"/>
</objectContribution>
- <objectContribution
- id="org.spearce.egit.ui.revobjectContributions"
- adaptable="true"
- objectClass="org.spearce.jgit.revwalk.RevObject">
+ <objectContribution
+ id="org.spearce.egit.ui.resetto"
+ objectClass="org.spearce.jgit.revwalk.RevCommit">
<action
- class="org.spearce.egit.ui.internal.actions.BranchAction"
- id="org.spearce.egit.ui.action1"
- label="Kolla"
- enablesFor="*"
- menubarPath="additions">
+ class="org.spearce.egit.ui.internal.actions.SoftResetToRevisionAction"
+ id="org.spearce.egit.ui.softresettorevision"
+ label="Soft Reset"
+ menubarPath="additions"
+ enablesFor="1"
+ tooltip="Resets HEAD but not working directory nor index">
</action>
- </objectContribution>
- <viewerContribution
- id="org.spearce.egit.ui.viewerContribution1"
- targetID="org.spearce.egit.ui.historyPageContributions">
<action
- class="org.spearce.egit.ui.internal.actions.ResetAction"
- id="org.spearce.egit.ui.action1"
- label="Titta"
- enablesFor="*"
- menubarPath="additions">
+ class="org.spearce.egit.ui.internal.actions.MixedResetToRevisionAction"
+ id="org.spearce.egit.ui.mixedresettorevision"
+ label="Mixed Reset"
+ menubarPath="additions"
+ enablesFor="1"
+ tooltip="Resets HEAD and index, but not working directory">
</action>
- </viewerContribution>
+ <action
+ class="org.spearce.egit.ui.internal.actions.HardResetToRevisionAction"
+ id="org.spearce.egit.ui.hardresettorevision"
+ label="Hard Reset"
+ menubarPath="additions"
+ enablesFor="1"
+ tooltip="Resets HEAD and index, and working directory (changed in tracked files will be lost)">
+ </action>
+ </objectContribution>
</extension>
<extension
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/HardResetToRevisionAction.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/HardResetToRevisionAction.java
new file mode 100644
index 0000000..78fd87f
--- /dev/null
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/HardResetToRevisionAction.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * See LICENSE for the full license text, also available.
+ *******************************************************************************/
+package org.spearce.egit.ui.internal.actions;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.jface.action.IAction;
+import org.spearce.egit.core.op.ResetOperation;
+
+/**
+ * Hard reset to selected revision
+ */
+public class HardResetToRevisionAction extends AbstractRevObjectAction {
+
+ @Override
+ protected IWorkspaceRunnable createOperation(IAction act, List selection) {
+ return new ResetOperation(getActiveRepository(), selection.get(0)
+ .toString(), ResetOperation.ResetType.HARD);
+ }
+}
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/MixedResetToRevisionAction.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/MixedResetToRevisionAction.java
new file mode 100644
index 0000000..6e4a9bf
--- /dev/null
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/MixedResetToRevisionAction.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * See LICENSE for the full license text, also available.
+ *******************************************************************************/
+package org.spearce.egit.ui.internal.actions;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.jface.action.IAction;
+import org.spearce.egit.core.op.ResetOperation;
+
+/**
+ * Mixed reset to selected revision
+ */
+public class MixedResetToRevisionAction extends AbstractRevObjectAction {
+
+ @Override
+ protected IWorkspaceRunnable createOperation(IAction act, List selection) {
+ return new ResetOperation(getActiveRepository(), selection.get(0)
+ .toString(), ResetOperation.ResetType.MIXED);
+ }
+}
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/SoftResetToRevisionAction.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/SoftResetToRevisionAction.java
new file mode 100644
index 0000000..7abbc92
--- /dev/null
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/SoftResetToRevisionAction.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * See LICENSE for the full license text, also available.
+ *******************************************************************************/
+package org.spearce.egit.ui.internal.actions;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.jface.action.IAction;
+import org.spearce.egit.core.op.ResetOperation;
+
+/**
+ * Soft reset to selected revision
+ */
+public class SoftResetToRevisionAction extends AbstractRevObjectAction {
+
+ @Override
+ protected IWorkspaceRunnable createOperation(IAction act, List selection) {
+ return new ResetOperation(getActiveRepository(), selection.get(0)
+ .toString(), ResetOperation.ResetType.SOFT);
+ }
+}
--
1.5.6.2.220.g44701
^ permalink raw reply related
* [EGIT PATCH 5/6] Create baseclasses for actions and operations on RevObjects
From: Robin Rosenberg @ 2008-07-10 22:39 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git, Marek Zawirski, Robin Rosenberg
In-Reply-To: <1215729573-26536-5-git-send-email-robin.rosenberg@dewire.com>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../internal/actions/AbstractOperationAction.java | 15 +++++++----
.../internal/actions/AbstractRevObjectAction.java | 26 ++++++++++++++++++++
.../actions/AbstractRevObjectOperation.java | 21 ++++++++++++++++
3 files changed, 57 insertions(+), 5 deletions(-)
create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractRevObjectAction.java
create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractRevObjectOperation.java
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractOperationAction.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractOperationAction.java
index be6d0d5..52f60f5 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractOperationAction.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractOperationAction.java
@@ -32,11 +32,20 @@ import org.spearce.egit.ui.UIText;
* Common functionality for EGit operations.
*/
public abstract class AbstractOperationAction implements IObjectActionDelegate {
- private IWorkbenchPart wp;
+ /**
+ * The active workbench part
+ */
+ protected IWorkbenchPart wp;
private IWorkspaceRunnable op;
public void selectionChanged(final IAction act, final ISelection sel) {
+ // work performed in setActivePart
+ }
+
+ public void setActivePart(final IAction act, final IWorkbenchPart part) {
+ wp = part;
+ ISelection sel = part.getSite().getPage().getSelection();
final List selection;
if (sel instanceof IStructuredSelection && !sel.isEmpty()) {
selection = ((IStructuredSelection) sel).toList();
@@ -47,10 +56,6 @@ public abstract class AbstractOperationAction implements IObjectActionDelegate {
act.setEnabled(op != null && wp != null);
}
- public void setActivePart(final IAction act, final IWorkbenchPart part) {
- wp = part;
- }
-
/**
* Instantiate an operation on an action on provided objects.
*
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractRevObjectAction.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractRevObjectAction.java
new file mode 100644
index 0000000..b7f4285
--- /dev/null
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractRevObjectAction.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * See LICENSE for the full license text, also available.
+ *******************************************************************************/
+package org.spearce.egit.ui.internal.actions;
+
+import org.spearce.egit.ui.internal.history.RevObjectSelectionProvider;
+import org.spearce.jgit.lib.Repository;
+
+abstract class AbstractRevObjectAction extends AbstractOperationAction {
+
+ /**
+ * Find out which repository is involved here
+ *
+ * @return the Git repository associated with the selected RevObject
+ */
+ protected Repository getActiveRepository() {
+ RevObjectSelectionProvider selectionProvider = (RevObjectSelectionProvider) wp
+ .getSite().getSelectionProvider();
+ return selectionProvider.getActiveRepository();
+ }
+
+}
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractRevObjectOperation.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractRevObjectOperation.java
new file mode 100644
index 0000000..0c5d570
--- /dev/null
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractRevObjectOperation.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * See LICENSE for the full license text, also available.
+ *******************************************************************************/
+package org.spearce.egit.ui.internal.actions;
+
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.spearce.jgit.lib.Repository;
+
+abstract class AbstractRevObjectOperation implements IWorkspaceRunnable {
+
+ Repository repository;
+
+ AbstractRevObjectOperation(final Repository repository) {
+ this.repository = repository;
+ }
+
+}
--
1.5.6.2.220.g44701
^ permalink raw reply related
* [EGIT PATCH 3/6] Adapt Git team operations to non-resouce objects
From: Robin Rosenberg @ 2008-07-10 22:39 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git, Marek Zawirski, Robin Rosenberg
In-Reply-To: <1215729573-26536-3-git-send-email-robin.rosenberg@dewire.com>
Sometimes structures in the workbench, such as in the Project Explorer
in the Java EE perspective, are not represented directly as resources,
but connect to resources. We use the IAdaptable interface to ask for
the underlying resource and the proceed as usual.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../org/spearce/egit/core/internal/UpdateJob.java | 2 ++
.../egit/core/op/AssumeUnchangedOperation.java | 6 +++---
.../egit/core/op/DisconnectProviderOperation.java | 7 +++----
.../org/spearce/egit/core/op/TrackOperation.java | 6 +++---
.../org/spearce/egit/core/op/UntrackOperation.java | 6 +++---
5 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/internal/UpdateJob.java b/org.spearce.egit.core/src/org/spearce/egit/core/internal/UpdateJob.java
index 9641529..be1c591 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/internal/UpdateJob.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/internal/UpdateJob.java
@@ -21,6 +21,7 @@ import org.eclipse.core.resources.IResourceProxy;
import org.eclipse.core.resources.IResourceProxyVisitor;
import org.eclipse.core.resources.IResourceVisitor;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -65,6 +66,7 @@ public class UpdateJob extends Job {
final int[] count=new int[1];
long t0=System.currentTimeMillis();
for (Object obj : rsrcList) {
+ obj = ((IAdaptable)obj).getAdapter(IResource.class);
if (obj instanceof IContainer) {
((IContainer)obj).accept(new IResourceProxyVisitor() {
public boolean visit(IResourceProxy rp) throws CoreException {
diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/op/AssumeUnchangedOperation.java b/org.spearce.egit.core/src/org/spearce/egit/core/op/AssumeUnchangedOperation.java
index 856ef3f..78a84bb 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/op/AssumeUnchangedOperation.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/op/AssumeUnchangedOperation.java
@@ -18,6 +18,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceVisitor;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.spearce.egit.core.Activator;
@@ -51,9 +52,8 @@ public class AssumeUnchangedOperation implements IWorkspaceRunnable {
final IdentityHashMap<RepositoryMapping, Boolean> tomerge = new IdentityHashMap<RepositoryMapping, Boolean>();
m.beginTask(CoreText.AssumeUnchangedOperation_adding, rsrcList.size() * 200);
try {
- final Iterator i = rsrcList.iterator();
- while (i.hasNext()) {
- final Object obj = i.next();
+ for (Object obj : rsrcList) {
+ obj = ((IAdaptable)obj).getAdapter(IResource.class);
if (obj instanceof IResource) {
final IResource toAssumeValid = (IResource)obj;
final RepositoryMapping rm = RepositoryMapping.getMapping(toAssumeValid);
diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/op/DisconnectProviderOperation.java b/org.spearce.egit.core/src/org/spearce/egit/core/op/DisconnectProviderOperation.java
index 7fde335..b63c69b 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/op/DisconnectProviderOperation.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/op/DisconnectProviderOperation.java
@@ -8,13 +8,13 @@
package org.spearce.egit.core.op;
import java.util.Collection;
-import java.util.Iterator;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
@@ -51,9 +51,8 @@ public class DisconnectProviderOperation implements IWorkspaceRunnable {
m.beginTask(CoreText.DisconnectProviderOperation_disconnecting,
projectList.size() * 200);
try {
- final Iterator i = projectList.iterator();
- while (i.hasNext()) {
- final Object obj = i.next();
+ for (Object obj : projectList) {
+ obj = ((IAdaptable)obj).getAdapter(IResource.class);
if (obj instanceof IProject) {
final IProject p = (IProject) obj;
diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/op/TrackOperation.java b/org.spearce.egit.core/src/org/spearce/egit/core/op/TrackOperation.java
index af16cdb..29b4344 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/op/TrackOperation.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/op/TrackOperation.java
@@ -21,6 +21,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceVisitor;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.team.core.Team;
@@ -65,9 +66,8 @@ public class TrackOperation implements IWorkspaceRunnable {
final IdentityHashMap<RepositoryMapping, Boolean> tomerge = new IdentityHashMap<RepositoryMapping, Boolean>();
m.beginTask(CoreText.AddOperation_adding, rsrcList.size() * 200);
try {
- final Iterator i = rsrcList.iterator();
- while (i.hasNext()) {
- final Object obj = i.next();
+ for (Object obj : rsrcList) {
+ obj = ((IAdaptable)obj).getAdapter(IResource.class);
if (obj instanceof IResource) {
final IResource toAdd = (IResource)obj;
final RepositoryMapping rm = RepositoryMapping.getMapping(toAdd);
diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/op/UntrackOperation.java b/org.spearce.egit.core/src/org/spearce/egit/core/op/UntrackOperation.java
index fdc9c2e..369ff38 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/op/UntrackOperation.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/op/UntrackOperation.java
@@ -20,6 +20,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceVisitor;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.spearce.egit.core.Activator;
@@ -62,9 +63,8 @@ public class UntrackOperation implements IWorkspaceRunnable {
final IdentityHashMap<RepositoryMapping, Boolean> tomerge = new IdentityHashMap<RepositoryMapping, Boolean>();
m.beginTask(CoreText.AddOperation_adding, rsrcList.size() * 200);
try {
- final Iterator i = rsrcList.iterator();
- while (i.hasNext()) {
- final Object obj = i.next();
+ for (Object obj : rsrcList) {
+ obj = ((IAdaptable)obj).getAdapter(IResource.class);
if (obj instanceof IResource) {
final IResource toRemove = (IResource)obj;
final IProject p = toRemove.getProject();
--
1.5.6.2.220.g44701
^ permalink raw reply related
* [EGIT PATCH 4/6] Teach the revision selection handler about the active repository
From: Robin Rosenberg @ 2008-07-10 22:39 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git, Marek Zawirski, Robin Rosenberg
In-Reply-To: <1215729573-26536-4-git-send-email-robin.rosenberg@dewire.com>
The handler needs to know which repository the selected revision was in.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../egit/ui/internal/history/GitHistoryPage.java | 4 ++++
.../history/RevObjectSelectionProvider.java | 19 +++++++++++++++++++
2 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
index d8777ef..6b55185 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
@@ -503,6 +503,8 @@ public class GitHistoryPage extends HistoryPage {
@Override
public boolean inputSet() {
+ if (revObjectSelectionProvider != null)
+ revObjectSelectionProvider.setActiveRepository(null);
cancelRefreshJob();
if (graph == null)
@@ -589,9 +591,11 @@ public class GitHistoryPage extends HistoryPage {
list.source(currentWalk);
final GenerateHistoryJob rj = new GenerateHistoryJob(this, list);
+ final Repository fdb = db;
rj.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(final IJobChangeEvent event) {
+ revObjectSelectionProvider.setActiveRepository(fdb);
final Control graphctl = graph.getControl();
if (job != rj || graphctl.isDisposed())
return;
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/RevObjectSelectionProvider.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/RevObjectSelectionProvider.java
index c44b229..46a091c 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/RevObjectSelectionProvider.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/RevObjectSelectionProvider.java
@@ -14,6 +14,7 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.spearce.jgit.lib.Repository;
/**
* A selection provider for Git revision objects
@@ -24,6 +25,8 @@ public class RevObjectSelectionProvider implements ISelectionProvider {
private ISelection selection;
+ private Repository repository;
+
public void addSelectionChangedListener(ISelectionChangedListener listener) {
listeners.add(listener);
}
@@ -45,4 +48,20 @@ public class RevObjectSelectionProvider implements ISelectionProvider {
}
}
+ /**
+ * Sets the active repository. This one is called by the view when the view
+ * is updated with new data.
+ *
+ * @param repository
+ */
+ public void setActiveRepository(Repository repository) {
+ this.repository = repository;
+ }
+
+ /**
+ * @return currently active repository
+ */
+ public Repository getActiveRepository() {
+ return repository;
+ }
}
--
1.5.6.2.220.g44701
^ permalink raw reply related
* [EGIT PATCH 1/6] Create a selection handler for the revision graph.
From: Robin Rosenberg @ 2008-07-10 22:39 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git, Marek Zawirski, Robin Rosenberg
In-Reply-To: <1215729573-26536-1-git-send-email-robin.rosenberg@dewire.com>
This make it possible to associate content menu contributions
with selections in the history graph.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../egit/ui/internal/history/GitHistoryPage.java | 11 ++++-
.../history/RevObjectSelectionProvider.java | 48 ++++++++++++++++++++
2 files changed, 57 insertions(+), 2 deletions(-)
create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/RevObjectSelectionProvider.java
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
index 9bcae19..6eaa6e4 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
@@ -181,6 +181,11 @@ public class GitHistoryPage extends HistoryPage {
*/
private List<String> pathFilters;
+ /**
+ * The selection provider tracks the selected revisions for the context menu
+ */
+ private RevObjectSelectionProvider revObjectSelectionProvider;
+
@Override
public void createControl(final Composite parent) {
GridData gd;
@@ -211,6 +216,7 @@ public class GitHistoryPage extends HistoryPage {
layoutSashForm(graphDetailSplit, SPLIT_GRAPH);
layoutSashForm(revInfoSplit, SPLIT_INFO);
+ revObjectSelectionProvider = new RevObjectSelectionProvider();
popupMgr = new MenuManager(null, POPUP_ID);
attachCommitSelectionChanged();
createLocalToolbarActions();
@@ -221,7 +227,6 @@ public class GitHistoryPage extends HistoryPage {
attachContextMenu(graph.getControl());
attachContextMenu(commentViewer.getControl());
attachContextMenu(fileViewer.getControl());
-
layout();
}
@@ -229,7 +234,8 @@ public class GitHistoryPage extends HistoryPage {
popupMgr.add(new Separator());
popupMgr.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
getSite().registerContextMenu(POPUP_ID, popupMgr,
- getSite().getSelectionProvider());
+ revObjectSelectionProvider);
+ getSite().setSelectionProvider(revObjectSelectionProvider);
}
private void attachContextMenu(final Control c) {
@@ -299,6 +305,7 @@ public class GitHistoryPage extends HistoryPage {
c = (PlotCommit<?>) sel.getFirstElement();
commentViewer.setInput(c);
fileViewer.setInput(c);
+ revObjectSelectionProvider.setSelection(s);
}
});
commentViewer
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/RevObjectSelectionProvider.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/RevObjectSelectionProvider.java
new file mode 100644
index 0000000..c44b229
--- /dev/null
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/RevObjectSelectionProvider.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * See LICENSE for the full license text, also available.
+ *******************************************************************************/
+package org.spearce.egit.ui.internal.history;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+
+/**
+ * A selection provider for Git revision objects
+ */
+public class RevObjectSelectionProvider implements ISelectionProvider {
+
+ private List<ISelectionChangedListener> listeners = new ArrayList<ISelectionChangedListener>();
+
+ private ISelection selection;
+
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ listeners.add(listener);
+ }
+
+ public ISelection getSelection() {
+ return selection;
+ }
+
+ public void removeSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ listeners.remove(listener);
+ }
+
+ public void setSelection(ISelection selection) {
+ this.selection = selection;
+ SelectionChangedEvent event = new SelectionChangedEvent(this, selection);
+ for (ISelectionChangedListener l : listeners) {
+ l.selectionChanged(event);
+ }
+ }
+
+}
--
1.5.6.2.220.g44701
^ permalink raw reply related
* [EGIT PATCH 2/6] Using the page site selection turned out to be cumbersome.
From: Robin Rosenberg @ 2008-07-10 22:39 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git, Marek Zawirski, Robin Rosenberg
In-Reply-To: <1215729573-26536-2-git-send-email-robin.rosenberg@dewire.com>
So we use the view site instead. I'm not sure that is the proper
way though.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
org.spearce.egit.ui/plugin.xml | 23 ++++++++++++++++++++
.../egit/ui/internal/history/GitHistoryPage.java | 3 +-
2 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/org.spearce.egit.ui/plugin.xml b/org.spearce.egit.ui/plugin.xml
index 611829a..924c6e5 100644
--- a/org.spearce.egit.ui/plugin.xml
+++ b/org.spearce.egit.ui/plugin.xml
@@ -97,6 +97,29 @@
menubarPath="team.main/group1"
tooltip="%CommitAction_tooltip"/>
</objectContribution>
+ <objectContribution
+ id="org.spearce.egit.ui.revobjectContributions"
+ adaptable="true"
+ objectClass="org.spearce.jgit.revwalk.RevObject">
+ <action
+ class="org.spearce.egit.ui.internal.actions.BranchAction"
+ id="org.spearce.egit.ui.action1"
+ label="Kolla"
+ enablesFor="*"
+ menubarPath="additions">
+ </action>
+ </objectContribution>
+ <viewerContribution
+ id="org.spearce.egit.ui.viewerContribution1"
+ targetID="org.spearce.egit.ui.historyPageContributions">
+ <action
+ class="org.spearce.egit.ui.internal.actions.ResetAction"
+ id="org.spearce.egit.ui.action1"
+ label="Titta"
+ enablesFor="*"
+ menubarPath="additions">
+ </action>
+ </viewerContribution>
</extension>
<extension
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
index 6eaa6e4..d8777ef 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
@@ -235,7 +235,8 @@ public class GitHistoryPage extends HistoryPage {
popupMgr.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
getSite().registerContextMenu(POPUP_ID, popupMgr,
revObjectSelectionProvider);
- getSite().setSelectionProvider(revObjectSelectionProvider);
+ getHistoryPageSite().getPart().getSite().setSelectionProvider(
+ revObjectSelectionProvider);
}
private void attachContextMenu(final Control c) {
--
1.5.6.2.220.g44701
^ permalink raw reply related
* [EGIT PATCH 0/6] RevObject selection handler
From: Robin Rosenberg @ 2008-07-10 22:39 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git, Marek Zawirski, Robin Rosenberg
This adds a new type of selection handler that connects to the
history view, but could be used in other, yet to be invented
views. It allows us to declare actions using the view and
object contribution mechanism. And then some uses of that code.
-- robin
Robin Rosenberg (6):
Create a selection handler for the revision graph.
Using the page site selection turned out to be cumbersome.
Adapt Git team operations to non-resouce objects
Teach the revision selection handler about the active repository
Create baseclasses for actions and operations on RevObjects
Add actions in history view to perform reset actions
.../org/spearce/egit/core/internal/UpdateJob.java | 2 +
.../egit/core/op/AssumeUnchangedOperation.java | 6 +-
.../egit/core/op/DisconnectProviderOperation.java | 7 +-
.../org/spearce/egit/core/op/TrackOperation.java | 6 +-
.../org/spearce/egit/core/op/UntrackOperation.java | 6 +-
org.spearce.egit.ui/plugin.xml | 28 ++++++++
.../internal/actions/AbstractOperationAction.java | 15 +++--
.../internal/actions/AbstractRevObjectAction.java | 26 ++++++++
.../actions/AbstractRevObjectOperation.java | 21 ++++++
.../actions/HardResetToRevisionAction.java | 26 ++++++++
.../actions/MixedResetToRevisionAction.java | 26 ++++++++
.../actions/SoftResetToRevisionAction.java | 26 ++++++++
.../egit/ui/internal/history/GitHistoryPage.java | 16 ++++-
.../history/RevObjectSelectionProvider.java | 67 ++++++++++++++++++++
14 files changed, 258 insertions(+), 20 deletions(-)
create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractRevObjectAction.java
create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractRevObjectOperation.java
create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/HardResetToRevisionAction.java
create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/MixedResetToRevisionAction.java
create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/SoftResetToRevisionAction.java
create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/RevObjectSelectionProvider.java
^ permalink raw reply
* Re: [PATCH] bisect: test merge base if good rev is not an ancestor of bad rev
From: Johannes Schindelin @ 2008-07-10 22:38 UTC (permalink / raw)
To: Christian Couder; +Cc: Junio C Hamano, Michael Haggerty, Jeff King, git
In-Reply-To: <200807110036.17504.chriscool@tuxfamily.org>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1178 bytes --]
Hi,
On Fri, 11 Jul 2008, Christian Couder wrote:
> Le jeudi 10 juillet 2008, Junio C Hamano a écrit :
>
> > - "Test this merge-base before going forward, please" will add
> > typically only one round of check (if you have more merge bases
> > between good and bad, you need to test all of them are good to be
> > sure), so it is not "slower nor more complex".
>
> By "slower" I meant that it would need more rounds of check on average.
> By "more complex" I meant that more code is needed.
>
> And I think you are right, all the merge bases need to be tested so I
> will send a patch on top of the patch discussed here.
Good luck. This will open the scenario where people use a proper ancestor
as "good" revision. In this case, you test that. If it is "bad" you
report that it is the _first_ one.
You are opening a can of worms here, and I doubt that this is a good idea.
git-bisect as-is has very precise, and _simple_ semantics, and users
should really know what they are doing (i.e. not marking something as
"good" which is on a branch containing a fix).
Trying to be too clever here might just make the whole tool rather
useless.
Ciao,
Dscho
^ permalink raw reply
* Re: [PATCH] git-mailinfo: Fix getting the subject from the body
From: Lukas Sandström @ 2008-07-10 22:37 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git Mailing List, Lukas Sandström
In-Reply-To: <7vod55o0tx.fsf@gitster.siamese.dyndns.org>
Junio C Hamano wrote:
> Lukas Sandström <lukass@etek.chalmers.se> writes:
>
>> "Subject: " isn't in the static array "header", and thus
>> memcmp("Subject: ", header[i], 7) will never match.
>>
>> Signed-off-by: Lukas Sandström <lukass@etek.chalmers.se>
>> ---
>>
>> This has been broken since 2007-03-12, with commit
>> 87ab799234639c26ea10de74782fa511cb3ca606
>> so it might not be very important.
>
> Wow, thanks. Perhaps we would want some additional test scripts?
Yes, apparently.
After looking at this part some more, I see that there is no guarantee
that hdr_data[i] != NULL in this codepath, and then we won't use the
subject anyway.
I'm currently working on rewriting git-mailinfo to use strbuf's insted
of the preallocated buffers currently used. Do you want me to send a
patch allocating hdr_data[i], or can you wait for my strbuf-conversion
patch? It'll propably be ready for review tonight.
/Lukas
^ permalink raw reply
* Re: [PATCH] bisect: test merge base if good rev is not an ancestor of bad rev
From: Christian Couder @ 2008-07-10 22:36 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Johannes Schindelin, Michael Haggerty, Jeff King, git
In-Reply-To: <7vd4llpkxq.fsf@gitster.siamese.dyndns.org>
Le jeudi 10 juillet 2008, Junio C Hamano a écrit :
> Christian Couder <chriscool@tuxfamily.org> writes:
> > Yeah, in that case...
> >
> >> The whole idea of "bisect" relies on that idea, that any ancestor of a
> >> good commit is good. Otherwise you'd have to check the commits one by
> >> one, not in a bisecting manner.
>
> Didn't we already discuss this at length?
Yes, the thread is there:
http://thread.gmane.org/gmane.comp.version-control.git/86951
> > No, you just need to check that the merge bases between the bad rev on
> > one side and each good rev on the other side are good too. And if that
> > is the case, then you can be sure that bisection will point to a first
> > bad commit.
> >
> > So the choice is between a simple and fast but not fully reliable
> > bisect, or a more complex and slower but fully reliable bisect.
>
> I have not looked at your implementation, but I do think:
>
> - The current one is not "fully reliable"; the user needs to know what
> he is doing. You might call it "prone to user errors".
I agree.
> - "Test this merge-base before going forward, please" will add typically
> only one round of check (if you have more merge bases between good and
> bad, you need to test all of them are good to be sure), so it is not
> "slower nor more complex".
By "slower" I meant that it would need more rounds of check on average.
By "more complex" I meant that more code is needed.
And I think you are right, all the merge bases need to be tested so I will
send a patch on top of the patch discussed here.
Another idea to fix the problem, might be to bisect as usual and at the end
before saying "X is first bad commit" to check if some of X parents are
merge bases between the bad rev and a good rev. If that is the case, then
we could ask the user to check that these parents are all good. On average
this would probably reduce the number of revs the user must check.
Regards,
Christian.
^ permalink raw reply
* Re: [JGIT PATCH 2/5] Don't display passwords on the console in fetch/push output
From: Johannes Schindelin @ 2008-07-10 22:25 UTC (permalink / raw)
To: Robin Rosenberg; +Cc: Shawn O. Pearce, Marek Zawirski, git
In-Reply-To: <200807102217.38459.robin.rosenberg.lists@dewire.com>
Hi,
On Thu, 10 Jul 2008, Robin Rosenberg wrote:
> >From 99c09cf2321f36eb81043aed2fa6834811ee762b Mon Sep 17 00:00:00 2001
> From: Robin Rosenberg <robin.rosenberg@dewire.com>
> Date: Thu, 10 Jul 2008 22:16:19 +0200
> Subject: [PATCH] Avoid password leak from URIIsh
What is this new fashion of sending them headers in the mail body? Robin,
I thought you knew better.
Ciao,
Dscho
^ permalink raw reply
* Re: feature request: git-log should accept sth like v2.6.26-rc8-227
From: Johannes Schindelin @ 2008-07-10 22:24 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Jakub Narebski, Toralf Förster, git
In-Reply-To: <7v8ww9pkv8.fsf@gitster.siamese.dyndns.org>
Hi,
On Thu, 10 Jul 2008, Junio C Hamano wrote:
> Jakub Narebski <jnareb@gmail.com> writes:
>
> > Besides, it would be nice to have some command (git-rev-parse
> > perhaps?) which could take ambiguous commit-ish, and list all commit
> > which matches it.
>
> Have fun writing it and send in a patch.
Note that this really could be a patch, but not for rev-parse. Patch
revision.c instead to parse the argument into _all_ matching revisions.
The :/ notation I no longer like so much should give you a lot of
inspiration.
Good luck,
Dscho
^ permalink raw reply
* Re: THREADED_DELTA_SEARCH
From: Alex Riesen @ 2008-07-10 22:19 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: Junio C Hamano, Pierre Habouzit, Git ML
In-Reply-To: <alpine.LFD.1.10.0807101633480.12484@xanadu.home>
Nicolas Pitre, Thu, Jul 10, 2008 22:36:35 +0200:
> > There are just systems were resources are a problem.
>
> Then on those systems you simply have to adjust the appropriate knob.
_after_ they crashed?
^ permalink raw reply
* Re: Errors importing Apache Synapse SVN using Git
From: Björn Steinbrink @ 2008-07-10 22:02 UTC (permalink / raw)
To: Michael J Gruber; +Cc: git
In-Reply-To: <g55130$n3i$1@ger.gmane.org>
On 2008.07.10 14:59:11 +0200, Michael J Gruber wrote:
> Asankha C. Perera venit, vidit, dixit 10.07.2008 14:01:
>> Hi All
>>
>> I am an Apache Synapse developer, and want to import the Synapse SVN
>> repo into Git, so that Ohloh can properly get the Synapse history
>> (http://www.ohloh.net/topics/1326?page=1#post_6287)
>>
>> However, when I try the command: "git svn clone --trunk=trunk
>> --tags=tags --branches=branches
>> http://svn.apache.org/repos/asf/synapse" it seems to take forever, (or
>> at least until the next network glitch), and keeps filling up a file
>> with just plain zeros ("0") :
>> ./.git/svn/trunk/.rev_db.13f79535-47bb-0310-9956-ffa450edef68
>>
>> Can someone try the above command on the Synapse repo and tell me what
>> I can do to import from the SVN?
>
> "svn log" takes forever on that repo, too. Current rev seems to be
> 675546, and the synapse path does not exist in early revisions. Knowing
> the initial revision would help, then you could save "git svn" from
> having to comb through (supposedly) tens of thousands of irrelevant revs.
>
> I just checked out trunk using svn 1.4.6, "svn log ." takes forever in
> the root dir. So the svn repo seems to be largely unusable, at least
> when accessed from svn 1.4.6 clients (the server is 1.5.0, I see).
>
> Okay, I bisected it and got r234477 as the beginning of time for
> synapse. "svn log -r 234477:HEAD" is still painful.
>
> You may want to fetch 1000 revs each or so from there each time.
Also, upgrading git to 1.5.6.2 might be a good idea. It doesn't use the
.revdb file format anymore, but a more efficient .revmap file. And it
has quite a few performance improvements (although they won't help
against the primary issue with that svn server). Don't use
1.5.6/1.5.6.1, they have a git-svn bug that can lead to corrupted clones
(just in case that your distro has packages for those versions but not
yet got 1.5.6.2).
Björn
^ permalink raw reply
* [PATCH] git-mailinfo: Fix getting the subject from the body
From: Lukas Sandström @ 2008-07-10 21:41 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Lukas Sandström, Git Mailing List
"Subject: " isn't in the static array "header", and thus
memcmp("Subject: ", header[i], 7) will never match.
Signed-off-by: Lukas Sandström <lukass@etek.chalmers.se>
---
This has been broken since 2007-03-12, with commit
87ab799234639c26ea10de74782fa511cb3ca606
so it might not be very important.
builtin-mailinfo.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index 962aa34..2d1520f 100644
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
@@ -334,7 +334,7 @@ static int check_header(char *line, unsigned linesize, char **hdr_data, int over
return 1;
if (!memcmp("[PATCH]", line, 7) && isspace(line[7])) {
for (i = 0; header[i]; i++) {
- if (!memcmp("Subject: ", header[i], 9)) {
+ if (!memcmp("Subject", header[i], 7)) {
if (! handle_header(line, hdr_data[i], 0)) {
return 1;
}
--
1.5.4.5
^ permalink raw reply related
* [PATCH] git-mailinfo: document the -n option
From: Lukas Sandström @ 2008-07-10 21:36 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Lukas Sandström, Git Mailing List
Signed-off-by: Lukas Sandström <lukass@etek.chalmers.se>
---
Documentation/git-mailinfo.txt | 5 ++++-
builtin-mailinfo.c | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-mailinfo.txt b/Documentation/git-mailinfo.txt
index cc52db3..316bcc6 100644
--- a/Documentation/git-mailinfo.txt
+++ b/Documentation/git-mailinfo.txt
@@ -8,7 +8,7 @@ git-mailinfo - Extracts patch and authorship from a single e-mail message
SYNOPSIS
--------
-'git mailinfo' [-k] [-u | --encoding=<encoding>] <msg> <patch>
+'git mailinfo' [-k] [-u | --encoding=<encoding> | -n] <msg> <patch>
DESCRIPTION
@@ -46,6 +46,9 @@ conversion, even with this flag.
from what is specified by i18n.commitencoding, this flag
can be used to override it.
+-n::
+ Disable all charset re-coding of the metadata.
+
<msg>::
The commit log message extracted from e-mail, usually
except the title line which comes from e-mail Subject.
diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index fa6e8f9..962aa34 100644
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
@@ -960,7 +960,7 @@ static int mailinfo(FILE *in, FILE *out, int ks, const char *encoding,
}
static const char mailinfo_usage[] =
- "git-mailinfo [-k] [-u | --encoding=<encoding>] msg patch <mail >info";
+ "git-mailinfo [-k] [-u | --encoding=<encoding> | -n] msg patch <mail >info";
int cmd_mailinfo(int argc, const char **argv, const char *prefix)
{
--
1.5.4.5
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox