From 3943da39d2331c0e8f9c024a66f100f8b98b53cf Mon Sep 17 00:00:00 2001 From: Robin Rosenberg Date: Tue, 21 Aug 2007 23:29:51 +0200 Subject: [PATCH] Make attempt to refresh when merge conflicts exists more user friendly The index code does not handle conflict entries (yet). Signed-off-by: Robin Rosenberg --- .../org/spearce/egit/core/internal/UpdateJob.java | 3 +++ .../spearce/jgit/errors/NotSupportedException.java | 27 ++++++++++++++++++++++ .../src/org/spearce/jgit/lib/GitIndex.java | 3 ++- 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 org.spearce.jgit/src/org/spearce/jgit/errors/NotSupportedException.java 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 013874bb..72b41908 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 @@ -36,6 +36,7 @@ import org.eclipse.core.runtime.jobs.Job; import org.spearce.egit.core.Activator; import org.spearce.egit.core.CoreText; import org.spearce.egit.core.project.RepositoryMapping; +import org.spearce.jgit.errors.NotSupportedException; import org.spearce.jgit.lib.GitIndex; import org.spearce.jgit.lib.GitIndex.Entry; @@ -117,6 +118,8 @@ public class UpdateJob extends Job { m.setTaskName("Writing index for "+rm.getRepository().getDirectory()); rm.getRepository().getIndex().write(); } + } catch (NotSupportedException e) { + return Activator.error(e.getMessage(),e).getStatus(); } catch (RuntimeException e) { e.printStackTrace(); return Activator.error(CoreText.UpdateOperation_failed, e).getStatus(); diff --git a/org.spearce.jgit/src/org/spearce/jgit/errors/NotSupportedException.java b/org.spearce.jgit/src/org/spearce/jgit/errors/NotSupportedException.java new file mode 100644 index 00000000..d291b0f9 --- /dev/null +++ b/org.spearce.jgit/src/org/spearce/jgit/errors/NotSupportedException.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 20067 Robin Rosenberg + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License, version 2, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + */ +package org.spearce.jgit.errors; + +import java.io.IOException; + +public class NotSupportedException extends IOException { + private static final long serialVersionUID = 1L; + + public NotSupportedException(final String s) { + super(s); + } +} 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 a379460d..d2e78f9d 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java @@ -22,6 +22,7 @@ import java.util.Stack; import java.util.TreeMap; import org.spearce.jgit.errors.CorruptObjectException; +import org.spearce.jgit.errors.NotSupportedException; public class GitIndex { @@ -176,7 +177,7 @@ public class GitIndex { for (Iterator i = entries.values().iterator(); i.hasNext();) { Entry e = (Entry) i.next(); if (e.stage != 0) { - throw new IOException("Cannot work with other stages than zero right now. Won't write corrupt index."); + throw new NotSupportedException("Cannot work with other stages than zero right now. Won't write corrupt index."); } } } -- 2.11.4.GIT