diff options
234 files changed, 2766 insertions, 1007 deletions
diff --git a/org.eclipse.jgit.console/.classpath b/org.eclipse.jgit.console/.classpath index ad32c83a78..31db9a9117 100644 --- a/org.eclipse.jgit.console/.classpath +++ b/org.eclipse.jgit.console/.classpath @@ -3,5 +3,6 @@ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="resources"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/org.eclipse.jgit.console/META-INF/MANIFEST.MF b/org.eclipse.jgit.console/META-INF/MANIFEST.MF index 7c97c5ab0f..792a7cd6bb 100644 --- a/org.eclipse.jgit.console/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.console/META-INF/MANIFEST.MF @@ -7,6 +7,7 @@ Bundle-Version: 0.8.0.qualifier Bundle-Vendor: %provider_name Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Export-Package: org.eclipse.jgit.console;version="0.8.0" -Import-Package: org.eclipse.jgit.transport;version="[0.8.0,0.9.0)", +Import-Package: org.eclipse.jgit.nls;version="[0.8.0,0.9.0)", + org.eclipse.jgit.transport;version="[0.8.0,0.9.0)", org.eclipse.jgit.util;version="[0.8.0,0.9.0)" Require-Bundle: com.jcraft.jsch;bundle-version="[0.1.37,0.2.0)" diff --git a/org.eclipse.jgit.console/pom.xml b/org.eclipse.jgit.console/pom.xml index b33c5724d7..11ac7019a2 100644 --- a/org.eclipse.jgit.console/pom.xml +++ b/org.eclipse.jgit.console/pom.xml @@ -84,6 +84,9 @@ <include>plugin.properties</include> </includes> </resource> + <resource> + <directory>resources/</directory> + </resource> </resources> <plugins> diff --git a/org.eclipse.jgit.console/resources/org/eclipse/jgit/console/ConsoleText.properties b/org.eclipse.jgit.console/resources/org/eclipse/jgit/console/ConsoleText.properties new file mode 100644 index 0000000000..9aaf2298da --- /dev/null +++ b/org.eclipse.jgit.console/resources/org/eclipse/jgit/console/ConsoleText.properties @@ -0,0 +1,5 @@ +answerNo=n +answerYes=y +noSystemConsoleAvailable=No System.console available +password=Password: +usernameFor=Username for {0}: diff --git a/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleAuthenticator.java b/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleAuthenticator.java index 84fd520f75..3df5e44331 100644 --- a/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleAuthenticator.java +++ b/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleAuthenticator.java @@ -47,6 +47,7 @@ package org.eclipse.jgit.console; import java.io.Console; import java.net.Authenticator; import java.net.PasswordAuthentication; +import java.text.MessageFormat; import org.eclipse.jgit.util.CachedAuthenticator; @@ -56,7 +57,7 @@ public class ConsoleAuthenticator extends CachedAuthenticator { public static void install() { final ConsoleAuthenticator c = new ConsoleAuthenticator(); if (c.cons == null) - throw new NoClassDefFoundError("No System.console available"); + throw new NoClassDefFoundError(ConsoleText.get().noSystemConsoleAvailable); Authenticator.setDefault(c); } @@ -65,11 +66,11 @@ public class ConsoleAuthenticator extends CachedAuthenticator { @Override protected PasswordAuthentication promptPasswordAuthentication() { final String realm = formatRealm(); - String username = cons.readLine("Username for %s: ", realm); + String username = cons.readLine(MessageFormat.format(ConsoleText.get().usernameFor + " ", realm)); if (username == null || username.isEmpty()) { return null; } - char[] password = cons.readPassword("Password: "); + char[] password = cons.readPassword(ConsoleText.get().password + " "); if (password == null) { password = new char[0]; } diff --git a/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleSshSessionFactory.java b/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleSshSessionFactory.java index 7d36dded48..b11078dea8 100644 --- a/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleSshSessionFactory.java +++ b/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleSshSessionFactory.java @@ -70,7 +70,7 @@ public class ConsoleSshSessionFactory extends SshConfigSessionFactory { public static void install() { final ConsoleSshSessionFactory c = new ConsoleSshSessionFactory(); if (c.cons == null) - throw new NoClassDefFoundError("No System.console available"); + throw new NoClassDefFoundError(ConsoleText.get().noSystemConsoleAvailable); SshSessionFactory.setInstance(c); } @@ -93,8 +93,8 @@ public class ConsoleSshSessionFactory extends SshConfigSessionFactory { } public boolean promptYesNo(final String msg) { - String r = cons.readLine("%s [y/n]? ", msg); - return "y".equalsIgnoreCase(r); + String r = cons.readLine("%s [%s/%s]? ", msg, ConsoleText.get().answerYes, ConsoleText.get().answerNo); + return ConsoleText.get().answerYes.equalsIgnoreCase(r); } public boolean promptPassword(final String msg) { diff --git a/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleText.java b/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleText.java new file mode 100644 index 0000000000..3f1734b01a --- /dev/null +++ b/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleText.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2010, Sasa Zivkov <sasa.zivkov@sap.com> + * and other copyright owners as documented in the project's IP log. + * + * This program and the accompanying materials are made available + * under the terms of the Eclipse Distribution License v1.0 which + * accompanies this distribution, is reproduced below, and is + * available at http://www.eclipse.org/org/documents/edl-v10.php + * + * 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 Eclipse Foundation, Inc. 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.eclipse.jgit.console; + +import org.eclipse.jgit.nls.NLS; +import org.eclipse.jgit.nls.TranslationBundle; + +/** + * Translation bundle for JGit console + */ +public class ConsoleText extends TranslationBundle { + + /** + * @return an instance of this translation bundle + */ + public static ConsoleText get() { + return NLS.getBundleFor(ConsoleText.class); + } + + /***/ public String answerNo; + /***/ public String answerYes; + /***/ public String noSystemConsoleAvailable; + /***/ public String password; + /***/ public String usernameFor; +} diff --git a/org.eclipse.jgit.http.server/.classpath b/org.eclipse.jgit.http.server/.classpath index 304e86186a..d7edf529a2 100644 --- a/org.eclipse.jgit.http.server/.classpath +++ b/org.eclipse.jgit.http.server/.classpath @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="resources"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="output" path="bin"/> diff --git a/org.eclipse.jgit.http.server/META-INF/MANIFEST.MF b/org.eclipse.jgit.http.server/META-INF/MANIFEST.MF index 3bde0dc42f..c772f5db0a 100644 --- a/org.eclipse.jgit.http.server/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.http.server/META-INF/MANIFEST.MF @@ -15,6 +15,7 @@ Import-Package: javax.servlet;version="[2.5.0,3.0.0)", javax.servlet.http;version="[2.5.0,3.0.0)", org.eclipse.jgit.errors;version="[0.8.0,0.9.0)", org.eclipse.jgit.lib;version="[0.8.0,0.9.0)", + org.eclipse.jgit.nls;version="[0.8.0,0.9.0)", org.eclipse.jgit.revwalk;version="[0.8.0,0.9.0)", org.eclipse.jgit.transport;version="[0.8.0,0.9.0)", org.eclipse.jgit.util;version="[0.8.0,0.9.0)", diff --git a/org.eclipse.jgit.http.server/pom.xml b/org.eclipse.jgit.http.server/pom.xml index 5fba55cbcd..08489ac163 100644 --- a/org.eclipse.jgit.http.server/pom.xml +++ b/org.eclipse.jgit.http.server/pom.xml @@ -90,6 +90,9 @@ <include>plugin.properties</include> </includes> </resource> + <resource> + <directory>resources/</directory> + </resource> </resources> <plugins> diff --git a/org.eclipse.jgit.http.server/resources/org/eclipse/jgit/http/server/HttpServerText.properties b/org.eclipse.jgit.http.server/resources/org/eclipse/jgit/http/server/HttpServerText.properties new file mode 100644 index 0000000000..8e36aab28b --- /dev/null +++ b/org.eclipse.jgit.http.server/resources/org/eclipse/jgit/http/server/HttpServerText.properties @@ -0,0 +1,21 @@ +alreadyInitializedByContainer=Already initialized by container +cannotGetLengthOf=Cannot get length of {0} +encodingNotSupportedByThisLibrary={0} "{1}": not supported by this library. +expectedRepositoryAttribute=Expected Repository attribute +filterMustNotBeNull=filter must not be null +internalErrorDuringReceivePack=Internal error during receive-pack +internalErrorDuringUploadPack=Internal error during upload-pack +internalServerErrorRequestAttributeWasAlreadySet=Internal server error, request attribute {0} was already set when {1} was invoked. +invalidBoolean=Invalid boolean {0} = {1} +invalidIndex=Invalid index: {0} +invalidRegexGroup=Invalid regex group {0} +noResolverAvailable=No resolver available +parameterNotSet=Parameter {0} not set +pathForParamNotFound={0} (for {1}) not found +pathNotSupported={0} not supported +serviceNotEnabled=Service not enabled +serviceNotPermitted=Service not permitted +servletAlreadyInitialized=Servlet already initialized +servletMustNotBeNull=servlet must not be null +servletWasAlreadyBound=servlet was already bound +unexpectedeOFOn=Unexpected EOF on {0} diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/FileSender.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/FileSender.java index 280450d01a..6b746e3193 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/FileSender.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/FileSender.java @@ -57,6 +57,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.OutputStream; import java.io.RandomAccessFile; +import java.text.MessageFormat; import java.util.Enumeration; import javax.servlet.http.HttpServletRequest; @@ -100,7 +101,7 @@ final class FileSender { } final FileNotFoundException r; - r = new FileNotFoundException("Cannot get length of " + path); + r = new FileNotFoundException(MessageFormat.format(HttpServerText.get().cannotGetLengthOf, path)); r.initCause(e); throw r; } @@ -143,7 +144,7 @@ final class FileSender { final int r = (int) Math.min(buf.length, end - pos); final int n = source.read(buf, 0, r); if (n < 0) { - throw new EOFException("Unexpected EOF on " + path); + throw new EOFException(MessageFormat.format(HttpServerText.get().unexpectedeOFOn, path)); } out.write(buf, 0, n); pos += n; diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitServlet.java index dced779c98..cc4cf6a800 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitServlet.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitServlet.java @@ -44,6 +44,7 @@ package org.eclipse.jgit.http.server; import java.io.File; +import java.text.MessageFormat; import javax.servlet.ServletConfig; import javax.servlet.ServletException; @@ -169,7 +170,7 @@ public class GitServlet extends MetaServlet { private void assertNotInitialized() { if (initialized) - throw new IllegalStateException("Already initialized by container"); + throw new IllegalStateException(HttpServerText.get().alreadyInitializedByContainer); } @Override @@ -259,11 +260,11 @@ public class GitServlet extends MetaServlet { private File getFile(final String param) throws ServletException { String n = getInitParameter(param); if (n == null || "".equals(n)) - throw new ServletException("Parameter " + param + " not set"); + throw new ServletException(MessageFormat.format(HttpServerText.get().parameterNotSet, param)); File path = new File(n); if (!path.exists()) - throw new ServletException(path + " (for " + param + ") not found"); + throw new ServletException(MessageFormat.format(HttpServerText.get().pathForParamNotFound, path, param)); return path; } @@ -274,14 +275,14 @@ public class GitServlet extends MetaServlet { try { return StringUtils.toBoolean(n); } catch (IllegalArgumentException err) { - throw new ServletException("Invalid boolean " + param + " = " + n); + throw new ServletException(MessageFormat.format(HttpServerText.get().invalidBoolean, param, n)); } } @Override protected ServletBinder register(ServletBinder binder) { if (resolver == null) - throw new IllegalStateException("No resolver available"); + throw new IllegalStateException(HttpServerText.get().noResolverAvailable); binder = binder.through(new NoCacheFilter()); binder = binder.through(new RepositoryFilter(resolver)); return binder; diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/HttpServerText.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/HttpServerText.java new file mode 100644 index 0000000000..8ad0eb0497 --- /dev/null +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/HttpServerText.java @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2010, Sasa Zivkov <sasa.zivkov@sap.com> + * and other copyright owners as documented in the project's IP log. + * + * This program and the accompanying materials are made available + * under the terms of the Eclipse Distribution License v1.0 which + * accompanies this distribution, is reproduced below, and is + * available at http://www.eclipse.org/org/documents/edl-v10.php + * + * 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 Eclipse Foundation, Inc. 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.eclipse.jgit.http.server; + +import org.eclipse.jgit.nls.NLS; +import org.eclipse.jgit.nls.TranslationBundle; + +/** + * Translation bundle for JGit http server + */ +public class HttpServerText extends TranslationBundle { + + /** + * @return an instance of this translation bundle + */ + public static HttpServerText get() { + return NLS.getBundleFor(HttpServerText.class); + } + + /***/ public String alreadyInitializedByContainer; + /***/ public String cannotGetLengthOf; + /***/ public String encodingNotSupportedByThisLibrary; + /***/ public String expectedRepositoryAttribute; + /***/ public String filterMustNotBeNull; + /***/ public String internalErrorDuringReceivePack; + /***/ public String internalErrorDuringUploadPack; + /***/ public String internalServerErrorRequestAttributeWasAlreadySet; + /***/ public String invalidBoolean; + /***/ public String invalidIndex; + /***/ public String invalidRegexGroup; + /***/ public String noResolverAvailable; + /***/ public String parameterNotSet; + /***/ public String pathForParamNotFound; + /***/ public String pathNotSupported; + /***/ public String serviceNotEnabled; + /***/ public String serviceNotPermitted; + /***/ public String servletAlreadyInitialized; + /***/ public String servletMustNotBeNull; + /***/ public String servletWasAlreadyBound; + /***/ public String unexpectedeOFOn; +} diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java index ba8b8ab669..49fd535a71 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java @@ -120,7 +120,7 @@ class ReceivePackServlet extends HttpServlet { return; } catch (IOException e) { - getServletContext().log("Internal error during receive-pack", e); + getServletContext().log(HttpServerText.get().internalErrorDuringReceivePack, e); rsp.sendError(SC_INTERNAL_SERVER_ERROR); return; } diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java index a212f0d7ba..7975809e87 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java @@ -50,6 +50,7 @@ import static javax.servlet.http.HttpServletResponse.SC_UNAUTHORIZED; import static org.eclipse.jgit.http.server.ServletUtils.ATTRIBUTE_REPOSITORY; import java.io.IOException; +import java.text.MessageFormat; import javax.servlet.Filter; import javax.servlet.FilterChain; @@ -109,9 +110,9 @@ public class RepositoryFilter implements Filter { final ServletResponse rsp, final FilterChain chain) throws IOException, ServletException { if (request.getAttribute(ATTRIBUTE_REPOSITORY) != null) { - context.log("Internal server error, request attribute " - + ATTRIBUTE_REPOSITORY + " was already set when " - + getClass().getName() + " was invoked."); + context.log(MessageFormat.format(HttpServerText.get().internalServerErrorRequestAttributeWasAlreadySet + , ATTRIBUTE_REPOSITORY + , getClass().getName())); ((HttpServletResponse) rsp).sendError(SC_INTERNAL_SERVER_ERROR); return; } diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java index 7514d7c7e7..28dabe4cc7 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java @@ -54,6 +54,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.security.MessageDigest; +import java.text.MessageFormat; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; @@ -85,7 +86,7 @@ public final class ServletUtils { public static Repository getRepository(final ServletRequest req) { Repository db = (Repository) req.getAttribute(ATTRIBUTE_REPOSITORY); if (db == null) - throw new IllegalStateException("Expected Repository attribute"); + throw new IllegalStateException(HttpServerText.get().expectedRepositoryAttribute); return db; } @@ -109,8 +110,8 @@ public final class ServletUtils { if (ENCODING_GZIP.equals(enc) || "x-gzip".equals(enc)) //$NON-NLS-1$ in = new GZIPInputStream(in); else if (enc != null) - throw new IOException(HDR_CONTENT_ENCODING + " \"" + enc + "\"" - + ": not supported by this library."); + throw new IOException(MessageFormat.format(HttpServerText.get().encodingNotSupportedByThisLibrary + , HDR_CONTENT_ENCODING, enc)); return in; } diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java index 8de5f06781..92d41a0caf 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java @@ -122,7 +122,7 @@ class UploadPackServlet extends HttpServlet { return; } catch (IOException e) { - getServletContext().log("Internal error during upload-pack", e); + getServletContext().log(HttpServerText.get().internalErrorDuringUploadPack, e); rsp.reset(); rsp.sendError(SC_INTERNAL_SERVER_ERROR); return; diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/MetaServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/MetaServlet.java index d289743ba4..7764a90c12 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/MetaServlet.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/MetaServlet.java @@ -46,6 +46,7 @@ package org.eclipse.jgit.http.server.glue; import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND; import java.io.IOException; +import java.text.MessageFormat; import java.util.AbstractSet; import java.util.ArrayList; import java.util.IdentityHashMap; @@ -59,6 +60,8 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.eclipse.jgit.http.server.HttpServerText; + /** * Generic container servlet to manage routing to different pipelines. * <p> @@ -95,7 +98,7 @@ public class MetaServlet extends HttpServlet { public ServletBinder serve(String path) { if (path.startsWith("*")) return register(new SuffixPipeline.Binder(path.substring(1))); - throw new IllegalArgumentException("\"" + path + "\" not supported"); + throw new IllegalArgumentException(MessageFormat.format(HttpServerText.get().pathNotSupported, path)); } /** @@ -164,7 +167,7 @@ public class MetaServlet extends HttpServlet { private ServletBinder register(ServletBinderImpl b) { synchronized (bindings) { if (pipelines != null) - throw new IllegalStateException("Servlet already initialized"); + throw new IllegalStateException(HttpServerText.get().servletAlreadyInitialized); bindings.add(b); } return register((ServletBinder) b); diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexGroupFilter.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexGroupFilter.java index ed7b1cf694..5c7b965ff7 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexGroupFilter.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexGroupFilter.java @@ -44,6 +44,7 @@ package org.eclipse.jgit.http.server.glue; import java.io.IOException; +import java.text.MessageFormat; import javax.servlet.Filter; import javax.servlet.FilterChain; @@ -52,6 +53,8 @@ import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; +import org.eclipse.jgit.http.server.HttpServerText; + /** * Switch servlet path and path info to use another regex match group. * <p> @@ -69,7 +72,7 @@ public class RegexGroupFilter implements Filter { */ public RegexGroupFilter(final int groupIdx) { if (groupIdx < 1) - throw new IllegalArgumentException("Invalid index: " + groupIdx); + throw new IllegalArgumentException(MessageFormat.format(HttpServerText.get().invalidIndex, groupIdx)); this.groupIdx = groupIdx - 1; } @@ -88,7 +91,7 @@ public class RegexGroupFilter implements Filter { if (groupIdx < g.length) chain.doFilter(g[groupIdx], rsp); else - throw new ServletException("Invalid regex group " + (groupIdx + 1)); + throw new ServletException(MessageFormat.format(HttpServerText.get().invalidRegexGroup, (groupIdx + 1))); } private static WrappedRequest[] groupsFor(final ServletRequest r) { diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/ServletBinderImpl.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/ServletBinderImpl.java index d4cd445a13..e96fc59dc3 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/ServletBinderImpl.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/ServletBinderImpl.java @@ -50,6 +50,8 @@ import javax.servlet.Filter; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletResponse; +import org.eclipse.jgit.http.server.HttpServerText; + abstract class ServletBinderImpl implements ServletBinder { private final List<Filter> filters; @@ -61,16 +63,16 @@ abstract class ServletBinderImpl implements ServletBinder { public ServletBinder through(Filter filter) { if (filter == null) - throw new NullPointerException("filter must not be null"); + throw new NullPointerException(HttpServerText.get().filterMustNotBeNull); filters.add(filter); return this; } public void with(HttpServlet servlet) { if (servlet == null) - throw new NullPointerException("servlet must not be null"); + throw new NullPointerException(HttpServerText.get().servletMustNotBeNull); if (httpServlet != null) - throw new IllegalStateException("servlet was already bound"); + throw new IllegalStateException(HttpServerText.get().servletWasAlreadyBound); httpServlet = servlet; } diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/ServiceNotAuthorizedException.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/ServiceNotAuthorizedException.java index fca044a10c..6c9bf693d3 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/ServiceNotAuthorizedException.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/ServiceNotAuthorizedException.java @@ -43,12 +43,14 @@ package org.eclipse.jgit.http.server.resolver; +import org.eclipse.jgit.http.server.HttpServerText; + /** Indicates the request service is not authorized for current user. */ public class ServiceNotAuthorizedException extends Exception { private static final long serialVersionUID = 1L; /** Indicates the request service is not available. */ public ServiceNotAuthorizedException() { - super("Service not permitted"); + super(HttpServerText.get().serviceNotPermitted); } } diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/ServiceNotEnabledException.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/ServiceNotEnabledException.java index dedc0d4825..adc132df3d 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/ServiceNotEnabledException.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/ServiceNotEnabledException.java @@ -43,12 +43,14 @@ package org.eclipse.jgit.http.server.resolver; +import org.eclipse.jgit.http.server.HttpServerText; + /** Indicates the request service is not enabled on a repository. */ public class ServiceNotEnabledException extends Exception { private static final long serialVersionUID = 1L; /** Indicates the request service is not available. */ public ServiceNotEnabledException() { - super("Service not enabled"); + super(HttpServerText.get().serviceNotEnabled); } } diff --git a/org.eclipse.jgit.iplog/.classpath b/org.eclipse.jgit.iplog/.classpath index 304e86186a..d7edf529a2 100644 --- a/org.eclipse.jgit.iplog/.classpath +++ b/org.eclipse.jgit.iplog/.classpath @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="resources"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="output" path="bin"/> diff --git a/org.eclipse.jgit.iplog/META-INF/MANIFEST.MF b/org.eclipse.jgit.iplog/META-INF/MANIFEST.MF index 1a0de54a8a..a871ba9811 100644 --- a/org.eclipse.jgit.iplog/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.iplog/META-INF/MANIFEST.MF @@ -11,6 +11,7 @@ Import-Package: org.eclipse.jgit.diff;version="[0.8.0,0.9.0)", org.eclipse.jgit.dircache;version="[0.8.0,0.9.0)", org.eclipse.jgit.errors;version="[0.8.0,0.9.0)", org.eclipse.jgit.lib;version="[0.8.0,0.9.0)", + org.eclipse.jgit.nls;version="[0.8.0,0.9.0)", org.eclipse.jgit.revplot;version="[0.8.0,0.9.0)", org.eclipse.jgit.revwalk;version="[0.8.0,0.9.0)", org.eclipse.jgit.revwalk.filter;version="[0.8.0,0.9.0)", diff --git a/org.eclipse.jgit.iplog/pom.xml b/org.eclipse.jgit.iplog/pom.xml index b03e5ed754..64d1dc1516 100644 --- a/org.eclipse.jgit.iplog/pom.xml +++ b/org.eclipse.jgit.iplog/pom.xml @@ -83,6 +83,9 @@ <include>plugin.properties</include> </includes> </resource> + <resource> + <directory>resources/</directory> + </resource> </resources> <plugins> diff --git a/org.eclipse.jgit.iplog/resources/org/eclipse/jgit/iplog/IpLogText.properties b/org.eclipse.jgit.iplog/resources/org/eclipse/jgit/iplog/IpLogText.properties new file mode 100644 index 0000000000..758620839b --- /dev/null +++ b/org.eclipse.jgit.iplog/resources/org/eclipse/jgit/iplog/IpLogText.properties @@ -0,0 +1,17 @@ +CQString=CQ {0} +CSVParsingError=CSV parsing error: {0} +cannotLock=Cannot lock {0} +cannotSerializeXML=Cannot serialize XML +cannotWrite=Cannot write {0} +committerString=Committer {0} {1} +configurationFileInCommitHasNoProjectsDeclared=Configuration file {0} in commit {1} has no projects declared. +configurationFileInCommitIsInvalid=Configuration file {0} in commit {1} is invalid +contributorString=Contributor {0} +incorrectlyScanned=Incorrectly scanned {0} +invalidDate=Invalid date: {0} +invalidURIFormat=Invalid URI format: {0} +loginFailed=Login as {0} to {1} failed: {2} +pageTitleWas=page title was "{0}" +projectString=Project {0} ({1}) +queryFailed=Query {0} failed: {1} +responseNotHTMLAsExpected=Response not HTML as expected diff --git a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/CQ.java b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/CQ.java index c2a4fe1195..13781f48ad 100644 --- a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/CQ.java +++ b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/CQ.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.iplog; +import java.text.MessageFormat; import java.util.Comparator; /** @@ -156,6 +157,6 @@ class CQ { @Override public String toString() { - return "CQ " + getID(); + return MessageFormat.format(IpLogText.get().CQString, getID()); } } diff --git a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/CSV.java b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/CSV.java index 8c57edb00f..3f80c7d1fc 100644 --- a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/CSV.java +++ b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/CSV.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.iplog; import java.io.BufferedReader; import java.io.IOException; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -108,7 +109,7 @@ class CSV { } } if (p < line.length() && line.charAt(p) != ',') - throw new IOException("CSV parsing error: " + line); + throw new IOException(MessageFormat.format(IpLogText.get().CSVParsingError, line)); row.add(b.toString()); p++; // skip the trailing comma (if present) diff --git a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/Committer.java b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/Committer.java index fe84a08ecf..905f99e0f3 100644 --- a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/Committer.java +++ b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/Committer.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.iplog; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -172,7 +173,7 @@ class Committer { @Override public String toString() { - return "Committer " + getFirstName() + " " + getLastName(); + return MessageFormat.format(IpLogText.get().committerString, getFirstName(), getLastName()); } /** Date period during which the committer was active. */ diff --git a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/Contributor.java b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/Contributor.java index cf1f7c1013..9d3771bfb8 100644 --- a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/Contributor.java +++ b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/Contributor.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.iplog; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -93,6 +94,6 @@ class Contributor { @Override public String toString() { - return "Contributor " + getName(); + return MessageFormat.format(IpLogText.get().contributorString, getName()); } } diff --git a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IPZillaQuery.java b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IPZillaQuery.java index 7d9f9a64c8..b8db84a89c 100644 --- a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IPZillaQuery.java +++ b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IPZillaQuery.java @@ -59,6 +59,7 @@ import java.net.ProxySelector; import java.net.URISyntaxException; import java.net.URL; import java.net.URLEncoder; +import java.text.MessageFormat; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -135,8 +136,8 @@ class IPZillaQuery { HttpURLConnection conn = open(csv); if (HttpSupport.response(conn) != HttpURLConnection.HTTP_OK) { - throw new IOException("Query " + csv + " failed: " - + conn.getResponseCode() + " " + conn.getResponseMessage()); + throw new IOException(MessageFormat.format(IpLogText.get().queryFailed + , csv, conn.getResponseCode() + " " + conn.getResponseMessage())); } BufferedReader br = reader(conn); @@ -185,23 +186,23 @@ class IPZillaQuery { out.close(); if (HttpSupport.response(c) != HttpURLConnection.HTTP_OK) { - throw new IOException("Login as " + username + " to " + login - + " failed: " + c.getResponseCode() + " " - + c.getResponseMessage()); + throw new IOException(MessageFormat.format(IpLogText.get().loginFailed + , username, login, c.getResponseCode() + " " + c.getResponseMessage())); } String content = readFully(c); Matcher matcher = Pattern.compile("<title>(.*)</title>", Pattern.CASE_INSENSITIVE).matcher(content); if (!matcher.find()) { - throw new IOException("Login as " + username + " to " + login - + " failed: Response not HTML as expected"); + throw new IOException(MessageFormat.format(IpLogText.get().loginFailed + , username, login, IpLogText.get().responseNotHTMLAsExpected)); } String title = matcher.group(1); if (!"IPZilla Main Page".equals(title)) { - throw new IOException("Login as " + username + " to " + login - + " failed; page title was \"" + title + "\""); + throw new IOException(MessageFormat.format(IpLogText.get().loginFailed + , username, login + , MessageFormat.format(IpLogText.get().pageTitleWas, title))); } } @@ -246,7 +247,7 @@ class IPZillaQuery { try { CookieHandler.getDefault().put(url.toURI(), cols); } catch (URISyntaxException e) { - IOException err = new IOException("Invalid URI format:" + url); + IOException err = new IOException(MessageFormat.format(IpLogText.get().invalidURIFormat, url)); err.initCause(e); throw err; } diff --git a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogGenerator.java b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogGenerator.java index d8956afe12..a9fdb81581 100644 --- a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogGenerator.java +++ b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogGenerator.java @@ -48,6 +48,7 @@ import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.OutputStream; +import java.text.MessageFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -209,15 +210,13 @@ public class IpLogGenerator { try { meta.loadFrom(new BlobBasedConfig(null, db, log.getObjectId(0))); } catch (ConfigInvalidException e) { - throw new ConfigInvalidException("Configuration file " - + log.getPathString() + " in commit " + commit.name() - + " is invalid", e); + throw new ConfigInvalidException(MessageFormat.format(IpLogText.get().configurationFileInCommitIsInvalid + , log.getPathString(), commit.name()), e); } if (meta.getProjects().isEmpty()) { - throw new ConfigInvalidException("Configuration file " - + log.getPathString() + " in commit " + commit.name() - + " has no projects declared."); + throw new ConfigInvalidException(MessageFormat.format(IpLogText.get().configurationFileInCommitHasNoProjectsDeclared + , log.getPathString(), commit.name())); } for (Project p : meta.getProjects()) { @@ -274,7 +273,7 @@ public class IpLogGenerator { try { return dt.parse(value); } catch (ParseException e) { - IOException err = new IOException("Invalid date: " + value); + IOException err = new IOException(MessageFormat.format(IpLogText.get().invalidDate, value)); err.initCause(e); throw err; } @@ -411,7 +410,7 @@ public class IpLogGenerator { } if (addedLines < 0) - throw new IOException("Incorrectly scanned " + commit.name()); + throw new IOException(MessageFormat.format(IpLogText.get().incorrectlyScanned, commit.name())); if (1 == addedLines) item.setSize("+1 line"); else @@ -447,17 +446,17 @@ public class IpLogGenerator { s.setOutputProperty(INDENT, "2"); s.transform(new DOMSource(toXML()), new StreamResult(out)); } catch (ParserConfigurationException e) { - IOException err = new IOException("Cannot serialize XML"); + IOException err = new IOException(IpLogText.get().cannotSerializeXML); err.initCause(e); throw err; } catch (TransformerConfigurationException e) { - IOException err = new IOException("Cannot serialize XML"); + IOException err = new IOException(IpLogText.get().cannotSerializeXML); err.initCause(e); throw err; } catch (TransformerException e) { - IOException err = new IOException("Cannot serialize XML"); + IOException err = new IOException(IpLogText.get().cannotSerializeXML); err.initCause(e); throw err; } diff --git a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogMeta.java b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogMeta.java index d0a5279abb..8d73b02fd5 100644 --- a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogMeta.java +++ b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogMeta.java @@ -46,6 +46,7 @@ package org.eclipse.jgit.iplog; import java.io.File; import java.io.IOException; import java.net.URL; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -155,7 +156,7 @@ public class IpLogMeta { LockFile lf = new LockFile(file); if (!lf.lock()) - throw new IOException("Cannot lock " + file); + throw new IOException(MessageFormat.format(IpLogText.get().cannotLock, file)); try { FileBasedConfig cfg = new FileBasedConfig(file); cfg.load(); @@ -181,7 +182,7 @@ public class IpLogMeta { lf.write(Constants.encode(cfg.toText())); if (!lf.commit()) - throw new IOException("Cannot write " + file); + throw new IOException(MessageFormat.format(IpLogText.get().cannotWrite, file)); } finally { lf.unlock(); } diff --git a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogText.java b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogText.java new file mode 100644 index 0000000000..2067c5f634 --- /dev/null +++ b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogText.java @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2010, Sasa Zivkov <sasa.zivkov@sap.com> + * and other copyright owners as documented in the project's IP log. + * + * This program and the accompanying materials are made available + * under the terms of the Eclipse Distribution License v1.0 which + * accompanies this distribution, is reproduced below, and is + * available at http://www.eclipse.org/org/documents/edl-v10.php + * + * 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 Eclipse Foundation, Inc. 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.eclipse.jgit.iplog; + +import org.eclipse.jgit.nls.NLS; +import org.eclipse.jgit.nls.TranslationBundle; + +/** + * Translation bundle for JGit IP Log + */ +public class IpLogText extends TranslationBundle { + + /** + * @return an instance of this translation bundle + */ + public static IpLogText get() { + return NLS.getBundleFor(IpLogText.class); + } + + /***/ public String CQString; + /***/ public String CSVParsingError; + /***/ public String cannotLock; + /***/ public String cannotSerializeXML; + /***/ public String cannotWrite; + /***/ public String committerString; + /***/ public String configurationFileInCommitHasNoProjectsDeclared; + /***/ public String configurationFileInCommitIsInvalid; + /***/ public String contributorString; + /***/ public String incorrectlyScanned; + /***/ public String invalidDate; + /***/ public String invalidURIFormat; + /***/ public String loginFailed; + /***/ public String pageTitleWas; + /***/ public String projectString; + /***/ public String queryFailed; + /***/ public String responseNotHTMLAsExpected; +} diff --git a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/Project.java b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/Project.java index 15b79cede5..efa1fed793 100644 --- a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/Project.java +++ b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/Project.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.iplog; +import java.text.MessageFormat; import java.util.Collections; import java.util.Comparator; import java.util.Set; @@ -128,6 +129,6 @@ class Project { @Override public String toString() { - return "Project " + getID() + " (" + getName() + ")"; + return MessageFormat.format(IpLogText.get().projectString, getID(), getName()); } } diff --git a/org.eclipse.jgit.pgm/.classpath b/org.eclipse.jgit.pgm/.classpath index c2f8fa7c8d..2f7278b3c0 100644 --- a/org.eclipse.jgit.pgm/.classpath +++ b/org.eclipse.jgit.pgm/.classpath @@ -1,7 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> - <classpathentry excluding="*" including="META-INF/" kind="src" path=""/> + <classpathentry excluding="*|resources/|resources/" including="META-INF/" kind="src" path=""/> + <classpathentry kind="src" path="resources"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="output" path="bin"/> diff --git a/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF b/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF index cedc4e8fd8..ad9964d55d 100644 --- a/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF @@ -11,7 +11,9 @@ Import-Package: org.eclipse.jgit.api;version="[0.8.0,0.9.0)", org.eclipse.jgit.diff;version="[0.8.0,0.9.0)", org.eclipse.jgit.dircache;version="[0.8.0,0.9.0)", org.eclipse.jgit.errors;version="[0.8.0,0.9.0)", + org.eclipse.jgit.iplog;version="[0.8.0,0.9.0)", org.eclipse.jgit.lib;version="[0.8.0,0.9.0)", + org.eclipse.jgit.nls;version="[0.8.0,0.9.0)", org.eclipse.jgit.revplot;version="[0.8.0,0.9.0)", org.eclipse.jgit.revwalk;version="[0.8.0,0.9.0)", org.eclipse.jgit.revwalk.filter;version="[0.8.0,0.9.0)", @@ -19,10 +21,17 @@ Import-Package: org.eclipse.jgit.api;version="[0.8.0,0.9.0)", org.eclipse.jgit.treewalk;version="[0.8.0,0.9.0)", org.eclipse.jgit.treewalk.filter;version="[0.8.0,0.9.0)", org.eclipse.jgit.util;version="[0.8.0,0.9.0)", - org.eclipse.jgit.iplog;version="[0.8.0,0.9.0)", org.kohsuke.args4j;version="[2.0.12,2.1.0)", org.kohsuke.args4j.spi;version="[2.0.12,2.1.0)" Bundle-ActivationPolicy: lazy -Export-Package: org.eclipse.jgit.pgm +Export-Package: org.eclipse.jgit.pgm;version="0.8.0"; + uses:="org.eclipse.jgit.lib, + org.eclipse.jgit.nls, + org.eclipse.jgit.treewalk, + org.eclipse.jgit.revwalk, + javax.swing, + org.eclipse.jgit.pgm.opt, + org.eclipse.jgit.awtui, + org.eclipse.jgit.transport" Main-Class: org.eclipse.jgit.pgm.Main Implementation-Title: JGit Command Line Interface diff --git a/org.eclipse.jgit.pgm/pom.xml b/org.eclipse.jgit.pgm/pom.xml index a42e4e7223..1b085e4633 100644 --- a/org.eclipse.jgit.pgm/pom.xml +++ b/org.eclipse.jgit.pgm/pom.xml @@ -111,6 +111,9 @@ <include>META-INF/services/org.eclipse.jgit.pgm.TextBuiltin</include> </includes> </resource> + <resource> + <directory>resources/</directory> + </resource> </resources> <plugins> diff --git a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/CLIText.properties b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/CLIText.properties new file mode 100644 index 0000000000..edf31e97be --- /dev/null +++ b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/CLIText.properties @@ -0,0 +1,174 @@ +# default meta variable defined in the org.kohsuke.args4j.spi.StringOptionHandler +VAL=VAL +# default meta variable defined in the org.kohsuke.args4j.spi.StopOptionHandler +ARGUMENTS=ARGUMENTS +# default meta variable defined in the org.kohsuke.args4j.spi.OneArgumentOptionHandler +N=N + +IPZillaPasswordPrompt=IPZilla Password +authorInfo=Author: {0} <{1}> +averageMSPerRead=average {0} ms/read +branchAlreadyExists=branch {0} already exists +branchCreatedFrom =branch: Created from {0} +branchIsNotAnAncestorOfYourCurrentHEAD=The branch '{0}' is not an ancestor of your current HEAD.\nIf you are sure you want to delete it, run 'jgit branch -D {0}'. +branchNotFound=branch '{0}' not found. +cacheTreePathInfo="{0}": {1} entries, {2} children +cannotBeRenamed={0} cannot be renamed +cannotChekoutNoHeadsAdvertisedByRemote=cannot checkout; no HEAD advertised by remote +cannotCreateCommand=Cannot create command {0} +cannotCreateOutputStream=cannot create output stream +cannotDeatchHEAD=Cannot deatch HEAD +cannotDeleteTheBranchWhichYouAreCurrentlyOn=Cannot delete the branch '{0}' which you are currently on. +cannotGuessLocalNameFrom=cannot guess local name from {0} +cannotLock=Cannot lock {0} +cannotReadBecause=cannot read {0}: {1} +cannotReadPackageInformation=Cannot read package information. +cannotRenameDetachedHEAD=Cannot rename detached HEAD +cannotResolve=Cannot resolve {0} +cannotSetupConsole=Cannot setup console +cannotUseObjectsWithGlog=Cannot use --objects with glog +cannotWrite=Cannot write {0} +cantFindGitDirectory=error: can't find git directory +cantWrite=Can't write {0} +commitLabel=commit +conflictingUsageOf_git_dir_andArguments=conflicting usage of --git-dir and arguments +couldNotCreateBranch=Could not create branch {0}: {1} +dateInfo=Date: {0} +deletedBranch=Deleted branch {0} +deletedRemoteBranch=Deleted remote branch {0} +doesNotExist={0} does not exist +everythingUpToDate=Everything up-to-date +expectedNumberOfbytes=Expected {0} bytes. +exporting=Exporting {0} +failedToCommitIndex=failed to commit index +failedToLockIndex=failed to lock index +fatalError=fatal: {0} +fatalErrorTagExists=fatal: tag '{0}' exists +fatalThisProgramWillDestroyTheRepository=fatal: This program will destroy the repository\nfatal:\nfatal:\nfatal: {0}\nfatal:\nfatal: To continue, add {1} to the command line\nfatal: +forcedUpdate=forced update +fromURI=From {0} +initializedEmptyGitRepositoryIn=Initialized empty Git repository in {0} +invalidHttpProxyOnlyHttpSupported=Invalid http_proxy: {0}: Only http supported. +jgitVersion=jgit version {0} +listeningOn=Listening on {0} +metaVar_DAG=DAG +metaVar_KEY=KEY +metaVar_arg=ARG +metaVar_base=base +metaVar_bucket=BUCKET +metaVar_command=command +metaVar_commitOrTag=COMMIT|TAG +metaVar_commitish=commit-ish +metaVar_connProp=conn.prop +metaVar_directory=DIRECTORY +metaVar_file=FILE +metaVar_gitDir=GIT_DIR +metaVar_hostName=HOSTNAME +metaVar_message=message +metaVar_name=name +metaVar_object=object +metaVar_op=OP +metaVar_pass=PASS +metaVar_path=path +metaVar_paths=path ... +metaVar_port=PORT +metaVar_refs=REFS +metaVar_refspec=refspec +metaVar_remoteName=name +metaVar_seconds=SECONDS +metaVar_service=SERVICE +metaVar_treeish=tree-ish +metaVar_uriish=uri-ish +metaVar_url=URL +metaVar_user=USER +metaVar_version=VERSION +mostCommonlyUsedCommandsAre=The most commonly used commands are: +needApprovalToDestroyCurrentRepository=Need approval to destroy current repository +noGitRepositoryConfigured=No Git repository configured. +noSuchFile=no such file: {0} +noTREESectionInIndex=no 'TREE' section in index +nonFastForward=non-fast forward +notABranch={0} is not a branch +notACommit={0} is not a commit +notAGitRepository='{0}' not a git repository +notAJgitCommand={0} is not a jgit command +notARevision=Not a revision: {0} +notATagVersionIsRequired={0} is not a tag, --version is required +notATree={0} is not a tree +notAValidRefName={0} is not a valid ref name +notAnIndexFile={0} is not an index file +notAnObject={0} is not an object +notFound=!! NOT FOUND !! +onlyOneMetaVarExpectedIn=Only one {0} expected in {1}. +pushTo=To {0} +remoteMessage=remote: {0} +remoteRefObjectChangedIsNotExpectedOne=remote ref object changed - is not expected one {0} +remoteSideDoesNotSupportDeletingRefs=remote side does not support deleting refs +repaint=Repaint +serviceNotSupported=Service '{0}' not supported +skippingObject=skipping {0} {1} +timeInMilliSeconds={0} ms +tooManyRefsGiven=Too many refs given +unsupportedOperation=Unsupported operation: {0} +usage_CommandLineClientForamazonsS3Service=Command line client for Amazon's S3 service +usage_CreateABareRepository=Create a bare repository +usage_CreateATag=Create a tag +usage_CreateAnEmptyGitRepository=Create an empty git repository +usage_DisplayTheVersionOfJgit=Display the version of jgit +usage_IPZillaPassword=IPZilla Password +usage_IPZillaURL=IPZilla URL +usage_IPZillausername=IPZilla Username +usage_RepositoryToReadFrom=Repository to read from +usage_RepositoryToReceiveInto=Repository to receive into +usage_ServerSideBackendForJgitFetch=Server side backend for 'jgit fetch' +usage_ServerSideBackendForJgitPush=Server side backend for 'jgit push' +usage_ShowDiffs=Show diffs +usage_StopTrackingAFile=Stop tracking a file +usage_UpdateRemoteRepositoryFromLocalRefs=Update remote repository from local refs +usage_abortConnectionIfNoActivity=abort connection if no activity +usage_actOnRemoteTrackingBranches=act on remote-tracking branches +usage_alterTheDetailShown=alter the detail shown +usage_approveDestructionOfRepository=approve destruction of repository +usage_beMoreVerbose=be more verbose +usage_beVerbose=be verbose +usage_cloneRepositoryIntoNewDir=Clone a repository into a new directory +usage_configureTheServiceInDaemonServicename=configure the service in daemon.servicename +usage_deleteBranchEvenIfNotMerged=delete branch (even if not merged) +usage_deleteFullyMergedBranch=delete fully merged branch +usage_directoriesToExport=directories to export +usage_disableTheServiceInAllRepositories=disable the service in all repositories +usage_displayAListOfAllRegisteredJgitCommands=Display a list of all registered jgit commands +usage_displayAllPossibleMergeBases=display all possible merge bases +usage_displayThejavaStackTraceOnExceptions=display the Java stack trace on exceptions +usage_displayThisHelpText=display this help text +usage_enableTheServiceInAllRepositories=enable the service in all repositories +usage_exportRepositoriesOverGit=Export repositories over git:// +usage_exportWithoutGitDaemonExportOk=export without git-daemon-export-ok +usage_fetchThinPack=fetch thin pack +usage_fixAThinPackToBeComplete=fix a thin pack to be complete +usage_forEachRefOutput=for-each-ref output +usage_forceCreateBranchEvenExists=force create branch even exists +usage_forceReplacingAnExistingTag=force replacing an existing tag +usage_hostnameOrIpToListenOn=hostname (or ip) to listen on +usage_indexFileFormatToCreate=index file format to create +usage_inputOutputFile=Input/output file +usage_listBothRemoteTrackingAndLocalBranches=list both remote-tracking and local branches +usage_listCreateOrDeleteBranches=List, create, or delete branches +usage_logAllPretty=format:%H %ct %P' output=log --all '--pretty=format:%H %ct %P' output +usage_moveRenameABranch=move/rename a branch +usage_outputFile=Output file +usage_path=path +usage_performFsckStyleChecksOnReceive=perform fsck style checks on receive +usage_portNumberToListenOn=port number to listen on +usage_produceAnEclipseIPLog=Produce an Eclipse IP log +usage_pruneStaleTrackingRefs=prune stale tracking refs +usage_recurseIntoSubtrees=recurse into subtrees +usage_setTheGitRepositoryToOperateOn=set the git repository to operate on +usage_showRefNamesMatchingCommits=Show ref names matching commits +usage_symbolicVersionForTheProject=Symbolic version for the project +usage_synchronizeIPZillaData=Synchronize IPZilla data +usage_tagMessage=tag message +usage_updateRemoteRefsFromAnotherRepository=Update remote refs from another repository +usage_useNameInsteadOfOriginToTrackUpstream=use <name> instead of 'origin' to track upstream +usage_viewCommitHistory=View commit history +warningNoCommitGivenOnCommandLine=warning: No commit given on command line, assuming {0} diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java index 1e03567500..b572e0092b 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java @@ -3,6 +3,7 @@ * Copyright (C) 2008-2010, Google Inc. * Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com> * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> + * Copyright (C) 2010, Sasa Zivkov <sasa.zivkov@sap.com> * and other copyright owners as documented in the project's IP log. * * This program and the accompanying materials are made available @@ -46,6 +47,8 @@ package org.eclipse.jgit.pgm; +import java.io.PrintWriter; + import org.kohsuke.args4j.Option; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; @@ -55,7 +58,7 @@ import org.eclipse.jgit.transport.TrackingRefUpdate; import org.eclipse.jgit.transport.Transport; abstract class AbstractFetchCommand extends TextBuiltin { - @Option(name = "--verbose", aliases = { "-v" }, usage = "be more verbose") + @Option(name = "--verbose", aliases = { "-v" }, usage = "usage_beMoreVerbose") private boolean verbose; protected void showFetchResult(final Transport tn, final FetchResult r) { @@ -70,8 +73,7 @@ abstract class AbstractFetchCommand extends TextBuiltin { final String dst = abbreviateRef(u.getLocalName(), true); if (!shownURI) { - out.print("From "); - out.print(tn.getURI()); + out.format(CLIText.get().fromURI, tn.getURI()); out.println(); shownURI = true; } @@ -84,6 +86,7 @@ abstract class AbstractFetchCommand extends TextBuiltin { } static void showRemoteMessages(String pkt) { + PrintWriter writer = new PrintWriter(System.err); while (0 < pkt.length()) { final int lf = pkt.indexOf('\n'); final int cr = pkt.indexOf('\r'); @@ -95,18 +98,22 @@ abstract class AbstractFetchCommand extends TextBuiltin { else if (0 <= cr) s = cr; else { - System.err.println("remote: " + pkt); + writer.format(CLIText.get().remoteMessage, pkt); + writer.println(); break; } - if (pkt.charAt(s) == '\r') - System.err.print("remote: " + pkt.substring(0, s) + "\r"); - else - System.err.println("remote: " + pkt.substring(0, s)); + if (pkt.charAt(s) == '\r') { + writer.format(CLIText.get().remoteMessage, pkt.substring(0, s)); + writer.print('\r'); + } else { + writer.format(CLIText.get().remoteMessage, pkt.substring(0, s)); + writer.println(); + } pkt = pkt.substring(s + 1); } - System.err.flush(); + writer.flush(); } private String longTypeOf(final TrackingRefUpdate u) { diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java index 179a32bdbf..cad4b63314 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java @@ -52,23 +52,24 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URLConnection; +import java.text.MessageFormat; import java.util.Properties; import org.eclipse.jgit.transport.AmazonS3; import org.kohsuke.args4j.Argument; -@Command(name = "amazon-s3-client", common = false, usage = "Command line client for Amazon's S3 service") +@Command(name = "amazon-s3-client", common = false, usage = "usage_CommandLineClientForamazonsS3Service") class AmazonS3Client extends TextBuiltin { - @Argument(index = 0, metaVar = "conn.prop", required = true) + @Argument(index = 0, metaVar = "metaVar_connProp", required = true) private File propertyFile; - @Argument(index = 1, metaVar = "OP", required = true) + @Argument(index = 1, metaVar = "metaVar_op", required = true) private String op; - @Argument(index = 2, metaVar = "BUCKET", required = true) + @Argument(index = 2, metaVar = "metaVar_bucket", required = true) private String bucket; - @Argument(index = 3, metaVar = "KEY", required = true) + @Argument(index = 3, metaVar = "metaVar_KEY", required = true) private String key; @Override @@ -89,7 +90,7 @@ class AmazonS3Client extends TextBuiltin { while (len > 0) { final int n = in.read(tmp); if (n < 0) - throw new EOFException("Expected " + len + " bytes."); + throw new EOFException(MessageFormat.format(CLIText.get().expectedNumberOfbytes, len)); System.out.write(tmp, 0, n); len -= n; } @@ -113,7 +114,7 @@ class AmazonS3Client extends TextBuiltin { os.close(); } else { - throw die("Unsupported operation: " + op); + throw die(MessageFormat.format(CLIText.get().unsupportedOperation, op)); } } @@ -128,9 +129,9 @@ class AmazonS3Client extends TextBuiltin { in.close(); } } catch (FileNotFoundException e) { - throw die("no such file: " + propertyFile, e); + throw die(MessageFormat.format(CLIText.get().noSuchFile, propertyFile), e); } catch (IOException e) { - throw die("cannot read " + propertyFile, e); + throw die(MessageFormat.format(CLIText.get().cannotReadBecause, propertyFile, e.getMessage()), e); } } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java index 7a1dd16043..0274219b78 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java @@ -44,6 +44,7 @@ package org.eclipse.jgit.pgm; import java.io.IOException; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -64,28 +65,28 @@ import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.ExampleMode; import org.kohsuke.args4j.Option; -@Command(common = true, usage = "List, create, or delete branches") +@Command(common = true, usage = "usage_listCreateOrDeleteBranches") class Branch extends TextBuiltin { - @Option(name = "--remote", aliases = { "-r" }, usage = "act on remote-tracking branches") + @Option(name = "--remote", aliases = { "-r" }, usage = "usage_actOnRemoteTrackingBranches") private boolean remote = false; - @Option(name = "--all", aliases = { "-a" }, usage = "list both remote-tracking and local branches") + @Option(name = "--all", aliases = { "-a" }, usage = "usage_listBothRemoteTrackingAndLocalBranches") private boolean all = false; - @Option(name = "--delete", aliases = { "-d" }, usage = "delete fully merged branch") + @Option(name = "--delete", aliases = { "-d" }, usage = "usage_deleteFullyMergedBranch") private boolean delete = false; - @Option(name = "--delete-force", aliases = { "-D" }, usage = "delete branch (even if not merged)") + @Option(name = "--delete-force", aliases = { "-D" }, usage = "usage_deleteBranchEvenIfNotMerged") private boolean deleteForce = false; - @Option(name = "--create-force", aliases = { "-f" }, usage = "force create branch even exists") + @Option(name = "--create-force", aliases = { "-f" }, usage = "usage_forceCreateBranchEvenExists") private boolean createForce = false; - @Option(name = "-m", usage = "move/rename a branch") + @Option(name = "-m", usage = "usage_moveRenameABranch") private boolean rename = false; - @Option(name = "--verbose", aliases = { "-v" }, usage = "be verbose") + @Option(name = "--verbose", aliases = { "-v" }, usage = "usage_beVerbose") private boolean verbose = false; @Argument @@ -104,7 +105,7 @@ class Branch extends TextBuiltin { delete(deleteForce); else { if (branches.size() > 2) - throw die("Too many refs given\n" + new CmdLineParser(this).printExample(ExampleMode.ALL)); + throw die(CLIText.get().tooManyRefsGiven + new CmdLineParser(this).printExample(ExampleMode.ALL)); if (rename) { String src, dst; @@ -113,15 +114,15 @@ class Branch extends TextBuiltin { if (head != null && head.isSymbolic()) src = head.getLeaf().getName(); else - throw die("Cannot rename detached HEAD"); + throw die(CLIText.get().cannotRenameDetachedHEAD); dst = branches.get(0); } else { src = branches.get(0); final Ref old = db.getRef(src); if (old == null) - throw die(String.format("%s does not exist", src)); + throw die(MessageFormat.format(CLIText.get().doesNotExist, src)); if (!old.getName().startsWith(Constants.R_HEADS)) - throw die(String.format("%s is not a branch", src)); + throw die(MessageFormat.format(CLIText.get().notABranch, src)); src = old.getName(); dst = branches.get(1); } @@ -129,11 +130,11 @@ class Branch extends TextBuiltin { if (!dst.startsWith(Constants.R_HEADS)) dst = Constants.R_HEADS + dst; if (!Repository.isValidRefName(dst)) - throw die(String.format("%s is not a valid ref name", dst)); + throw die(MessageFormat.format(CLIText.get().notAValidRefName, dst)); RefRename r = db.renameRef(src, dst); if (r.rename() != Result.RENAMED) - throw die(String.format("%s cannot be renamed", src)); + throw die(MessageFormat.format(CLIText.get().cannotBeRenamed, src)); } else if (branches.size() > 0) { String newHead = branches.get(0); @@ -153,16 +154,16 @@ class Branch extends TextBuiltin { if (!newRefName.startsWith(Constants.R_HEADS)) newRefName = Constants.R_HEADS + newRefName; if (!Repository.isValidRefName(newRefName)) - throw die(String.format("%s is not a valid ref name", newRefName)); + throw die(MessageFormat.format(CLIText.get().notAValidRefName, newRefName)); if (!createForce && db.resolve(newRefName) != null) - throw die(String.format("branch %s already exists", newHead)); + throw die(MessageFormat.format(CLIText.get().branchAlreadyExists, newHead)); RefUpdate updateRef = db.updateRef(newRefName); updateRef.setNewObjectId(startAt); updateRef.setForceUpdate(createForce); - updateRef.setRefLogMessage("branch: Created from " + startBranch, false); + updateRef.setRefLogMessage(MessageFormat.format(CLIText.get().branchCreatedFrom, startBranch), false); Result update = updateRef.update(); if (update == Result.REJECTED) - throw die(String.format("Could not create branch %s: %s", newHead, update.toString())); + throw die(MessageFormat.format(CLIText.get().couldNotCreateBranch, newHead, update.toString())); } else { if (verbose) rw = new RevWalk(db); @@ -211,7 +212,7 @@ class Branch extends TextBuiltin { out.print(ref); if (verbose) { final int spaces = maxNameLength - ref.length() + 1; - out.print(String.format("%" + spaces + "s", "")); + out.format("%" + spaces + "s", ""); final ObjectId objectId = refObj.getObjectId(); out.print(objectId.abbreviate(db).name()); out.print(' '); @@ -225,8 +226,7 @@ class Branch extends TextBuiltin { ObjectId head = db.resolve(Constants.HEAD); for (String branch : branches) { if (current.equals(branch)) { - String err = "Cannot delete the branch '%s' which you are currently on."; - throw die(String.format(err, branch)); + throw die(MessageFormat.format(CLIText.get().cannotDeleteTheBranchWhichYouAreCurrentlyOn, branch)); } RefUpdate update = db.updateRef((remote ? Constants.R_REMOTES : Constants.R_HEADS) @@ -235,15 +235,13 @@ class Branch extends TextBuiltin { update.setForceUpdate(force || remote); Result result = update.delete(); if (result == Result.REJECTED) { - String err = "The branch '%s' is not an ancestor of your current HEAD.\n" - + "If you are sure you want to delete it, run 'jgit branch -D %1$s'."; - throw die(String.format(err, branch)); + throw die(MessageFormat.format(CLIText.get().branchIsNotAnAncestorOfYourCurrentHEAD, branch)); } else if (result == Result.NEW) - throw die(String.format("branch '%s' not found.", branch)); + throw die(MessageFormat.format(CLIText.get().branchNotFound, branch)); if (remote) - out.println(String.format("Deleted remote branch %s", branch)); + out.println(MessageFormat.format(CLIText.get().deletedRemoteBranch, branch)); else if (verbose) - out.println(String.format("Deleted branch %s", branch)); + out.println(MessageFormat.format(CLIText.get().deletedBranch, branch)); } } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java new file mode 100644 index 0000000000..8c811d4ef7 --- /dev/null +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2010, Sasa Zivkov <sasa.zivkov@sap.com> + * and other copyright owners as documented in the project's IP log. + * + * This program and the accompanying materials are made available + * under the terms of the Eclipse Distribution License v1.0 which + * accompanies this distribution, is reproduced below, and is + * available at http://www.eclipse.org/org/documents/edl-v10.php + * + * 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 Eclipse Foundation, Inc. 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.eclipse.jgit.pgm; + +import org.eclipse.jgit.nls.NLS; +import org.eclipse.jgit.nls.TranslationBundle; + +/** + * Translation bundle for JGit command line interface + */ +public class CLIText extends TranslationBundle { + + /** + * @return an instance of this translation bundle + */ + public static CLIText get() { + return NLS.getBundleFor(CLIText.class); + } + + /***/ public String IPZillaPasswordPrompt; + /***/ public String authorInfo; + /***/ public String averageMSPerRead; + /***/ public String branchAlreadyExists; + /***/ public String branchCreatedFrom; + /***/ public String branchIsNotAnAncestorOfYourCurrentHEAD; + /***/ public String branchNotFound; + /***/ public String cacheTreePathInfo; + /***/ public String cannotBeRenamed; + /***/ public String cannotChekoutNoHeadsAdvertisedByRemote; + /***/ public String cannotCreateCommand; + /***/ public String cannotCreateOutputStream; + /***/ public String cannotDeatchHEAD; + /***/ public String cannotDeleteTheBranchWhichYouAreCurrentlyOn; + /***/ public String cannotGuessLocalNameFrom; + /***/ public String cannotLock; + /***/ public String cannotReadBecause; + /***/ public String cannotReadPackageInformation; + /***/ public String cannotRenameDetachedHEAD; + /***/ public String cannotResolve; + /***/ public String cannotSetupConsole; + /***/ public String cannotUseObjectsWithGlog; + /***/ public String cannotWrite; + /***/ public String cantFindGitDirectory; + /***/ public String cantWrite; + /***/ public String commitLabel; + /***/ public String conflictingUsageOf_git_dir_andArguments; + /***/ public String couldNotCreateBranch; + /***/ public String dateInfo; + /***/ public String deletedBranch; + /***/ public String deletedRemoteBranch; + /***/ public String doesNotExist; + /***/ public String everythingUpToDate; + /***/ public String expectedNumberOfbytes; + /***/ public String exporting; + /***/ public String failedToCommitIndex; + /***/ public String failedToLockIndex; + /***/ public String fatalError; + /***/ public String fatalErrorTagExists; + /***/ public String fatalThisProgramWillDestroyTheRepository; + /***/ public String forcedUpdate; + /***/ public String fromURI; + /***/ public String initializedEmptyGitRepositoryIn; + /***/ public String invalidHttpProxyOnlyHttpSupported; + /***/ public String jgitVersion; + /***/ public String listeningOn; + /***/ public String metaVar_command; + /***/ public String metaVar_commitish; + /***/ public String metaVar_object; + /***/ public String metaVar_paths; + /***/ public String metaVar_refspec; + /***/ public String metaVar_treeish; + /***/ public String mostCommonlyUsedCommandsAre; + /***/ public String needApprovalToDestroyCurrentRepository; + /***/ public String noGitRepositoryConfigured; + /***/ public String noSuchFile; + /***/ public String noTREESectionInIndex; + /***/ public String nonFastForward; + /***/ public String notABranch; + /***/ public String notACommit; + /***/ public String notAGitRepository; + /***/ public String notAJgitCommand; + /***/ public String notARevision; + /***/ public String notATagVersionIsRequired; + /***/ public String notATree; + /***/ public String notAValidRefName; + /***/ public String notAnIndexFile; + /***/ public String notAnObject; + /***/ public String notFound; + /***/ public String onlyOneMetaVarExpectedIn; + /***/ public String pushTo; + /***/ public String remoteMessage; + /***/ public String remoteRefObjectChangedIsNotExpectedOne; + /***/ public String remoteSideDoesNotSupportDeletingRefs; + /***/ public String repaint; + /***/ public String serviceNotSupported; + /***/ public String skippingObject; + /***/ public String timeInMilliSeconds; + /***/ public String tooManyRefsGiven; + /***/ public String unsupportedOperation; + /***/ public String warningNoCommitGivenOnCommandLine; +} diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java index a6c50ff19a..b0f51ec58a 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java @@ -46,6 +46,7 @@ package org.eclipse.jgit.pgm; import java.io.File; import java.io.IOException; import java.net.URISyntaxException; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -70,15 +71,15 @@ import org.eclipse.jgit.transport.RemoteConfig; import org.eclipse.jgit.transport.Transport; import org.eclipse.jgit.transport.URIish; -@Command(common = true, usage = "Clone a repository into a new directory") +@Command(common = true, usage = "usage_cloneRepositoryIntoNewDir") class Clone extends AbstractFetchCommand { - @Option(name = "--origin", aliases = { "-o" }, metaVar = "name", usage = "use <name> instead of 'origin' to track upstream") + @Option(name = "--origin", aliases = { "-o" }, metaVar = "metaVar_remoteName", usage = "usage_useNameInsteadOfOriginToTrackUpstream") private String remoteName = Constants.DEFAULT_REMOTE_NAME; - @Argument(index = 0, required = true, metaVar = "uri-ish") + @Argument(index = 0, required = true, metaVar = "metaVar_uriish") private String sourceUri; - @Argument(index = 1, metaVar = "directory") + @Argument(index = 1, metaVar = "metaVar_directory") private String localName; @Override @@ -89,14 +90,14 @@ class Clone extends AbstractFetchCommand { @Override protected void run() throws Exception { if (localName != null && gitdir != null) - throw die("conflicting usage of --git-dir and arguments"); + throw die(CLIText.get().conflictingUsageOf_git_dir_andArguments); final URIish uri = new URIish(sourceUri); if (localName == null) { try { localName = uri.getHumanishName(); } catch (IllegalArgumentException e) { - throw die("cannot guess local name from " + sourceUri); + throw die(MessageFormat.format(CLIText.get().cannotGuessLocalNameFrom, sourceUri)); } } if (gitdir == null) @@ -107,8 +108,8 @@ class Clone extends AbstractFetchCommand { db.getConfig().setBoolean("core", null, "bare", false); db.getConfig().save(); - out.println("Initialized empty Git repository in " - + gitdir.getAbsolutePath()); + out.format(CLIText.get().initializedEmptyGitRepositoryIn, gitdir.getAbsolutePath()); + out.println(); out.flush(); saveRemote(uri); @@ -163,7 +164,7 @@ class Clone extends AbstractFetchCommand { private void doCheckout(final Ref branch) throws IOException { if (branch == null) - throw die("cannot checkout; no HEAD advertised by remote"); + throw die(CLIText.get().cannotChekoutNoHeadsAdvertisedByRemote); if (!Constants.HEAD.equals(branch.getName())) { RefUpdate u = db.updateRef(Constants.HEAD); u.disableRefLog(); @@ -183,4 +184,4 @@ class Clone extends AbstractFetchCommand { co.checkout(); index.write(); } -} +}
\ No newline at end of file diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandRef.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandRef.java index eb68ada9b7..eace2e1f25 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandRef.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandRef.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.pgm; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; +import java.text.MessageFormat; /** * Description of a command (a {@link TextBuiltin} subclass. @@ -140,9 +141,9 @@ public class CommandRef { try { c = impl.getDeclaredConstructor(); } catch (SecurityException e) { - throw new RuntimeException("Cannot create command " + getName(), e); + throw new RuntimeException(MessageFormat.format(CLIText.get().cannotCreateCommand, getName(), e)); } catch (NoSuchMethodException e) { - throw new RuntimeException("Cannot create command " + getName(), e); + throw new RuntimeException(MessageFormat.format(CLIText.get().cannotCreateCommand, getName(), e)); } c.setAccessible(true); @@ -150,13 +151,13 @@ public class CommandRef { try { r = c.newInstance(); } catch (InstantiationException e) { - throw new RuntimeException("Cannot create command " + getName(), e); + throw new RuntimeException(MessageFormat.format(CLIText.get().cannotCreateCommand, getName(), e)); } catch (IllegalAccessException e) { - throw new RuntimeException("Cannot create command " + getName(), e); + throw new RuntimeException(MessageFormat.format(CLIText.get().cannotCreateCommand, getName(), e)); } catch (IllegalArgumentException e) { - throw new RuntimeException("Cannot create command " + getName(), e); + throw new RuntimeException(MessageFormat.format(CLIText.get().cannotCreateCommand, getName(), e)); } catch (InvocationTargetException e) { - throw new RuntimeException("Cannot create command " + getName(), e); + throw new RuntimeException(MessageFormat.format(CLIText.get().cannotCreateCommand, getName(), e)); } r.setCommandName(getName()); return r; diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java index 88219bdd9a..f015a9e7bd 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.pgm; import java.io.File; import java.net.InetSocketAddress; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; @@ -52,33 +53,33 @@ import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Option; import org.eclipse.jgit.transport.DaemonService; -@Command(common = true, usage = "Export repositories over git://") +@Command(common = true, usage = "usage_exportRepositoriesOverGit") class Daemon extends TextBuiltin { - @Option(name = "--port", metaVar = "PORT", usage = "port number to listen on") + @Option(name = "--port", metaVar = "metaVar_port", usage = "usage_portNumberToListenOn") int port = org.eclipse.jgit.transport.Daemon.DEFAULT_PORT; - @Option(name = "--listen", metaVar = "HOSTNAME", usage = "hostname (or ip) to listen on") + @Option(name = "--listen", metaVar = "metaVar_hostName", usage = "usage_hostnameOrIpToListenOn") String host; - @Option(name = "--timeout", metaVar = "SECONDS", usage = "abort connection if no activity") + @Option(name = "--timeout", metaVar = "metaVar_seconds", usage = "usage_abortConnectionIfNoActivity") int timeout = -1; - @Option(name = "--enable", metaVar = "SERVICE", usage = "enable the service in all repositories", multiValued = true) + @Option(name = "--enable", metaVar = "metaVar_service", usage = "usage_enableTheServiceInAllRepositories", multiValued = true) final List<String> enable = new ArrayList<String>(); - @Option(name = "--disable", metaVar = "SERVICE", usage = "disable the service in all repositories", multiValued = true) + @Option(name = "--disable", metaVar = "metaVar_service", usage = "usage_disableTheServiceInAllRepositories", multiValued = true) final List<String> disable = new ArrayList<String>(); - @Option(name = "--allow-override", metaVar = "SERVICE", usage = "configure the service in daemon.servicename", multiValued = true) + @Option(name = "--allow-override", metaVar = "metaVar_service", usage = "usage_configureTheServiceInDaemonServicename", multiValued = true) final List<String> canOverride = new ArrayList<String>(); - @Option(name = "--forbid-override", metaVar = "SERVICE", usage = "configure the service in daemon.servicename", multiValued = true) + @Option(name = "--forbid-override", metaVar = "metaVar_service", usage = "usage_configureTheServiceInDaemonServicename", multiValued = true) final List<String> forbidOverride = new ArrayList<String>(); - @Option(name = "--export-all", usage = "export without git-daemon-export-ok") + @Option(name = "--export-all", usage = "usage_exportWithoutGitDaemonExportOk") boolean exportAll; - @Argument(required = true, metaVar = "DIRECTORY", usage = "directories to export") + @Argument(required = true, metaVar = "metaVar_directory", usage = "usage_directoriesToExport") final List<File> directory = new ArrayList<File>(); @Override @@ -108,18 +109,18 @@ class Daemon extends TextBuiltin { service(d, n).setOverridable(false); for (final File f : directory) { - out.println("Exporting " + f.getAbsolutePath()); + out.println(MessageFormat.format(CLIText.get().exporting, f.getAbsolutePath())); d.exportDirectory(f); } d.start(); - out.println("Listening on " + d.getAddress()); + out.println(MessageFormat.format(CLIText.get().listeningOn, d.getAddress())); } private DaemonService service(final org.eclipse.jgit.transport.Daemon d, final String n) { final DaemonService svc = d.getService(n); if (svc == null) - throw die("Service '" + n + "' not supported"); + throw die(MessageFormat.format(CLIText.get().serviceNotSupported, n)); return svc; } -} +}
\ No newline at end of file diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java index 24bcdcc612..a5db453688 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java @@ -64,17 +64,17 @@ import org.eclipse.jgit.treewalk.TreeWalk; import org.eclipse.jgit.treewalk.filter.AndTreeFilter; import org.eclipse.jgit.treewalk.filter.TreeFilter; -@Command(common = true, usage = "Show diffs") +@Command(common = true, usage = "usage_ShowDiffs") class Diff extends TextBuiltin { - @Argument(index = 0, metaVar = "tree-ish", required = true) + @Argument(index = 0, metaVar = "metaVar_treeish", required = true) void tree_0(final AbstractTreeIterator c) { trees.add(c); } - @Argument(index = 1, metaVar = "tree-ish", required = true) + @Argument(index = 1, metaVar = "metaVar_treeish", required = true) private final List<AbstractTreeIterator> trees = new ArrayList<AbstractTreeIterator>(); - @Option(name = "--", metaVar = "path", multiValued = true, handler = PathTreeFilterHandler.class) + @Option(name = "--", metaVar = "metaVar_port", multiValued = true, handler = PathTreeFilterHandler.class) private TreeFilter pathFilter = TreeFilter.ALL; private DiffFormatter fmt = new DiffFormatter(); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/DiffTree.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/DiffTree.java index 13b1c780f0..a7c40acdb3 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/DiffTree.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/DiffTree.java @@ -57,18 +57,18 @@ import org.eclipse.jgit.treewalk.filter.AndTreeFilter; import org.eclipse.jgit.treewalk.filter.TreeFilter; class DiffTree extends TextBuiltin { - @Option(name = "--recursive", usage = "recurse into subtrees", aliases = { "-r" }) + @Option(name = "--recursive", usage = "usage_recurseIntoSubtrees", aliases = { "-r" }) private boolean recursive; - @Argument(index = 0, metaVar = "tree-ish", required = true) + @Argument(index = 0, metaVar = "metaVar_treeish", required = true) void tree_0(final AbstractTreeIterator c) { trees.add(c); } - @Argument(index = 1, metaVar = "tree-ish", required = true) + @Argument(index = 1, metaVar = "metaVar_treeish", required = true) private final List<AbstractTreeIterator> trees = new ArrayList<AbstractTreeIterator>(); - @Option(name = "--", metaVar = "path", multiValued = true, handler = PathTreeFilterHandler.class) + @Option(name = "--", metaVar = "metaVar_path", multiValued = true, handler = PathTreeFilterHandler.class) private TreeFilter pathFilter = TreeFilter.ALL; @Override diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java index 6ed468510f..a68145bf71 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java @@ -55,12 +55,12 @@ import org.eclipse.jgit.transport.FetchResult; import org.eclipse.jgit.transport.RefSpec; import org.eclipse.jgit.transport.Transport; -@Command(common = true, usage = "Update remote refs from another repository") +@Command(common = true, usage = "usage_updateRemoteRefsFromAnotherRepository") class Fetch extends AbstractFetchCommand { - @Option(name = "--timeout", metaVar = "SECONDS", usage = "abort connection if no activity") + @Option(name = "--timeout", metaVar = "metaVar_seconds", usage = "usage_abortConnectionIfNoActivity") int timeout = -1; - @Option(name = "--fsck", usage = "perform fsck style checks on receive") + @Option(name = "--fsck", usage = "usage_performFsckStyleChecksOnReceive") private Boolean fsck; @Option(name = "--no-fsck") @@ -68,13 +68,13 @@ class Fetch extends AbstractFetchCommand { fsck = Boolean.FALSE; } - @Option(name = "--prune", usage = "prune stale tracking refs") + @Option(name = "--prune", usage = "usage_pruneStaleTrackingRefs") private Boolean prune; @Option(name = "--dry-run") private boolean dryRun; - @Option(name = "--thin", usage = "fetch thin pack") + @Option(name = "--thin", usage = "usage_fetchThinPack") private Boolean thin; @Option(name = "--no-thin") @@ -82,10 +82,10 @@ class Fetch extends AbstractFetchCommand { thin = Boolean.FALSE; } - @Argument(index = 0, metaVar = "uri-ish") + @Argument(index = 0, metaVar = "metaVar_uriish") private String remote = Constants.DEFAULT_REMOTE_NAME; - @Argument(index = 1, metaVar = "refspec") + @Argument(index = 1, metaVar = "metaVar_refspec") private List<RefSpec> toget; @Override diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java index caf4f30e3b..3dfd8ff62d 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java @@ -84,7 +84,7 @@ class Glog extends RevWalkTextBuiltin { final JPanel buttons = new JPanel(new FlowLayout()); final JButton repaint = new JButton(); - repaint.setText("Repaint"); + repaint.setText(CLIText.get().repaint); repaint.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { graphPane.repaint(); @@ -118,7 +118,7 @@ class Glog extends RevWalkTextBuiltin { @Override protected RevWalk createWalk() { if (objects) - throw die("Cannot use --objects with glog"); + throw die(CLIText.get().cannotUseObjectsWithGlog); final PlotWalk w = new PlotWalk(db); w.sort(RevSort.BOUNDARY, true); return w; diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/IndexPack.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/IndexPack.java index eb65e680ff..35fd2a5971 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/IndexPack.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/IndexPack.java @@ -52,13 +52,13 @@ import org.kohsuke.args4j.Option; import org.eclipse.jgit.lib.TextProgressMonitor; class IndexPack extends TextBuiltin { - @Option(name = "--fix-thin", usage = "fix a thin pack to be complete") + @Option(name = "--fix-thin", usage = "usage_fixAThinPackToBeComplete") private boolean fixThin; - @Option(name = "--index-version", usage = "index file format to create") + @Option(name = "--index-version", usage = "usage_indexFileFormatToCreate") private int indexVersion = -1; - @Argument(index = 0, required = true, metaVar = "base") + @Argument(index = 0, required = true, metaVar = "metaVar_base") private File base; @Override diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java index a8fe7d8a53..d8c7bdfb4a 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java @@ -46,14 +46,15 @@ package org.eclipse.jgit.pgm; import java.io.File; +import java.text.MessageFormat; import org.kohsuke.args4j.Option; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Repository; -@Command(common = true, usage = "Create an empty git repository") +@Command(common = true, usage = "usage_CreateAnEmptyGitRepository") class Init extends TextBuiltin { - @Option(name = "--bare", usage = "Create a bare repository") + @Option(name = "--bare", usage = "usage_CreateABareRepository") private boolean bare; @Override @@ -67,7 +68,6 @@ class Init extends TextBuiltin { gitdir = new File(bare ? "." : Constants.DOT_GIT); db = new Repository(gitdir); db.create(bare); - out.println("Initialized empty Git repository in " - + gitdir.getAbsolutePath()); + out.println(MessageFormat.format(CLIText.get().initializedEmptyGitRepositoryIn, gitdir.getAbsolutePath())); } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java index 4b5975669f..9aa197e4ab 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java @@ -46,6 +46,7 @@ package org.eclipse.jgit.pgm; import java.text.DateFormat; +import java.text.MessageFormat; import java.text.SimpleDateFormat; import java.util.Collection; import java.util.Iterator; @@ -61,7 +62,7 @@ import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevWalk; -@Command(common = true, usage = "View commit history") +@Command(common = true, usage = "usage_viewCommitHistory") class Log extends RevWalkTextBuiltin { private final TimeZone myTZ = TimeZone.getDefault(); @@ -69,7 +70,7 @@ class Log extends RevWalkTextBuiltin { private Map<AnyObjectId, Set<Ref>> allRefsByPeeledObjectId; - @Option(name="--decorate", usage="Show ref names matching commits") + @Option(name="--decorate", usage="usage_showRefNamesMatchingCommits") private boolean decorate; Log() { @@ -86,7 +87,8 @@ class Log extends RevWalkTextBuiltin { @Override protected void show(final RevCommit c) throws Exception { - out.print("commit "); + out.print(CLIText.get().commitLabel); + out.print(" "); c.getId().copyTo(outbuffer, out); if (decorate) { Collection<Ref> list = allRefsByPeeledObjectId.get(c.copy()); @@ -103,18 +105,11 @@ class Log extends RevWalkTextBuiltin { out.println(); final PersonIdent author = c.getAuthorIdent(); - out.print("Author: "); - out.print(author.getName()); - out.print(" <"); - out.print(author.getEmailAddress()); - out.print(">"); - out.println(); + out.println(MessageFormat.format(CLIText.get().authorInfo, author.getName(), author.getEmailAddress())); final TimeZone authorTZ = author.getTimeZone(); fmt.setTimeZone(authorTZ != null ? authorTZ : myTZ); - out.print("Date: "); - out.print(fmt.format(author.getWhen())); - out.println(); + out.println(MessageFormat.format(CLIText.get().dateInfo, fmt.format(author.getWhen()))); out.println(); final String[] lines = c.getFullMessage().split("\n"); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java index 44d1e754fe..e750e2dea8 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java @@ -53,10 +53,10 @@ import org.eclipse.jgit.transport.FetchConnection; import org.eclipse.jgit.transport.Transport; class LsRemote extends TextBuiltin { - @Option(name = "--timeout", metaVar = "SECONDS", usage = "abort connection if no activity") + @Option(name = "--timeout", metaVar = "metaVar_service", usage = "usage_abortConnectionIfNoActivity") int timeout = -1; - @Argument(index = 0, metaVar = "uri-ish", required = true) + @Argument(index = 0, metaVar = "metaVar_uriish", required = true) private String remote; @Override diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsTree.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsTree.java index 1a28a9a48f..4b63edeb0d 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsTree.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsTree.java @@ -53,10 +53,10 @@ import org.eclipse.jgit.treewalk.AbstractTreeIterator; import org.eclipse.jgit.treewalk.TreeWalk; class LsTree extends TextBuiltin { - @Option(name = "--recursive", usage = "recurse into subtrees", aliases = { "-r" }) + @Option(name = "--recursive", usage = "usage_recurseIntoSubtrees", aliases = { "-r" }) private boolean recursive; - @Argument(index = 0, required = true, metaVar = "tree-ish") + @Argument(index = 0, required = true, metaVar = "metaVar_treeish") private AbstractTreeIterator tree; @Override diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java index f1191a4599..306ac816d8 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java @@ -45,9 +45,11 @@ package org.eclipse.jgit.pgm; import java.io.File; +import java.io.PrintWriter; import java.lang.reflect.InvocationTargetException; import java.net.MalformedURLException; import java.net.URL; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -70,19 +72,19 @@ import org.kohsuke.args4j.Option; /** Command line entry point. */ public class Main { - @Option(name = "--help", usage = "display this help text", aliases = { "-h" }) + @Option(name = "--help", usage = "usage_displayThisHelpText", aliases = { "-h" }) private boolean help; - @Option(name = "--show-stack-trace", usage = "display the Java stack trace on exceptions") + @Option(name = "--show-stack-trace", usage = "usage_displayThejavaStackTraceOnExceptions") private boolean showStackTrace; - @Option(name = "--git-dir", metaVar = "GIT_DIR", usage = "set the git repository to operate on") + @Option(name = "--git-dir", metaVar = "metaVar_gitDir", usage = "usage_setTheGitRepositoryToOperateOn") private File gitdir; - @Argument(index = 0, metaVar = "command", required = true, handler = SubcommandHandler.class) + @Argument(index = 0, metaVar = "metaVar_command", required = true, handler = SubcommandHandler.class) private TextBuiltin subcommand; - @Argument(index = 1, metaVar = "ARG") + @Argument(index = 1, metaVar = "metaVar_arg") private List<String> arguments = new ArrayList<String>(); /** @@ -101,17 +103,17 @@ public class Main { configureHttpProxy(); me.execute(argv); } catch (Die err) { - System.err.println("fatal: " + err.getMessage()); + System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage())); if (me.showStackTrace) err.printStackTrace(); System.exit(128); } catch (Exception err) { if (!me.showStackTrace && err.getCause() != null && err instanceof TransportException) - System.err.println("fatal: " + err.getCause().getMessage()); + System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getCause().getMessage())); if (err.getClass().getName().startsWith("org.eclipse.jgit.errors.")) { - System.err.println("fatal: " + err.getMessage()); + System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage())); if (me.showStackTrace) err.printStackTrace(); System.exit(128); @@ -123,25 +125,27 @@ public class Main { private void execute(final String[] argv) throws Exception { final CmdLineParser clp = new CmdLineParser(this); + PrintWriter writer = new PrintWriter(System.err); try { clp.parseArgument(argv); } catch (CmdLineException err) { if (argv.length > 0 && !help) { - System.err.println("fatal: " + err.getMessage()); + writer.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage())); + writer.flush(); System.exit(1); } } if (argv.length == 0 || help) { - final String ex = clp.printExample(ExampleMode.ALL); - System.err.println("jgit" + ex + " command [ARG ...]"); + final String ex = clp.printExample(ExampleMode.ALL, CLIText.get().resourceBundle()); + writer.println("jgit" + ex + " command [ARG ...]"); if (help) { - System.err.println(); - clp.printUsage(System.err); - System.err.println(); + writer.println(); + clp.printUsage(writer, CLIText.get().resourceBundle()); + writer.println(); } else if (subcommand == null) { - System.err.println(); - System.err.println("The most commonly used commands are:"); + writer.println(); + writer.println(CLIText.get().mostCommonlyUsedCommandsAre); final CommandRef[] common = CommandCatalog.common(); int width = 0; for (final CommandRef c : common) @@ -149,15 +153,16 @@ public class Main { width += 2; for (final CommandRef c : common) { - System.err.print(' '); - System.err.print(c.getName()); + writer.print(' '); + writer.print(c.getName()); for (int i = c.getName().length(); i < width; i++) - System.err.print(' '); - System.err.print(c.getUsage()); - System.err.println(); + writer.print(' '); + writer.print(CLIText.get().resourceBundle().getString(c.getUsage())); + writer.println(); } - System.err.println(); + writer.println(); } + writer.flush(); System.exit(1); } @@ -203,7 +208,8 @@ public class Main { altobjectdirs = null; if (gitdir == null || !gitdir.isDirectory()) { - System.err.println("error: can't find git directory"); + writer.println(CLIText.get().cantFindGitDirectory); + writer.flush(); System.exit(1); } cmd.init(new Repository(gitdir, gitworktree, objectdir, altobjectdirs, indexfile), gitdir); @@ -252,15 +258,15 @@ public class Main { return false; } catch (IllegalArgumentException e) { - throw new RuntimeException("Cannot setup console", e); + throw new RuntimeException(CLIText.get().cannotSetupConsole, e); } catch (SecurityException e) { - throw new RuntimeException("Cannot setup console", e); + throw new RuntimeException(CLIText.get().cannotSetupConsole, e); } catch (IllegalAccessException e) { - throw new RuntimeException("Cannot setup console", e); + throw new RuntimeException(CLIText.get().cannotSetupConsole, e); } catch (InvocationTargetException e) { - throw new RuntimeException("Cannot setup console", e); + throw new RuntimeException(CLIText.get().cannotSetupConsole, e); } catch (NoSuchMethodException e) { - throw new RuntimeException("Cannot setup console", e); + throw new RuntimeException(CLIText.get().cannotSetupConsole, e); } } @@ -297,8 +303,7 @@ public class Main { final URL u = new URL((s.indexOf("://") == -1) ? "http://" + s : s); if (!"http".equals(u.getProtocol())) - throw new MalformedURLException("Invalid http_proxy: " + s - + ": Only http supported."); + throw new MalformedURLException(MessageFormat.format(CLIText.get().invalidHttpProxyOnlyHttpSupported, s)); final String proxyHost = u.getHost(); final int proxyPort = u.getPort(); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/MergeBase.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/MergeBase.java index 91fd7443b0..f59fd43158 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/MergeBase.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/MergeBase.java @@ -53,15 +53,15 @@ import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.filter.RevFilter; class MergeBase extends TextBuiltin { - @Option(name = "--all", usage = "display all possible merge bases") + @Option(name = "--all", usage = "usage_displayAllPossibleMergeBases") private boolean all; - @Argument(index = 0, metaVar = "commit-ish", required = true) + @Argument(index = 0, metaVar = "metaVar_commitish", required = true) void commit_0(final RevCommit c) { commits.add(c); } - @Argument(index = 1, metaVar = "commit-ish", required = true) + @Argument(index = 1, metaVar = "metaVar_commitish", required = true) private final List<RevCommit> commits = new ArrayList<RevCommit>(); @Override diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java index 2c02545639..22fd7e38f5 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.pgm; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -59,15 +60,15 @@ import org.eclipse.jgit.transport.Transport; import org.eclipse.jgit.transport.URIish; import org.eclipse.jgit.transport.RemoteRefUpdate.Status; -@Command(common = true, usage = "Update remote repository from local refs") +@Command(common = true, usage = "usage_UpdateRemoteRepositoryFromLocalRefs") class Push extends TextBuiltin { - @Option(name = "--timeout", metaVar = "SECONDS", usage = "abort connection if no activity") + @Option(name = "--timeout", metaVar = "metaVar_seconds", usage = "usage_abortConnectionIfNoActivity") int timeout = -1; - @Argument(index = 0, metaVar = "uri-ish") + @Argument(index = 0, metaVar = "metaVar_uriish") private String remote = Constants.DEFAULT_REMOTE_NAME; - @Argument(index = 1, metaVar = "refspec") + @Argument(index = 1, metaVar = "metaVar_refspec") private final List<RefSpec> refSpecs = new ArrayList<RefSpec>(); @Option(name = "--all") @@ -94,7 +95,7 @@ class Push extends TextBuiltin { @Option(name = "--force", aliases = { "-f" }) private boolean force; - @Option(name = "--receive-pack", metaVar = "path") + @Option(name = "--receive-pack", metaVar = "metaVar_path") private String receivePack; @Option(name = "--dry-run") @@ -164,14 +165,14 @@ class Push extends TextBuiltin { AbstractFetchCommand.showRemoteMessages(result.getMessages()); if (everythingUpToDate) - out.println("Everything up-to-date"); + out.println(CLIText.get().everythingUpToDate); } private void printRefUpdateResult(final URIish uri, final PushResult result, final RemoteRefUpdate rru) { if (!shownURI) { shownURI = true; - out.format("To %s\n", uri); + out.println(MessageFormat.format(CLIText.get().pushTo, uri)); } final String remoteName = rru.getRemoteName(); @@ -197,7 +198,7 @@ class Push extends TextBuiltin { .name() + (fastForward ? ".." : "...") + rru.getNewObjectId().abbreviate(db).name(); - final String message = fastForward ? null : "forced update"; + final String message = fastForward ? null : CLIText.get().forcedUpdate; printUpdateLine(flag, summary, srcRef, remoteName, message); } } @@ -209,17 +210,18 @@ class Push extends TextBuiltin { case REJECTED_NODELETE: printUpdateLine('!', "[rejected]", null, remoteName, - "remote side does not support deleting refs"); + CLIText.get().remoteSideDoesNotSupportDeletingRefs); break; case REJECTED_NONFASTFORWARD: printUpdateLine('!', "[rejected]", srcRef, remoteName, - "non-fast forward"); + CLIText.get().nonFastForward); break; case REJECTED_REMOTE_CHANGED: - final String message = "remote ref object changed - is not expected one " - + rru.getExpectedOldObjectId().abbreviate(db).name(); + final String message = MessageFormat.format( + CLIText.get().remoteRefObjectChangedIsNotExpectedOne + , rru.getExpectedOldObjectId().abbreviate(db).name()); printUpdateLine('!', "[rejected]", srcRef, remoteName, message); break; diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java index f43a2793ee..09a9f2b580 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java @@ -45,14 +45,15 @@ package org.eclipse.jgit.pgm; import java.io.File; +import java.text.MessageFormat; import org.kohsuke.args4j.Argument; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Repository; -@Command(common = false, usage = "Server side backend for 'jgit push'") +@Command(common = false, usage = "usage_ServerSideBackendForJgitPush") class ReceivePack extends TextBuiltin { - @Argument(index = 0, required = true, metaVar = "DIRECTORY", usage = "Repository to receive into") + @Argument(index = 0, required = true, metaVar = "metaVar_directory", usage = "usage_RepositoryToReceiveInto") File dstGitdir; @Override @@ -68,7 +69,7 @@ class ReceivePack extends TextBuiltin { dstGitdir = new File(dstGitdir, Constants.DOT_GIT); db = new Repository(dstGitdir); if (!db.getObjectsDirectory().isDirectory()) - throw die("'" + dstGitdir.getPath() + "' not a git repository"); + throw die(MessageFormat.format(CLIText.get().notAGitRepository, dstGitdir.getPath())); rp = new org.eclipse.jgit.transport.ReceivePack(db); rp.receive(System.in, System.out, System.err); } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java index cb0cd6d0f5..ea6eeb102c 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.pgm; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.EnumSet; import java.util.List; @@ -109,10 +110,10 @@ abstract class RevWalkTextBuiltin extends TextBuiltin { enableRevSort(RevSort.BOUNDARY, on); } - @Argument(index = 0, metaVar = "commit-ish") + @Argument(index = 0, metaVar = "metaVar_commitish") private final List<RevCommit> commits = new ArrayList<RevCommit>(); - @Option(name = "--", metaVar = "path", multiValued = true, handler = PathTreeFilterHandler.class) + @Option(name = "--", metaVar = "metaVar_path", multiValued = true, handler = PathTreeFilterHandler.class) private TreeFilter pathFilter = TreeFilter.ALL; private final List<RevFilter> revLimiter = new ArrayList<RevFilter>(); @@ -150,7 +151,7 @@ abstract class RevWalkTextBuiltin extends TextBuiltin { if (commits.isEmpty()) { final ObjectId head = db.resolve(Constants.HEAD); if (head == null) - throw die("Cannot resolve " + Constants.HEAD); + throw die(MessageFormat.format(CLIText.get().cannotResolve, Constants.HEAD)); commits.add(walk.parseCommit(head)); } for (final RevCommit c : commits) { @@ -167,9 +168,8 @@ abstract class RevWalkTextBuiltin extends TextBuiltin { final long end = System.currentTimeMillis(); System.err.print(n); System.err.print(' '); - System.err.print(end - start); - System.err.print(" ms"); - System.err.println(); + System.err.println(MessageFormat.format( + CLIText.get().timeInMilliSeconds, end - start)); } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java index 63e6e1712d..1b8711dc9d 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java @@ -57,9 +57,9 @@ import org.eclipse.jgit.pgm.opt.PathTreeFilterHandler; import org.eclipse.jgit.treewalk.TreeWalk; import org.eclipse.jgit.treewalk.filter.TreeFilter; -@Command(usage = "Stop tracking a file", common = true) +@Command(usage = "usage_StopTrackingAFile", common = true) class Rm extends TextBuiltin { - @Argument(metaVar = "path", usage = "path", multiValued = true, required = true, handler = PathTreeFilterHandler.class) + @Argument(metaVar = "metaVar_path", usage = "usage_path", multiValued = true, required = true, handler = PathTreeFilterHandler.class) @Option(name = "--", handler = StopOptionHandler.class) private TreeFilter paths; diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java index 703b10baf2..63d26eacae 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java @@ -47,6 +47,8 @@ package org.eclipse.jgit.pgm; +import java.text.MessageFormat; + import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Option; import org.eclipse.jgit.errors.MissingObjectException; @@ -55,18 +57,18 @@ import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectLoader; import org.eclipse.jgit.lib.PersonIdent; -@Command(common = true, usage = "Create a tag") +@Command(common = true, usage = "usage_CreateATag") class Tag extends TextBuiltin { - @Option(name = "-f", usage = "force replacing an existing tag") + @Option(name = "-f", usage = "usage_forceReplacingAnExistingTag") private boolean force; - @Option(name = "-m", metaVar = "message", usage = "tag message") + @Option(name = "-m", metaVar = "metaVar_message", usage = "usage_tagMessage") private String message = ""; - @Argument(index = 0, required = true, metaVar = "name") + @Argument(index = 0, required = true, metaVar = "metaVar_name") private String tagName; - @Argument(index = 1, metaVar = "object") + @Argument(index = 1, metaVar = "metaVar_object") private ObjectId object; @Override @@ -74,15 +76,14 @@ class Tag extends TextBuiltin { if (object == null) { object = db.resolve(Constants.HEAD); if (object == null) - throw die("Cannot resolve " + Constants.HEAD); + throw die(MessageFormat.format(CLIText.get().cannotResolve, Constants.HEAD)); } if (!tagName.startsWith(Constants.R_TAGS)) tagName = Constants.R_TAGS + tagName; if (!force && db.resolve(tagName) != null) { - throw die("fatal: tag '" - + tagName.substring(Constants.R_TAGS.length()) - + "' exists"); + throw die(MessageFormat.format(CLIText.get().fatalErrorTagExists + , tagName.substring(Constants.R_TAGS.length()))); } final ObjectLoader ldr = db.openObject(object); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java index 13b45e242a..b6f12a1ab1 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java @@ -53,6 +53,8 @@ import java.io.File; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.text.MessageFormat; +import java.util.ResourceBundle; import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.Option; @@ -75,7 +77,7 @@ import org.eclipse.jgit.revwalk.RevWalk; public abstract class TextBuiltin { private String commandName; - @Option(name = "--help", usage = "display this help text", aliases = { "-h" }) + @Option(name = "--help", usage = "usage_displayThisHelpText", aliases = { "-h" }) private boolean help; /** Stream to output to, typically this is standard output. */ @@ -110,7 +112,7 @@ public abstract class TextBuiltin { out = new PrintWriter(new BufferedWriter( new OutputStreamWriter(System.out))); } catch (IOException e) { - throw die("cannot create output stream"); + throw die(CLIText.get().cannotCreateOutputStream); } if (repo != null) { @@ -153,7 +155,7 @@ public abstract class TextBuiltin { clp.parseArgument(args); } catch (CmdLineException err) { if (!help) { - System.err.println("fatal: " + err.getMessage()); + System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage())); System.exit(1); } } @@ -181,20 +183,30 @@ public abstract class TextBuiltin { * @param clp */ public void printUsageAndExit(final String message, final CmdLineParser clp) { - System.err.println(message); - System.err.print("jgit "); - System.err.print(commandName); - clp.printSingleLineUsage(System.err); - System.err.println(); + PrintWriter writer = new PrintWriter(System.err); + writer.println(message); + writer.print("jgit "); + writer.print(commandName); + clp.printSingleLineUsage(writer, getResourceBundle()); + writer.println(); - System.err.println(); - clp.printUsage(System.err); - System.err.println(); + writer.println(); + clp.printUsage(writer, getResourceBundle()); + writer.println(); + writer.flush(); System.exit(1); } /** + * @return the resource bundle that will be passed to args4j for purpose + * of string localization + */ + protected ResourceBundle getResourceBundle() { + return CLIText.get().resourceBundle(); + } + + /** * Perform the actions of this command. * <p> * This method should only be invoked by {@link #execute(String[])}. @@ -216,7 +228,7 @@ public abstract class TextBuiltin { ObjectId resolve(final String s) throws IOException { final ObjectId r = db.resolve(s); if (r == null) - throw die("Not a revision: " + s); + throw die(MessageFormat.format(CLIText.get().notARevision, s)); return r; } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java index ea30899dcb..52d2488f70 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java @@ -45,18 +45,19 @@ package org.eclipse.jgit.pgm; import java.io.File; +import java.text.MessageFormat; import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Option; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Repository; -@Command(common = false, usage = "Server side backend for 'jgit fetch'") +@Command(common = false, usage = "usage_ServerSideBackendForJgitFetch") class UploadPack extends TextBuiltin { - @Option(name = "--timeout", metaVar = "SECONDS", usage = "abort connection if no activity") + @Option(name = "--timeout", metaVar = "metaVar_seconds", usage = "usage_abortConnectionIfNoActivity") int timeout = -1; - @Argument(index = 0, required = true, metaVar = "DIRECTORY", usage = "Repository to read from") + @Argument(index = 0, required = true, metaVar = "metaVar_directory", usage = "usage_RepositoryToReadFrom") File srcGitdir; @Override @@ -72,7 +73,7 @@ class UploadPack extends TextBuiltin { srcGitdir = new File(srcGitdir, Constants.DOT_GIT); db = new Repository(srcGitdir); if (!db.getObjectsDirectory().isDirectory()) - throw die("'" + srcGitdir.getPath() + "' not a git repository"); + throw die(MessageFormat.format(CLIText.get().notAGitRepository, srcGitdir.getPath())); rp = new org.eclipse.jgit.transport.UploadPack(db); if (0 <= timeout) rp.setTimeout(timeout); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Version.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Version.java index 11b6e83523..5bad4ef98c 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Version.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Version.java @@ -43,16 +43,16 @@ package org.eclipse.jgit.pgm; -@Command(common = true, usage = "Display the version of jgit") +import java.text.MessageFormat; + +@Command(common = true, usage = "usage_DisplayTheVersionOfJgit") class Version extends TextBuiltin { @Override protected void run() throws Exception { final Package pkg = getClass().getPackage(); if (pkg == null || pkg.getImplementationVersion() == null) - throw die("Cannot read package information."); + throw die(CLIText.get().cannotReadPackageInformation); - out.print("jgit version "); - out.print(pkg.getImplementationVersion()); - out.println(); + out.println(MessageFormat.format(CLIText.get().jgitVersion, pkg.getImplementationVersion())); } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/MakeCacheTree.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/MakeCacheTree.java index 8949cbce6d..d772ffe23f 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/MakeCacheTree.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/MakeCacheTree.java @@ -44,8 +44,11 @@ package org.eclipse.jgit.pgm.debug; +import java.text.MessageFormat; + import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.dircache.DirCacheTree; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.pgm.TextBuiltin; class MakeCacheTree extends TextBuiltin { @@ -57,16 +60,8 @@ class MakeCacheTree extends TextBuiltin { } private void show(final DirCacheTree tree) { - out.print("\""); - out.print(tree.getPathString()); - out.print("\""); - out.print(": "); - out.print(tree.getEntrySpan()); - out.print(" entries"); - out.print(", "); - out.print(tree.getChildCount()); - out.print(" children"); - out.println(); + out.println(MessageFormat.format(CLIText.get().cacheTreePathInfo + , tree.getPathString(), tree.getEntrySpan(), tree.getChildCount())); for (int i = 0; i < tree.getChildCount(); i++) show(tree.getChild(i)); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ReadDirCache.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ReadDirCache.java index b0c1c77fdb..2a1079b313 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ReadDirCache.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ReadDirCache.java @@ -44,7 +44,10 @@ package org.eclipse.jgit.pgm.debug; +import java.text.MessageFormat; + import org.eclipse.jgit.dircache.DirCache; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.pgm.TextBuiltin; class ReadDirCache extends TextBuiltin { @@ -55,6 +58,7 @@ class ReadDirCache extends TextBuiltin { for (int i = 0; i < cnt; i++) DirCache.read(db); final long end = System.currentTimeMillis(); - out.println(" average " + ((end - start) / cnt) + " ms/read"); + out.print(" "); + out.println(MessageFormat.format(CLIText.get().averageMSPerRead, (end - start) / cnt)); } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java index 0a5f2a0c9a..38df041017 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java @@ -48,6 +48,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; @@ -72,6 +73,7 @@ import org.eclipse.jgit.lib.RefUpdate; import org.eclipse.jgit.lib.RefWriter; import org.eclipse.jgit.lib.TextProgressMonitor; import org.eclipse.jgit.lib.Tree; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.pgm.TextBuiltin; import org.eclipse.jgit.revwalk.RevWalk; @@ -96,13 +98,13 @@ import org.eclipse.jgit.revwalk.RevWalk; class RebuildCommitGraph extends TextBuiltin { private final String REALLY = "--destroy-this-repository"; - @Option(name = REALLY, usage = "approve destruction of repository") + @Option(name = REALLY, usage = "usage_approveDestructionOfRepository") boolean really; - @Argument(index = 0, required = true, metaVar = "REFS", usage = "for-each-ref output") + @Argument(index = 0, required = true, metaVar = "metaVar_refs", usage = "usage_forEachRefOutput") File refList; - @Argument(index = 1, required = true, metaVar = "DAG", usage = "log --all '--pretty=format:%H %ct %P' output") + @Argument(index = 1, required = true, metaVar = "metaVar_refs", usage = "usage_logAllPretty") File graph; private final ProgressMonitor pm = new TextProgressMonitor(); @@ -112,28 +114,15 @@ class RebuildCommitGraph extends TextBuiltin { @Override protected void run() throws Exception { if (!really && !db.getAllRefs().isEmpty()) { - final StringBuilder m = new StringBuilder(); - m.append("fatal: "); - m.append("This program will destroy the repository:"); - m.append("\n"); - m.append("fatal:\n"); - m.append("fatal: "); - m.append(db.getDirectory().getAbsolutePath()); - m.append("\n"); - m.append("fatal:\n"); - m.append("fatal: "); - m.append("To continue, add "); - m.append(REALLY); - m.append(" to the command line"); - m.append("\n"); - m.append("fatal:"); - System.err.println(m); - throw die("Need approval to destroy current repository"); + System.err.println( + MessageFormat.format(CLIText.get().fatalThisProgramWillDestroyTheRepository + , db.getDirectory().getAbsolutePath(), REALLY)); + throw die(CLIText.get().needApprovalToDestroyCurrentRepository); } if (!refList.isFile()) - throw die("no such file: " + refList.getPath()); + throw die(MessageFormat.format(CLIText.get().noSuchFile, refList.getPath())); if (!graph.isFile()) - throw die("no such file: " + graph.getPath()); + throw die(MessageFormat.format(CLIText.get().noSuchFile, graph.getPath())); recreateCommitGraph(); detachHead(); @@ -240,10 +229,10 @@ class RebuildCommitGraph extends TextBuiltin { final LockFile lf; lf = new LockFile(new File(db.getDirectory(), Constants.HEAD)); if (!lf.lock()) - throw new IOException("Cannot lock HEAD"); + throw new IOException(MessageFormat.format(CLIText.get().cannotLock, Constants.HEAD)); lf.write(id); if (!lf.commit()) - throw new IOException("Cannot deatch HEAD"); + throw new IOException(CLIText.get().cannotDeatchHEAD); } } @@ -267,14 +256,14 @@ class RebuildCommitGraph extends TextBuiltin { final File file = new File(db.getDirectory(), name); final LockFile lck = new LockFile(file); if (!lck.lock()) - throw new ObjectWritingException("Can't write " + file); + throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite, file)); try { lck.write(content); } catch (IOException ioe) { - throw new ObjectWritingException("Can't write " + file); + throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite, file)); } if (!lck.commit()) - throw new ObjectWritingException("Can't write " + file); + throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite, file)); } }.writePackedRefs(); } @@ -299,7 +288,7 @@ class RebuildCommitGraph extends TextBuiltin { rw.parseAny(id); } catch (MissingObjectException mue) { if (!Constants.TYPE_COMMIT.equals(type)) { - System.err.println("skipping " + type + " " + name); + System.err.println(MessageFormat.format(CLIText.get().skippingObject, type, name)); continue; } throw new MissingObjectException(id, type); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCacheTree.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCacheTree.java index 29cdc98a83..09796edb30 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCacheTree.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCacheTree.java @@ -44,8 +44,11 @@ package org.eclipse.jgit.pgm.debug; +import java.text.MessageFormat; + import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.dircache.DirCacheTree; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.pgm.TextBuiltin; class ShowCacheTree extends TextBuiltin { @@ -54,21 +57,13 @@ class ShowCacheTree extends TextBuiltin { final DirCache cache = DirCache.read(db); final DirCacheTree tree = cache.getCacheTree(false); if (tree == null) - throw die("no 'TREE' section in index"); + throw die(CLIText.get().noTREESectionInIndex); show(tree); } private void show(final DirCacheTree tree) { - out.print("\""); - out.print(tree.getPathString()); - out.print("\""); - out.print(": "); - out.print(tree.getEntrySpan()); - out.print(" entries"); - out.print(", "); - out.print(tree.getChildCount()); - out.print(" children"); - out.println(); + out.println(MessageFormat.format(CLIText.get().cacheTreePathInfo + , tree.getPathString(), tree.getEntrySpan(), tree.getChildCount())); for (int i = 0; i < tree.getChildCount(); i++) show(tree.getChild(i)); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCommands.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCommands.java index 063cab5acf..78fc1453d1 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCommands.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCommands.java @@ -46,14 +46,15 @@ package org.eclipse.jgit.pgm.debug; import java.net.URL; import org.kohsuke.args4j.Option; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.pgm.Command; import org.eclipse.jgit.pgm.CommandCatalog; import org.eclipse.jgit.pgm.CommandRef; import org.eclipse.jgit.pgm.TextBuiltin; -@Command(usage = "Display a list of all registered jgit commands") +@Command(usage = "usage_displayAListOfAllRegisteredJgitCommands") class ShowCommands extends TextBuiltin { - @Option(name = "--pretty", usage = "alter the detail shown") + @Option(name = "--pretty", usage = "usage_alterTheDetailShown") private Format pretty = Format.USAGE; @Override @@ -83,7 +84,9 @@ class ShowCommands extends TextBuiltin { /** */ USAGE { void print(final CommandRef c) { - System.err.print(c.getUsage()); + String usage = c.getUsage(); + if (usage != null && usage.length() > 0) + System.err.print(CLIText.get().resourceBundle().getString(usage)); } }, @@ -104,7 +107,7 @@ class ShowCommands extends TextBuiltin { final URL url = ldr.getResource(cn); if (url == null) { - System.err.print("!! NOT FOUND !!"); + System.err.print(CLIText.get().notFound); return; } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/WriteDirCache.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/WriteDirCache.java index 54301dd041..cee5966a03 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/WriteDirCache.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/WriteDirCache.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.pgm.debug; import org.eclipse.jgit.dircache.DirCache; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.pgm.TextBuiltin; class WriteDirCache extends TextBuiltin { @@ -52,10 +53,10 @@ class WriteDirCache extends TextBuiltin { protected void run() throws Exception { final DirCache cache = DirCache.read(db); if (!cache.lock()) - throw die("failed to lock index"); + throw die(CLIText.get().failedToLockIndex); cache.read(); cache.write(); if (!cache.commit()) - throw die("failed to commit index"); + throw die(CLIText.get().failedToCommitIndex); } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Iplog.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Iplog.java index bb51f56070..e13bb1f136 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Iplog.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Iplog.java @@ -46,12 +46,14 @@ package org.eclipse.jgit.pgm.eclipse; import java.io.File; import java.io.OutputStream; import java.net.CookieHandler; +import java.text.MessageFormat; import org.eclipse.jgit.iplog.IpLogGenerator; import org.eclipse.jgit.iplog.SimpleCookieManager; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.LockFile; import org.eclipse.jgit.lib.ObjectId; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.pgm.Command; import org.eclipse.jgit.pgm.TextBuiltin; import org.eclipse.jgit.revwalk.RevObject; @@ -60,15 +62,15 @@ import org.eclipse.jgit.revwalk.RevWalk; import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Option; -@Command(name = "eclipse-iplog", common = false, usage = "Produce an Eclipse IP log") +@Command(name = "eclipse-iplog", common = false, usage = "usage_produceAnEclipseIPLog") class Iplog extends TextBuiltin { - @Option(name = "--version", aliases = { "-r" }, metaVar = "VERSION", usage = "Symbolic version for the project") + @Option(name = "--version", aliases = { "-r" }, metaVar = "metaVar_version", usage = "usage_symbolicVersionForTheProject") private String version; - @Option(name = "--output", aliases = { "-o" }, metaVar = "FILE", usage = "Output file") + @Option(name = "--output", aliases = { "-o" }, metaVar = "metaVar_file", usage = "usage_outputFile") private File output; - @Argument(index = 0, metaVar = "COMMIT|TAG") + @Argument(index = 0, metaVar = "metaVar_commitOrTag") private ObjectId commitId; @Override @@ -79,8 +81,8 @@ class Iplog extends TextBuiltin { final IpLogGenerator log = new IpLogGenerator(); if (commitId == null) { - System.err.println("warning: No commit given on command line," - + " assuming " + Constants.HEAD); + System.err.println(MessageFormat.format( + CLIText.get().warningNoCommitGivenOnCommandLine, Constants.HEAD)); commitId = db.resolve(Constants.HEAD); } @@ -89,7 +91,7 @@ class Iplog extends TextBuiltin { if (version == null && start instanceof RevTag) version = ((RevTag) start).getTagName(); else if (version == null) - throw die(start.name() + " is not a tag, --version is required"); + throw die(MessageFormat.format(CLIText.get().notATagVersionIsRequired, start.name())); log.scan(db, rw.parseCommit(start), version); @@ -98,7 +100,7 @@ class Iplog extends TextBuiltin { output.getParentFile().mkdirs(); LockFile lf = new LockFile(output); if (!lf.lock()) - throw die("Cannot lock " + output); + throw die(MessageFormat.format(CLIText.get().cannotLock, output)); try { OutputStream os = lf.getOutputStream(); try { @@ -107,7 +109,7 @@ class Iplog extends TextBuiltin { os.close(); } if (!lf.commit()) - throw die("Cannot write " + output); + throw die(MessageFormat.format(CLIText.get().cannotWrite, output)); } finally { lf.unlock(); } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Ipzilla.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Ipzilla.java index 616ca420cb..4f0e338e8d 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Ipzilla.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Ipzilla.java @@ -51,22 +51,23 @@ import java.net.URL; import org.eclipse.jgit.iplog.IpLogMeta; import org.eclipse.jgit.iplog.SimpleCookieManager; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.pgm.Command; import org.eclipse.jgit.pgm.TextBuiltin; import org.kohsuke.args4j.Option; -@Command(name = "eclipse-ipzilla", common = false, usage = "Synchronize IPZilla data") +@Command(name = "eclipse-ipzilla", common = false, usage = "usage_synchronizeIPZillaData") class Ipzilla extends TextBuiltin { - @Option(name = "--url", metaVar = "URL", usage = "IPZilla URL") + @Option(name = "--url", metaVar = "metaVar_url", usage = "usage_IPZillaURL") private String url = "https://dev.eclipse.org/ipzilla/"; - @Option(name = "--username", metaVar = "USER", usage = "IPZilla Username") + @Option(name = "--username", metaVar = "metaVar_user", usage = "usage_IPZillaUsername") private String username; - @Option(name = "--password", metaVar = "PASS", usage = "IPZilla Password") + @Option(name = "--password", metaVar = "metaVar_pass", usage = "usage_IPZillaPassword") private String password; - @Option(name = "--file", aliases = { "-f" }, metaVar = "FILE", usage = "Input/output file") + @Option(name = "--file", aliases = { "-f" }, metaVar = "metaVar_file", usage = "usage_inputOutputFile") private File output; @Override @@ -81,7 +82,7 @@ class Ipzilla extends TextBuiltin { null, // ipzilla.getPort(), // ipzilla.getProtocol(), // - "IPZilla Password", // + CLIText.get().IPZillaPasswordPrompt, // ipzilla.getProtocol(), // ipzilla, // Authenticator.RequestorType.SERVER); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java index c31676d72f..0bc9ee1122 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java @@ -46,6 +46,7 @@ package org.eclipse.jgit.pgm.opt; import java.io.File; import java.io.IOException; +import java.text.MessageFormat; import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.CmdLineParser; @@ -59,6 +60,7 @@ import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.WindowCursor; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.treewalk.AbstractTreeIterator; import org.eclipse.jgit.treewalk.CanonicalTreeParser; import org.eclipse.jgit.treewalk.FileTreeIterator; @@ -102,7 +104,7 @@ public class AbstractTreeIteratorHandler extends try { dirc = DirCache.read(new File(name)); } catch (IOException e) { - throw new CmdLineException(name + " is not an index file", e); + throw new CmdLineException(MessageFormat.format(CLIText.get().notAnIndexFile, name), e); } setter.addValue(new DirCacheIterator(dirc)); return 1; @@ -115,19 +117,18 @@ public class AbstractTreeIteratorHandler extends throw new CmdLineException(e.getMessage()); } if (id == null) - throw new CmdLineException(name + " is not a tree"); + throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); final CanonicalTreeParser p = new CanonicalTreeParser(); final WindowCursor curs = new WindowCursor(); try { p.reset(clp.getRepository(), clp.getRevWalk().parseTree(id), curs); } catch (MissingObjectException e) { - throw new CmdLineException(name + " is not a tree"); + throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); } catch (IncorrectObjectTypeException e) { - throw new CmdLineException(name + " is not a tree"); + throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); } catch (IOException e) { - throw new CmdLineException("cannot read " + name + ": " - + e.getMessage()); + throw new CmdLineException(MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage())); } finally { curs.release(); } @@ -138,6 +139,6 @@ public class AbstractTreeIteratorHandler extends @Override public String getDefaultMetaVariable() { - return "tree-ish"; + return CLIText.get().metaVar_treeish; } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java index a126fb1d85..7e61fb0418 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java @@ -51,6 +51,7 @@ import org.kohsuke.args4j.IllegalAnnotationError; import org.kohsuke.args4j.Option; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.pgm.TextBuiltin; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevTree; @@ -149,7 +150,7 @@ public class CmdLineParser extends org.kohsuke.args4j.CmdLineParser { */ public Repository getRepository() { if (db == null) - throw new IllegalStateException("No Git repository configured."); + throw new IllegalStateException(CLIText.get().noGitRepositoryConfigured); return db; } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/ObjectIdHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/ObjectIdHandler.java index d3f460c89d..f6550a5d88 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/ObjectIdHandler.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/ObjectIdHandler.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.pgm.opt; import java.io.IOException; +import java.text.MessageFormat; import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.CmdLineParser; @@ -53,6 +54,7 @@ import org.kohsuke.args4j.spi.OptionHandler; import org.kohsuke.args4j.spi.Parameters; import org.kohsuke.args4j.spi.Setter; import org.eclipse.jgit.lib.ObjectId; +import org.eclipse.jgit.pgm.CLIText; /** * Custom argument handler {@link ObjectId} from string values. @@ -91,11 +93,11 @@ public class ObjectIdHandler extends OptionHandler<ObjectId> { return 1; } - throw new CmdLineException(name + " is not an object"); + throw new CmdLineException(MessageFormat.format(CLIText.get().notAnObject, name)); } @Override public String getDefaultMetaVariable() { - return "object"; + return CLIText.get().metaVar_object; } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/PathTreeFilterHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/PathTreeFilterHandler.java index bebf3d9a7d..50ff02aca9 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/PathTreeFilterHandler.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/PathTreeFilterHandler.java @@ -53,6 +53,7 @@ import org.kohsuke.args4j.OptionDef; import org.kohsuke.args4j.spi.OptionHandler; import org.kohsuke.args4j.spi.Parameters; import org.kohsuke.args4j.spi.Setter; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.treewalk.filter.PathFilter; import org.eclipse.jgit.treewalk.filter.PathFilterGroup; import org.eclipse.jgit.treewalk.filter.TreeFilter; @@ -103,6 +104,6 @@ public class PathTreeFilterHandler extends OptionHandler<TreeFilter> { @Override public String getDefaultMetaVariable() { - return "path ..."; + return CLIText.get().metaVar_paths; } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RefSpecHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RefSpecHandler.java index 133c5f8db8..43b727ac02 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RefSpecHandler.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RefSpecHandler.java @@ -49,6 +49,7 @@ import org.kohsuke.args4j.OptionDef; import org.kohsuke.args4j.spi.OptionHandler; import org.kohsuke.args4j.spi.Parameters; import org.kohsuke.args4j.spi.Setter; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.transport.RefSpec; /** @@ -79,6 +80,6 @@ public class RefSpecHandler extends OptionHandler<RefSpec> { @Override public String getDefaultMetaVariable() { - return "refspec"; + return CLIText.get().metaVar_refspec; } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevCommitHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevCommitHandler.java index 01caaf2018..bf1753634c 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevCommitHandler.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevCommitHandler.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.pgm.opt; import java.io.IOException; +import java.text.MessageFormat; import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.CmdLineParser; @@ -55,6 +56,7 @@ import org.kohsuke.args4j.spi.Setter; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.lib.ObjectId; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevFlag; @@ -94,8 +96,8 @@ public class RevCommitHandler extends OptionHandler<RevCommit> { final int dot2 = name.indexOf(".."); if (dot2 != -1) { if (!option.isMultiValued()) - throw new CmdLineException("Only one " + option.metaVar() - + " expected in " + name + "." + ""); + throw new CmdLineException(MessageFormat.format(CLIText.get().onlyOneMetaVarExpectedIn + , option.metaVar(), name)); final String left = name.substring(0, dot2); final String right = name.substring(dot2 + 2); @@ -117,18 +119,17 @@ public class RevCommitHandler extends OptionHandler<RevCommit> { throw new CmdLineException(e.getMessage()); } if (id == null) - throw new CmdLineException(name + " is not a commit"); + throw new CmdLineException(MessageFormat.format(CLIText.get().notACommit, name)); final RevCommit c; try { c = clp.getRevWalk().parseCommit(id); } catch (MissingObjectException e) { - throw new CmdLineException(name + " is not a commit"); + throw new CmdLineException(MessageFormat.format(CLIText.get().notACommit, name)); } catch (IncorrectObjectTypeException e) { - throw new CmdLineException(name + " is not a commit"); + throw new CmdLineException(MessageFormat.format(CLIText.get().notACommit, name)); } catch (IOException e) { - throw new CmdLineException("cannot read " + name + ": " - + e.getMessage()); + throw new CmdLineException(MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage())); } if (interesting) @@ -141,6 +142,6 @@ public class RevCommitHandler extends OptionHandler<RevCommit> { @Override public String getDefaultMetaVariable() { - return "commit-ish"; + return CLIText.get().metaVar_commitish; } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevTreeHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevTreeHandler.java index c564b9b011..0b607ee06f 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevTreeHandler.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevTreeHandler.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.pgm.opt; import java.io.IOException; +import java.text.MessageFormat; import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.CmdLineParser; @@ -55,6 +56,7 @@ import org.kohsuke.args4j.spi.Setter; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.lib.ObjectId; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.revwalk.RevTree; /** @@ -90,18 +92,17 @@ public class RevTreeHandler extends OptionHandler<RevTree> { throw new CmdLineException(e.getMessage()); } if (id == null) - throw new CmdLineException(name + " is not a tree"); + throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); final RevTree c; try { c = clp.getRevWalk().parseTree(id); } catch (MissingObjectException e) { - throw new CmdLineException(name + " is not a tree"); + throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); } catch (IncorrectObjectTypeException e) { - throw new CmdLineException(name + " is not a tree"); + throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); } catch (IOException e) { - throw new CmdLineException("cannot read " + name + ": " - + e.getMessage()); + throw new CmdLineException(MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage())); } setter.addValue(c); return 1; @@ -109,6 +110,6 @@ public class RevTreeHandler extends OptionHandler<RevTree> { @Override public String getDefaultMetaVariable() { - return "tree-ish"; + return CLIText.get().metaVar_treeish; } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/SubcommandHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/SubcommandHandler.java index 3378f38c19..35ed22bd30 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/SubcommandHandler.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/SubcommandHandler.java @@ -51,6 +51,7 @@ import org.kohsuke.args4j.OptionDef; import org.kohsuke.args4j.spi.OptionHandler; import org.kohsuke.args4j.spi.Parameters; import org.kohsuke.args4j.spi.Setter; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.pgm.CommandCatalog; import org.eclipse.jgit.pgm.CommandRef; import org.eclipse.jgit.pgm.TextBuiltin; @@ -82,7 +83,7 @@ public class SubcommandHandler extends OptionHandler<TextBuiltin> { final CommandRef cr = CommandCatalog.get(name); if (cr == null) throw new CmdLineException(MessageFormat.format( - "{0} is not a jgit command", name)); + CLIText.get().notAJgitCommand, name)); // Force option parsing to stop. Everything after us should // be arguments known only to this command and must not be @@ -95,6 +96,6 @@ public class SubcommandHandler extends OptionHandler<TextBuiltin> { @Override public String getDefaultMetaVariable() { - return "command"; + return CLIText.get().metaVar_command; } } diff --git a/org.eclipse.jgit.test/META-INF/MANIFEST.MF b/org.eclipse.jgit.test/META-INF/MANIFEST.MF index d5eccecb08..b3799fb51e 100644 --- a/org.eclipse.jgit.test/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.test/META-INF/MANIFEST.MF @@ -10,15 +10,21 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5 Import-Package: junit.framework;version="[3.8.2,4.0.0)", junit.textui;version="[3.8.2,4.0.0)", org.eclipse.jgit.api;version="[0.8.0,0.9.0)", + org.eclipse.jgit;version="[0.8.0,0.9.0)", + org.eclipse.jgit.awtui;version="[0.8.0,0.9.0)", + org.eclipse.jgit.console;version="[0.8.0,0.9.0)", org.eclipse.jgit.diff;version="[0.8.0,0.9.0)", org.eclipse.jgit.dircache;version="[0.8.0,0.9.0)", org.eclipse.jgit.errors;version="[0.8.0,0.9.0)", org.eclipse.jgit.fnmatch;version="[0.8.0,0.9.0)", + org.eclipse.jgit.http.server;version="[0.8.0,0.9.0)", + org.eclipse.jgit.iplog;version="[0.8.0,0.9.0)", org.eclipse.jgit.junit;version="[0.8.0,0.9.0)", org.eclipse.jgit.lib;version="[0.8.0,0.9.0)", org.eclipse.jgit.merge;version="[0.8.0,0.9.0)", org.eclipse.jgit.nls;version="[0.8.0,0.9.0)", org.eclipse.jgit.patch;version="[0.8.0,0.9.0)", + org.eclipse.jgit.pgm;version="[0.8.0,0.9.0)", org.eclipse.jgit.revplot;version="[0.8.0,0.9.0)", org.eclipse.jgit.revwalk;version="[0.8.0,0.9.0)", org.eclipse.jgit.revwalk.filter;version="[0.8.0,0.9.0)", diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java index 2e470b386b..387a381893 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java @@ -44,8 +44,11 @@ package org.eclipse.jgit.lib; +import java.text.MessageFormat; + import junit.framework.TestCase; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.CorruptObjectException; public class ObjectCheckerTest extends TestCase { @@ -62,7 +65,7 @@ public class ObjectCheckerTest extends TestCase { fail("Did not throw CorruptObjectException"); } catch (CorruptObjectException e) { final String m = e.getMessage(); - assertEquals("Invalid object type: " + Constants.OBJ_BAD, m); + assertEquals(MessageFormat.format(JGitText.get().corruptObjectInvalidType2, Constants.OBJ_BAD), m); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/nls/TestNLS.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/nls/TestNLS.java index a01ed4e923..8b02f2f5e9 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/nls/TestNLS.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/nls/TestNLS.java @@ -55,23 +55,23 @@ public class TestNLS extends TestCase { public void testNLSLocale() { NLS.setLocale(NLS.ROOT_LOCALE); GermanTranslatedBundle bundle = GermanTranslatedBundle.get(); - assertEquals(NLS.ROOT_LOCALE, bundle.getEffectiveLocale()); + assertEquals(NLS.ROOT_LOCALE, bundle.effectiveLocale()); NLS.setLocale(Locale.GERMAN); bundle = GermanTranslatedBundle.get(); - assertEquals(Locale.GERMAN, bundle.getEffectiveLocale()); + assertEquals(Locale.GERMAN, bundle.effectiveLocale()); } public void testJVMDefaultLocale() { Locale.setDefault(NLS.ROOT_LOCALE); NLS.useJVMDefaultLocale(); GermanTranslatedBundle bundle = GermanTranslatedBundle.get(); - assertEquals(NLS.ROOT_LOCALE, bundle.getEffectiveLocale()); + assertEquals(NLS.ROOT_LOCALE, bundle.effectiveLocale()); Locale.setDefault(Locale.GERMAN); NLS.useJVMDefaultLocale(); bundle = GermanTranslatedBundle.get(); - assertEquals(Locale.GERMAN, bundle.getEffectiveLocale()); + assertEquals(Locale.GERMAN, bundle.effectiveLocale()); } public void testThreadTranslationBundleInheritance() throws InterruptedException { @@ -135,7 +135,7 @@ public class TestNLS extends TestCase { assertNull("t1 was interrupted or barrier was broken", t1.e); assertNull("t2 was interrupted or barrier was broken", t2.e); - assertEquals(NLS.ROOT_LOCALE, t1.bundle.getEffectiveLocale()); - assertEquals(Locale.GERMAN, t2.bundle.getEffectiveLocale()); + assertEquals(NLS.ROOT_LOCALE, t1.bundle.effectiveLocale()); + assertEquals(Locale.GERMAN, t2.bundle.effectiveLocale()); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/nls/TestTranslationBundle.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/nls/TestTranslationBundle.java index 7d713f2c1a..0b21bdbe0a 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/nls/TestTranslationBundle.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/nls/TestTranslationBundle.java @@ -79,15 +79,15 @@ public class TestTranslationBundle extends TestCase { NonTranslatedBundle bundle = new NonTranslatedBundle(); bundle.load(NLS.ROOT_LOCALE); - assertEquals(NLS.ROOT_LOCALE, bundle.getEffectiveLocale()); + assertEquals(NLS.ROOT_LOCALE, bundle.effectiveLocale()); assertEquals("Good morning {0}", bundle.goodMorning); bundle.load(Locale.ENGLISH); - assertEquals(NLS.ROOT_LOCALE, bundle.getEffectiveLocale()); + assertEquals(NLS.ROOT_LOCALE, bundle.effectiveLocale()); assertEquals("Good morning {0}", bundle.goodMorning); bundle.load(Locale.GERMAN); - assertEquals(NLS.ROOT_LOCALE, bundle.getEffectiveLocale()); + assertEquals(NLS.ROOT_LOCALE, bundle.effectiveLocale()); assertEquals("Good morning {0}", bundle.goodMorning); } @@ -95,11 +95,11 @@ public class TestTranslationBundle extends TestCase { GermanTranslatedBundle bundle = new GermanTranslatedBundle(); bundle.load(NLS.ROOT_LOCALE); - assertEquals(NLS.ROOT_LOCALE, bundle.getEffectiveLocale()); + assertEquals(NLS.ROOT_LOCALE, bundle.effectiveLocale()); assertEquals("Good morning {0}", bundle.goodMorning); bundle.load(Locale.GERMAN); - assertEquals(Locale.GERMAN, bundle.getEffectiveLocale()); + assertEquals(Locale.GERMAN, bundle.effectiveLocale()); assertEquals("Guten Morgen {0}", bundle.goodMorning); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/PatchCcErrorTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/PatchCcErrorTest.java index f2bae6eb19..87bd9d386d 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/PatchCcErrorTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/PatchCcErrorTest.java @@ -45,6 +45,9 @@ package org.eclipse.jgit.patch; import java.io.IOException; import java.io.InputStream; +import java.text.MessageFormat; + +import org.eclipse.jgit.JGitText; import junit.framework.TestCase; @@ -57,7 +60,7 @@ public class PatchCcErrorTest extends TestCase { final FormatError e = p.getErrors().get(0); assertSame(FormatError.Severity.ERROR, e.getSeverity()); assertEquals( - "Truncated hunk, at least 1 lines is missing for ancestor 1", + MessageFormat.format(JGitText.get().truncatedHunkLinesMissingForAncestor, 1, 1), e.getMessage()); assertEquals(346, e.getOffset()); assertTrue(e.getLineText().startsWith( @@ -67,7 +70,7 @@ public class PatchCcErrorTest extends TestCase { final FormatError e = p.getErrors().get(1); assertSame(FormatError.Severity.ERROR, e.getSeverity()); assertEquals( - "Truncated hunk, at least 2 lines is missing for ancestor 2", + MessageFormat.format(JGitText.get().truncatedHunkLinesMissingForAncestor, 2, 2), e.getMessage()); assertEquals(346, e.getOffset()); assertTrue(e.getLineText().startsWith( diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java index 61c894e414..156e4d0230 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java @@ -53,9 +53,11 @@ import static org.eclipse.jgit.transport.SideBandOutputStream.SMALL_BUF; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.text.MessageFormat; import junit.framework.TestCase; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.lib.Constants; // Note, test vectors created with: @@ -221,8 +223,7 @@ public class SideBandOutputStreamTest extends TestCase { new SideBandOutputStream(CH_DATA, Integer.MAX_VALUE, rawOut); fail("Accepted " + Integer.MAX_VALUE + " for buffer size"); } catch (IllegalArgumentException e) { - assertEquals("packet size " + Integer.MAX_VALUE - + " must be <= 65520", e.getMessage()); + assertEquals(MessageFormat.format(JGitText.get().packetSizeMustBeAtMost, Integer.MAX_VALUE, 65520), e.getMessage()); } } diff --git a/org.eclipse.jgit.ui/.classpath b/org.eclipse.jgit.ui/.classpath index 64c5e31b7a..b3d21cc667 100644 --- a/org.eclipse.jgit.ui/.classpath +++ b/org.eclipse.jgit.ui/.classpath @@ -3,5 +3,6 @@ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="resources"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/org.eclipse.jgit.ui/META-INF/MANIFEST.MF b/org.eclipse.jgit.ui/META-INF/MANIFEST.MF index b496cd08dd..fe2f476b2e 100644 --- a/org.eclipse.jgit.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.ui/META-INF/MANIFEST.MF @@ -8,6 +8,7 @@ Bundle-Vendor: %provider_name Bundle-RequiredExecutionEnvironment: J2SE-1.5 Export-Package: org.eclipse.jgit.awtui;version="0.8.0" Import-Package: org.eclipse.jgit.lib;version="[0.8.0,0.9.0)", + org.eclipse.jgit.nls;version="[0.8.0,0.9.0)", org.eclipse.jgit.revplot;version="[0.8.0,0.9.0)", org.eclipse.jgit.revwalk;version="[0.8.0,0.9.0)", org.eclipse.jgit.transport;version="[0.8.0,0.9.0)", diff --git a/org.eclipse.jgit.ui/pom.xml b/org.eclipse.jgit.ui/pom.xml index 8c452b0a9e..3d96fd1113 100644 --- a/org.eclipse.jgit.ui/pom.xml +++ b/org.eclipse.jgit.ui/pom.xml @@ -84,6 +84,9 @@ <include>plugin.properties</include> </includes> </resource> + <resource> + <directory>resources/</directory> + </resource> </resources> <plugins> diff --git a/org.eclipse.jgit.ui/resources/org/eclipse/jgit/awtui/UIText.properties b/org.eclipse.jgit.ui/resources/org/eclipse/jgit/awtui/UIText.properties new file mode 100644 index 0000000000..0bc5a7acbc --- /dev/null +++ b/org.eclipse.jgit.ui/resources/org/eclipse/jgit/awtui/UIText.properties @@ -0,0 +1,8 @@ +authenticationRequired=Authentication Required +author=Author +date=Date +enterUsernameAndPasswordFor=Enter username and password for +mustBeSpecialTableModel=Must be special table model. +password=Password: +username=Username: +warning=Warning diff --git a/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/AwtAuthenticator.java b/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/AwtAuthenticator.java index 1d2f9d765c..6728d616da 100644 --- a/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/AwtAuthenticator.java +++ b/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/AwtAuthenticator.java @@ -74,7 +74,8 @@ public class AwtAuthenticator extends CachedAuthenticator { panel.setLayout(new GridBagLayout()); final StringBuilder instruction = new StringBuilder(); - instruction.append("Enter username and password for "); + instruction.append(UIText.get().enterUsernameAndPasswordFor); + instruction.append(" "); if (getRequestorType() == RequestorType.PROXY) { instruction.append(getRequestorType()); instruction.append(" "); @@ -101,7 +102,7 @@ public class AwtAuthenticator extends CachedAuthenticator { gbc.fill = GridBagConstraints.NONE; gbc.gridx = 0; gbc.weightx = 1; - panel.add(new JLabel("Username:"), gbc); + panel.add(new JLabel(UIText.get().username), gbc); gbc.gridx = 1; gbc.fill = GridBagConstraints.HORIZONTAL; @@ -116,7 +117,7 @@ public class AwtAuthenticator extends CachedAuthenticator { gbc.fill = GridBagConstraints.NONE; gbc.gridx = 0; gbc.weightx = 1; - panel.add(new JLabel("Password:"), gbc); + panel.add(new JLabel(UIText.get().password), gbc); gbc.gridx = 1; gbc.fill = GridBagConstraints.HORIZONTAL; @@ -126,7 +127,7 @@ public class AwtAuthenticator extends CachedAuthenticator { gbc.gridy++; if (JOptionPane.showConfirmDialog(null, panel, - "Authentication Required", JOptionPane.OK_CANCEL_OPTION, + UIText.get().authenticationRequired, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION) { return new PasswordAuthentication(username.getText(), password .getPassword()); diff --git a/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/AwtSshSessionFactory.java b/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/AwtSshSessionFactory.java index f6710854b4..f0de7ceb70 100644 --- a/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/AwtSshSessionFactory.java +++ b/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/AwtSshSessionFactory.java @@ -96,7 +96,7 @@ public class AwtSshSessionFactory extends SshConfigSessionFactory { } public boolean promptYesNo(final String msg) { - return JOptionPane.showConfirmDialog(null, msg, "Warning", + return JOptionPane.showConfirmDialog(null, msg, UIText.get().warning, JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION; } diff --git a/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/CommitGraphPane.java b/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/CommitGraphPane.java index da68c81953..effe6e5756 100644 --- a/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/CommitGraphPane.java +++ b/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/CommitGraphPane.java @@ -112,7 +112,7 @@ public class CommitGraphPane extends JTable { @Override public void setModel(final TableModel dataModel) { if (dataModel != null && !(dataModel instanceof CommitTableModel)) - throw new ClassCastException("Must be special table model."); + throw new ClassCastException(UIText.get().mustBeSpecialTableModel); super.setModel(dataModel); } @@ -130,8 +130,8 @@ public class CommitGraphPane extends JTable { final TableColumn date = cols.getColumn(2); graph.setHeaderValue(""); - author.setHeaderValue("Author"); - date.setHeaderValue("Date"); + author.setHeaderValue(UIText.get().author); + date.setHeaderValue(UIText.get().date); graph.setCellRenderer(new GraphCellRender()); author.setCellRenderer(new NameCellRender()); diff --git a/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/UIText.java b/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/UIText.java new file mode 100644 index 0000000000..e1acbcd16e --- /dev/null +++ b/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/UIText.java @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2010, Sasa Zivkov <sasa.zivkov@sap.com> + * and other copyright owners as documented in the project's IP log. + * + * This program and the accompanying materials are made available + * under the terms of the Eclipse Distribution License v1.0 which + * accompanies this distribution, is reproduced below, and is + * available at http://www.eclipse.org/org/documents/edl-v10.php + * + * 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 Eclipse Foundation, Inc. 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.eclipse.jgit.awtui; + +import org.eclipse.jgit.nls.NLS; +import org.eclipse.jgit.nls.TranslationBundle; + +/** + * Translation bundle for JGit UI + */ +public class UIText extends TranslationBundle { + + /** + * @return an instance of this translation bundle + */ + public static UIText get() { + return NLS.getBundleFor(UIText.class); + } + + /***/ public String authenticationRequired; + /***/ public String author; + /***/ public String date; + /***/ public String enterUsernameAndPasswordFor; + /***/ public String mustBeSpecialTableModel; + /***/ public String password; + /***/ public String username; + /***/ public String warning; +} diff --git a/org.eclipse.jgit/.classpath b/org.eclipse.jgit/.classpath index 304e86186a..d7edf529a2 100644 --- a/org.eclipse.jgit/.classpath +++ b/org.eclipse.jgit/.classpath @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="resources"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="output" path="bin"/> diff --git a/org.eclipse.jgit/META-INF/MANIFEST.MF b/org.eclipse.jgit/META-INF/MANIFEST.MF index 7c04302d8b..a5a317b703 100644 --- a/org.eclipse.jgit/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit/META-INF/MANIFEST.MF @@ -5,7 +5,8 @@ Bundle-SymbolicName: org.eclipse.jgit Bundle-Version: 0.8.0.qualifier Bundle-Localization: plugin Bundle-Vendor: %provider_name -Export-Package: org.eclipse.jgit.api;version="0.8.0", +Export-Package: org.eclipse.jgit;version="0.8.0", + org.eclipse.jgit.api;version="0.8.0", org.eclipse.jgit.diff;version="0.8.0", org.eclipse.jgit.dircache;version="0.8.0", org.eclipse.jgit.errors;version="0.8.0", diff --git a/org.eclipse.jgit/pom.xml b/org.eclipse.jgit/pom.xml index e39f1faed1..abb24d14ca 100644 --- a/org.eclipse.jgit/pom.xml +++ b/org.eclipse.jgit/pom.xml @@ -84,6 +84,9 @@ <include>plugin.properties</include> </includes> </resource> + <resource> + <directory>resources/</directory> + </resource> </resources> <plugins> diff --git a/org.eclipse.jgit/resources/org/eclipse/jgit/JGitText.properties b/org.eclipse.jgit/resources/org/eclipse/jgit/JGitText.properties new file mode 100644 index 0000000000..4cdf914163 --- /dev/null +++ b/org.eclipse.jgit/resources/org/eclipse/jgit/JGitText.properties @@ -0,0 +1,360 @@ +DIRCChecksumMismatch=DIRC checksum mismatch +DIRCExtensionIsTooLargeAt=DIRC extension {0} is too large at {1} bytes. +DIRCExtensionNotSupportedByThisVersion=DIRC extension {0} not supported by this version. +DIRCHasTooManyEntries=DIRC has too many entries. +JRELacksMD5Implementation=JRE lacks MD5 implementation +URINotSupported=URI not supported: {0} +URLNotFound={0} not found +aNewObjectIdIsRequired=A NewObjectId is required. +advertisementCameBefore=advertisement of {0}^{} came before {1} +advertisementOfCameBefore=advertisement of {0}^{} came before {1} +amazonS3ActionFailed={0} of '{1}' failed: {2} {3} +amazonS3ActionFailedGivingUp={0} of '{1}' failed: Giving up after {2} attempts. +anExceptionOccurredWhileTryingToAddTheIdOfHEAD=An exception occurred while trying to add the Id of HEAD +anSSHSessionHasBeenAlreadyCreated=An SSH session has been already created +atLeastOnePathIsRequired=At least one path is required. +atLeastTwoFiltersNeeded=At least two filters needed. +badBase64InputCharacterAt=Bad Base64 input character at {0} : {1} (decimal) +badEntryDelimiter=Bad entry delimiter +badEntryName=Bad entry name: {0} +badEscape=Bad escape: {0} +badGroupHeader=Bad group header +badObjectType=Bad object type: {0} +badSectionEntry=Bad section entry: {0} +base64InputNotProperlyPadded=Base64 input not properly padded. +baseLengthIncorrect=base length incorrect +blobNotFound=Blob not found: {0} +blobNotFoundForPath=Blob not found: {0} for path: {1} +cannotBeCombined=Cannot be combined. +cannotCombineTreeFilterWithRevFilter=Cannot combine TreeFilter {0} with RefFilter {1}. +cannotCommitWriteTo=Cannot commit write to {0} +cannotConnectPipes=cannot connect pipes +cannotConvertScriptToText=Cannot convert script to text +cannotCreateConfig=cannot create config +cannotCreateDirectory=Cannot create directory {0} +cannotCreateHEAD=cannot create HEAD +cannotDeleteFile=Cannot delete file: {0} +cannotDeleteStaleTrackingRef2=Cannot delete stale tracking ref {0}: {1} +cannotDeleteStaleTrackingRef=Cannot delete stale tracking ref {0} +cannotDetermineProxyFor=Cannot determine proxy for {0} +cannotDownload=Cannot download {0} +cannotExecute=cannot execute: {0} +cannotGet=Cannot get {0} +cannotListRefs=cannot list refs +cannotLock=Cannot lock {0} +cannotLockFile=Cannot lock file {0} +cannotLockPackIn=Cannot lock pack in {0} +cannotMatchOnEmptyString=Cannot match on empty string. +cannotMoveIndexTo=Cannot move index to {0} +cannotMovePackTo=Cannot move pack to {0} +cannotOpenService=cannot open {0} +cannotParseGitURIish=Cannot parse Git URI-ish +cannotRead=Cannot read {0} +cannotReadBlob=Cannot read blob {0} +cannotReadCommit=Cannot read commit {0} +cannotReadFile=Cannot read file {0} +cannotReadHEAD=cannot read HEAD: {0} {1} +cannotReadObject=Cannot read object +cannotReadTree=Cannot read tree {0} +cannotResolveLocalTrackingRefForUpdating=Cannot resolve local tracking ref {0} for updating. +cannotStoreObjects=cannot store objects +cannotUnloadAModifiedTree=Cannot unload a modified tree. +cannotWorkWithOtherStagesThanZeroRightNow=Cannot work with other stages than zero right now. Won't write corrupt index. +cantFindObjectInReversePackIndexForTheSpecifiedOffset=Can't find object in (reverse) pack index for the specified offset {0} +cantPassMeATree=Can't pass me a tree! +channelMustBeInRange0_255=channel {0} must be in range [0, 255] +characterClassIsNotSupported=The character class {0} is not supported. +checkoutConflictWithFile=Checkout conflict with file: {0} +checkoutConflictWithFiles=Checkout conflict with files: {0} +classCastNotA=Not a {0} +collisionOn=Collision on {0} +commandWasCalledInTheWrongState=Command {0} was called in the wrong state +commitAlreadyExists=exists {0} +commitMessageNotSpecified=commit message not specified +commitOnRepoWithoutHEADCurrentlyNotSupported=Commit on repo without HEAD currently not supported +compressingObjects=Compressing objects +connectionFailed=connection failed +connectionTimeOut=Connection time out: {0} +contextMustBeNonNegative=context must be >= 0 +corruptObjectBadStream=bad stream +corruptObjectBadStreamCorruptHeader=bad stream, corrupt header +corruptObjectGarbageAfterSize=garbage after size +corruptObjectIncorrectLength=incorrect length +corruptObjectInvalidEntryMode=invalid entry mode +corruptObjectInvalidMode2=invalid mode {0} +corruptObjectInvalidMode3=invalid mode {0} for {1} '{2}' in {3}. +corruptObjectInvalidMode=invalid mode +corruptObjectInvalidType2=invalid type {0} +corruptObjectInvalidType=invalid type +corruptObjectMalformedHeader=malformed header: {0} +corruptObjectNegativeSize=negative size +corruptObjectNoAuthor=no author +corruptObjectNoCommitter=no committer +corruptObjectNoHeader=no header +corruptObjectNoObject=no object +corruptObjectNoTagName=no tag name +corruptObjectNoTaggerBadHeader=no tagger/bad header +corruptObjectNoTaggerHeader=no tagger header +corruptObjectNoType=no type +corruptObjectNotree=no tree +corruptObjectPackfileChecksumIncorrect=Packfile checksum incorrect. +corruptionDetectedReReadingAt=Corruption detected re-reading at {0} +couldNotDeleteLockFileShouldNotHappen=Could not delete lock file. Should not happen +couldNotDeleteTemporaryIndexFileShouldNotHappen=Could not delete temporary index file. Should not happen +couldNotLockHEAD=Could not lock HEAD +couldNotReadIndexInOneGo=Could not read index in one go, only {0} out of {1} read +couldNotRenameDeleteOldIndex=Could not rename delete old index +couldNotRenameTemporaryIndexFileToIndex=Could not rename temporary index file to index +couldNotURLEncodeToUTF8=Could not URL encode to UTF-8 +couldNotWriteFile=Could not write file {0} +countingObjects=Counting objects +creatingDeltasIsNotImplemented=creating deltas is not implemented +daemonAlreadyRunning=Daemon already running +deletingNotSupported=Deleting {0} not supported. +destinationIsNotAWildcard=Destination is not a wildcard. +dirCacheDoesNotHaveABackingFile=DirCache does not have a backing file +dirCacheFileIsNotLocked=DirCache {0} not locked +dirCacheIsNotLocked=DirCache is not locked +doesNotHandleMode=Does not handle mode {0} ({1}) +downloadCancelled=Download cancelled +downloadCancelledDuringIndexing=Download cancelled during indexing +duplicateAdvertisementsOf=duplicate advertisements of {0} +duplicateRef=Duplicate ref: {0} +duplicateRemoteRefUpdateIsIllegal=Duplicate remote ref update is illegal. Affected remote name: {0} +duplicateStagesNotAllowed=Duplicate stages not allowed +eitherGIT_DIRorGIT_WORK_TREEmustBePassed=Either GIT_DIR or GIT_WORK_TREE must be passed to Repository constructor +emptyPathNotPermitted=Empty path not permitted. +encryptionError=Encryption error: {0} +endOfFileInEscape=End of file in escape +entryNotFoundByPath=Entry not found by path: {0} +errorDecodingFromFile=Error decoding from file {0} +errorEncodingFromFile=Error encoding from file {0} +errorInBase64CodeReadingStream=Error in Base64 code reading stream. +errorInPackedRefs=error in packed-refs +errorInvalidProtocolWantedOldNewRef=error: invalid protocol: wanted 'old new ref' +errorListing=Error listing {0} +errorOccurredDuringUnpackingOnTheRemoteEnd=error occurred during unpacking on the remote end: {0} +errorReadingInfoRefs=error reading info/refs +exceptionCaughtDuringExecutionOfCommitCommand=Exception caught during execution of commit command +exceptionOccuredDuringAddingOfOptionToALogCommand=Exception occured during adding of {0} as option to a Log command +expectedACKNAKFoundEOF=Expected ACK/NAK, found EOF +expectedACKNAKGot=Expected ACK/NAK, got: {0} +expectedBooleanStringValue=Expected boolean string value +expectedCharacterEncodingGuesses=Expected {0} character encoding guesses +expectedEOFReceived=expected EOF; received '{0}' instead +expectedGot=expected '{0}', got '{1}' +expectedPktLineWithService=expected pkt-line with '# service=-', got '{0}' +expectedReceivedContentType=expected Content-Type {0}; received Content-Type {1} +expectedReportForRefNotReceived={0}: expected report for ref {1} not received +failedUpdatingRefs=failed updating refs +failureDueToOneOfTheFollowing=Failure due to one of the following: +failureUpdatingFETCH_HEAD=Failure updating FETCH_HEAD: {0} +failureUpdatingTrackingRef=Failure updating tracking ref {0}: {1} +fileCannotBeDeleted=File cannot be deleted: {0} +fileIsTooBigForThisConvenienceMethod=File is too big for this convenience method ({0} bytes). +fileIsTooLarge=File is too large: {0} +fileModeNotSetForPath=FileMode not set for path {0} +flagIsDisposed={0} is disposed. +flagNotFromThis={0} not from this. +flagsAlreadyCreated={0} flags already created. +funnyRefname=funny refname +hugeIndexesAreNotSupportedByJgitYet=Huge indexes are not supported by jgit, yet +hunkBelongsToAnotherFile=Hunk belongs to another file +hunkDisconnectedFromFile=Hunk disconnected from file +hunkHeaderDoesNotMatchBodyLineCountOf=Hunk header {0} does not match body line count of {1} +illegalArgumentNotA=Not {0} +illegalStateExists=exists {0} +improperlyPaddedBase64Input=Improperly padded Base64 input. +inMemoryBufferLimitExceeded=In-memory buffer limit exceeded +incorrectHashFor=Incorrect hash for {0}; computed {1} as a {2} from {3} bytes. +incorrectOBJECT_ID_LENGTH=Incorrect OBJECT_ID_LENGTH. +incorrectObjectType_COMMITnorTREEnorBLOBnorTAG=COMMIT nor TREE nor BLOB nor TAG +indexFileIsInUse=Index file is in use +indexFileIsTooLargeForJgit=Index file is too large for jgit +indexSignatureIsInvalid=Index signature is invalid: {0} +integerValueOutOfRange=Integer value {0}.{1} out of range +internalRevisionError=internal revision error +interruptedWriting=Interrupted writing {0} +invalidAdvertisementOf=invalid advertisement of {0} +invalidAncestryLength=Invalid ancestry length +invalidBooleanValue=Invalid boolean value: {0}.{1}={2} +invalidChannel=Invalid channel {0} +invalidCharacterInBase64Data=Invalid character in Base64 data. +invalidCommitParentNumber=Invalid commit parent number +invalidEncryption=Invalid encryption +invalidGitType=invalid git type: {0} +invalidId=Invalid id {0} +invalidIdLength=Invalid id length {0}; should be {1} +invalidIntegerValue=Invalid integer value: {0}.{1}={2} +invalidKey=Invalid key: {0} +invalidLineInConfigFile=Invalid line in config file +invalidModeFor=Invalid mode {0} for {1} {2} in {3}. +invalidModeForPath=Invalid mode {0} for path {1} +invalidObject=Invalid {0} {1}:{2} +invalidOldIdSent=invalid old id sent +invalidPacketLineHeader=Invalid packet line header: {0} +invalidPath=Invalid path: {0} +invalidRefName=Invalid ref name: {0} +invalidStageForPath=Invalid stage {0} for path {1} +invalidTagOption=Invalid tag option: {0} +invalidTimeout=Invalid timeout: {0} +invalidURL=Invalid URL {0} +invalidWildcards=Invalid wildcards {0} +invalidWindowSize=Invalid window size +isAStaticFlagAndHasNorevWalkInstance={0} is a static flag and has no RevWalk instance +kNotInRange=k {0} not in {1} - {2} +lengthExceedsMaximumArraySize=Length exceeds maximum array size +listingAlternates=Listing alternates +localObjectsIncomplete=Local objects incomplete. +localRefIsMissingObjects=Local ref {0} is missing object(s). +lockCountMustBeGreaterOrEqual1=lockCount must be >= 1 +lockError=lock error: {0} +lockOnNotClosed=Lock on {0} not closed. +lockOnNotHeld=Lock on {0} not held. +malformedpersonIdentString=Malformed PersonIdent string (no < was found): {0} +mergeStrategyAlreadyExistsAsDefault=Merge strategy "{0}" already exists as a default strategy +missingAccesskey=Missing accesskey. +missingForwardImageInGITBinaryPatch=Missing forward-image in GIT binary patch +missingObject=Missing {0} {1} +missingPrerequisiteCommits=missing prerequisite commits: +missingSecretkey=Missing secretkey. +mixedStagesNotAllowed=Mixed stages not allowed +multipleMergeBasesFor=Multiple merge bases for:\n {0}\n {1} found:\n {2}\n {3} +need2Arguments=Need 2 arguments +needPackOut=need packOut +needsAtLeastOneEntry=Needs at least one entry +needsWorkdir=Needs workdir +newlineInQuotesNotAllowed=Newline in quotes not allowed +noApplyInDelete=No apply in delete +noClosingBracket=No closing {0} found for {1} at index {2}. +noHEADExistsAndNoExplicitStartingRevisionWasSpecified=No HEAD exists and no explicit starting revision was specified +noHMACsupport=No {0} support: {1} +noSuchRef=no such ref +noXMLParserAvailable=No XML parser available. +notABoolean=Not a boolean: {0} +notABundle=not a bundle +notADIRCFile=Not a DIRC file. +notAGitDirectory=not a git directory +notAPACKFile=Not a PACK file. +notARef=Not a ref: {0}: {1} +notASCIIString=Not ASCII string: {0} +notAValidPack=Not a valid pack {0} +notFound=not found. +notValid={0} not valid +nothingToFetch=Nothing to fetch. +nothingToPush=Nothing to push. +objectAtHasBadZlibStream=Object at {0} in {1} has bad zlib stream +objectAtPathDoesNotHaveId=Object at path "{0}" does not have an id assigned. All object ids must be assigned prior to writing a tree. +objectIsCorrupt=Object {0} is corrupt: {1} +objectIsNotA=Object {0} is not a {1}. +objectNotFoundIn=Object {0} not found in {1}. +offsetWrittenDeltaBaseForObjectNotFoundInAPack=Offset-written delta base for object not found in a pack +onlyOneFetchSupported=Only one fetch supported +onlyOneOperationCallPerConnectionIsSupported=Only one operation call per connection is supported. +openFilesMustBeAtLeast1=Open files must be >= 1 +openingConnection=Opening connection +outputHasAlreadyBeenStarted=Output has already been started. +packChecksumMismatch=Pack checksum mismatch +packCorruptedWhileWritingToFilesystem=Pack corrupted while writing to filesystem +packDoesNotMatchIndex=Pack {0} does not match index +packFileInvalid=Pack file invalid: {0} +packHasUnresolvedDeltas=pack has unresolved deltas +packObjectCountMismatch=Pack object count mismatch: pack {0} index {1}: {2} +packTooLargeForIndexVersion1=Pack too large for index version 1 +packetSizeMustBeAtLeast=packet size {0} must be >= {1} +packetSizeMustBeAtMost=packet size {0} must be <= {1} +packfileCorruptionDetected=Packfile corruption detected: {0} +packfileIsTruncated=Packfile is truncated. +packingCancelledDuringObjectsWriting=Packing cancelled during objects writing +pathIsNotInWorkingDir=Path is not in working dir +peeledLineBeforeRef=Peeled line before ref. +peeledLineBeforeRef=Peeled line before ref. +peerDidNotSupplyACompleteObjectGraph=peer did not supply a complete object graph +prefixRemote=remote: +problemWithResolvingPushRefSpecsLocally=Problem with resolving push ref specs locally: {0} +progressMonUploading=Uploading {0} +propertyIsAlreadyNonNull=Property is already non null +pushCancelled=push cancelled +pushIsNotSupportedForBundleTransport=Push is not supported for bundle transport +pushNotPermitted=push not permitted +rawLogMessageDoesNotParseAsLogEntry=Raw log message does not parse as log entry +readTimedOut=Read timed out +readingObjectsFromLocalRepositoryFailed=reading objects from local repository failed: {0} +receivingObjects=Receiving objects +refUpdateReturnCodeWas=RefUpdate return code was: {0} +reflogsNotYetSupportedByRevisionParser=reflogs not yet supported by revision parser +remoteConfigHasNoURIAssociated=Remote config "{0}" has no URIs associated +remoteDoesNotHaveSpec=Remote does not have {0} available for fetch. +remoteDoesNotSupportSmartHTTPPush=remote does not support smart HTTP push +remoteHungUpUnexpectedly=remote hung up unexpectedly +remoteNameCantBeNull=Remote name can't be null. +repositoryAlreadyExists=Repository already exists: {0} +repositoryNotFound=repository not found: {0} +requiredHashFunctionNotAvailable=Required hash function {0} not available. +resolvingDeltas=Resolving deltas +serviceNotPermitted={0} not permitted +shortCompressedStreamAt=Short compressed stream at {0} +shortReadOfBlock=Short read of block. +shortReadOfOptionalDIRCExtensionExpectedAnotherBytes=Short read of optional DIRC extension {0}; expected another {1} bytes within the section. +shortSkipOfBlock=Short skip of block. +smartHTTPPushDisabled=smart HTTP push disabled +sourceDestinationMustMatch=Source/Destination must match. +sourceIsNotAWildcard=Source is not a wildcard. +sourceRefDoesntResolveToAnyObject=Source ref {0} doesn't resolve to any object. +sourceRefNotSpecifiedForRefspec=Source ref not specified for refspec: {0} +staleRevFlagsOn=Stale RevFlags on {0} +startingReadStageWithoutWrittenRequestDataPendingIsNotSupported=Starting read stage without written request data pending is not supported +statelessRPCRequiresOptionToBeEnabled=stateless RPC requires {0} to be enabled +symlinkCannotBeWrittenAsTheLinkTarget=Symlink "{0}" cannot be written as the link target cannot be read from within Java. +tSizeMustBeGreaterOrEqual1=tSize must be >= 1 +theFactoryMustNotBeNull=The factory must not be null +timerAlreadyTerminated=Timer already terminated +topologicalSortRequired=Topological sort required. +transportExceptionBadRef=Empty ref: {0}: {1} +transportExceptionEmptyRef=Empty ref: {0} +transportExceptionInvalid=Invalid {0} {1}:{2} +transportExceptionMissingAssumed=Missing assumed {0} +transportExceptionReadRef=read {0} +treeEntryAlreadyExists=Tree entry "{0}" already exists. +treeIteratorDoesNotSupportRemove=TreeIterator does not support remove() +truncatedHunkLinesMissingForAncestor=Truncated hunk, at least {0} lines missing for ancestor {1} +truncatedHunkNewLinesMissing=Truncated hunk, at least {0} new lines is missing +truncatedHunkOldLinesMissing=Truncated hunk, at least {0} old lines is missing +unableToCheckConnectivity=Unable to check connectivity. +unableToLockTag=Unable to lock tag {0} +unableToStore=Unable to store {0}. +unableToWrite=Unable to write {0} +unencodeableFile=Unencodeable file: {0} +unexpectedEndOfConfigFile=Unexpected end of config file +unexpectedHunkTrailer=Unexpected hunk trailer +unexpectedOddResult=odd: {0} + {1} - {2} +unexpectedRefReport={0}: unexpected ref report: {1} +unexpectedReportLine2={0} unexpected report line: {1} +unexpectedReportLine=unexpected report line: {0} +unknownDIRCVersion=Unknown DIRC version {0} +unknownHost=unknown host +unknownIndexVersionOrCorruptIndex=Unknown index version (or corrupt index): {0} +unknownObjectType=Unknown object type {0}. +unknownRepositoryFormat2=Unknown repository format "{0}"; expected "0". +unknownRepositoryFormat=Unknown repository format +unmergedPath=Unmerged path: {0} +unpackError=unpack error {0} +unreadablePackIndex=Unreadable pack index: {0} +unrecognizedRef=Unrecognized ref: {0} +unsupportedCommand0=unsupported command 0 +unsupportedEncryptionAlgorithm=Unsupported encryption algorithm: {0} +unsupportedEncryptionVersion=Unsupported encryption version: {0} +unsupportedOperationNotAddAtEnd=Not add-at-end: {0} +unsupportedPackIndexVersion=Unsupported pack index version {0} +unsupportedPackVersion=Unsupported pack version {0}. +updatingRefFailed=Updating the ref {0} to {1} failed. ReturnCode from RefUpdate.update() was {2} +userConfigFileInvalid=User config file {0} invalid {1} +walkFailure=Walk failure. +windowSizeMustBeLesserThanLimit=Window size must be < limit +windowSizeMustBePowerOf2=Window size must be power of 2 +writeTimedOut=Write timed out +writerAlreadyInitialized=Writer already initialized +writingNotPermitted=Writing not permitted +writingNotSupported=Writing {0} not supported. +writingObjects=Writing objects +wrongDecompressedLength=wrong decompressed length diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java b/org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java new file mode 100644 index 0000000000..fbc17aad8e --- /dev/null +++ b/org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java @@ -0,0 +1,420 @@ +/* + * Copyright (C) 2010, Sasa Zivkov <sasa.zivkov@sap.com> + * and other copyright owners as documented in the project's IP log. + * + * This program and the accompanying materials are made available + * under the terms of the Eclipse Distribution License v1.0 which + * accompanies this distribution, is reproduced below, and is + * available at http://www.eclipse.org/org/documents/edl-v10.php + * + * 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 Eclipse Foundation, Inc. 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.eclipse.jgit; + +import org.eclipse.jgit.nls.NLS; +import org.eclipse.jgit.nls.TranslationBundle; + +/** + * Translation bundle for JGit core + */ +public class JGitText extends TranslationBundle { + + /** + * @return an instance of this translation bundle + */ + public static JGitText get() { + return NLS.getBundleFor(JGitText.class); + } + + /***/ public String DIRCChecksumMismatch; + /***/ public String DIRCExtensionIsTooLargeAt; + /***/ public String DIRCExtensionNotSupportedByThisVersion; + /***/ public String DIRCHasTooManyEntries; + /***/ public String JRELacksMD5Implementation; + /***/ public String URINotSupported; + /***/ public String URLNotFound; + /***/ public String aNewObjectIdIsRequired; + /***/ public String advertisementCameBefore; + /***/ public String advertisementOfCameBefore; + /***/ public String amazonS3ActionFailed; + /***/ public String amazonS3ActionFailedGivingUp; + /***/ public String anExceptionOccurredWhileTryingToAddTheIdOfHEAD; + /***/ public String anSSHSessionHasBeenAlreadyCreated; + /***/ public String atLeastOnePathIsRequired; + /***/ public String atLeastTwoFiltersNeeded; + /***/ public String badBase64InputCharacterAt; + /***/ public String badEntryDelimiter; + /***/ public String badEntryName; + /***/ public String badEscape; + /***/ public String badGroupHeader; + /***/ public String badObjectType; + /***/ public String badSectionEntry; + /***/ public String base64InputNotProperlyPadded; + /***/ public String baseLengthIncorrect; + /***/ public String blobNotFound; + /***/ public String blobNotFoundForPath; + /***/ public String cannotBeCombined; + /***/ public String cannotCombineTreeFilterWithRevFilter; + /***/ public String cannotCommitWriteTo; + /***/ public String cannotConnectPipes; + /***/ public String cannotConvertScriptToText; + /***/ public String cannotCreateConfig; + /***/ public String cannotCreateDirectory; + /***/ public String cannotCreateHEAD; + /***/ public String cannotDeleteFile; + /***/ public String cannotDeleteStaleTrackingRef2; + /***/ public String cannotDeleteStaleTrackingRef; + /***/ public String cannotDetermineProxyFor; + /***/ public String cannotDownload; + /***/ public String cannotExecute; + /***/ public String cannotGet; + /***/ public String cannotListRefs; + /***/ public String cannotLock; + /***/ public String cannotLockFile; + /***/ public String cannotLockPackIn; + /***/ public String cannotMatchOnEmptyString; + /***/ public String cannotMoveIndexTo; + /***/ public String cannotMovePackTo; + /***/ public String cannotOpenService; + /***/ public String cannotParseGitURIish; + /***/ public String cannotRead; + /***/ public String cannotReadBlob; + /***/ public String cannotReadCommit; + /***/ public String cannotReadFile; + /***/ public String cannotReadHEAD; + /***/ public String cannotReadObject; + /***/ public String cannotReadTree; + /***/ public String cannotResolveLocalTrackingRefForUpdating; + /***/ public String cannotStoreObjects; + /***/ public String cannotUnloadAModifiedTree; + /***/ public String cannotWorkWithOtherStagesThanZeroRightNow; + /***/ public String cantFindObjectInReversePackIndexForTheSpecifiedOffset; + /***/ public String cantPassMeATree; + /***/ public String channelMustBeInRange0_255; + /***/ public String characterClassIsNotSupported; + /***/ public String checkoutConflictWithFile; + /***/ public String checkoutConflictWithFiles; + /***/ public String classCastNotA; + /***/ public String collisionOn; + /***/ public String commandWasCalledInTheWrongState; + /***/ public String commitAlreadyExists; + /***/ public String commitMessageNotSpecified; + /***/ public String commitOnRepoWithoutHEADCurrentlyNotSupported; + /***/ public String compressingObjects; + /***/ public String connectionFailed; + /***/ public String connectionTimeOut; + /***/ public String contextMustBeNonNegative; + /***/ public String corruptObjectBadStream; + /***/ public String corruptObjectBadStreamCorruptHeader; + /***/ public String corruptObjectGarbageAfterSize; + /***/ public String corruptObjectIncorrectLength; + /***/ public String corruptObjectInvalidEntryMode; + /***/ public String corruptObjectInvalidMode2; + /***/ public String corruptObjectInvalidMode3; + /***/ public String corruptObjectInvalidMode; + /***/ public String corruptObjectInvalidType2; + /***/ public String corruptObjectInvalidType; + /***/ public String corruptObjectMalformedHeader; + /***/ public String corruptObjectNegativeSize; + /***/ public String corruptObjectNoAuthor; + /***/ public String corruptObjectNoCommitter; + /***/ public String corruptObjectNoHeader; + /***/ public String corruptObjectNoObject; + /***/ public String corruptObjectNoTagName; + /***/ public String corruptObjectNoTaggerBadHeader; + /***/ public String corruptObjectNoTaggerHeader; + /***/ public String corruptObjectNoType; + /***/ public String corruptObjectNotree; + /***/ public String corruptObjectPackfileChecksumIncorrect; + /***/ public String corruptionDetectedReReadingAt; + /***/ public String couldNotDeleteLockFileShouldNotHappen; + /***/ public String couldNotDeleteTemporaryIndexFileShouldNotHappen; + /***/ public String couldNotLockHEAD; + /***/ public String couldNotReadIndexInOneGo; + /***/ public String couldNotRenameDeleteOldIndex; + /***/ public String couldNotRenameTemporaryIndexFileToIndex; + /***/ public String couldNotURLEncodeToUTF8; + /***/ public String couldNotWriteFile; + /***/ public String countingObjects; + /***/ public String creatingDeltasIsNotImplemented; + /***/ public String daemonAlreadyRunning; + /***/ public String deletingNotSupported; + /***/ public String destinationIsNotAWildcard; + /***/ public String dirCacheDoesNotHaveABackingFile; + /***/ public String dirCacheFileIsNotLocked; + /***/ public String dirCacheIsNotLocked; + /***/ public String doesNotHandleMode; + /***/ public String downloadCancelled; + /***/ public String downloadCancelledDuringIndexing; + /***/ public String duplicateAdvertisementsOf; + /***/ public String duplicateRef; + /***/ public String duplicateRemoteRefUpdateIsIllegal; + /***/ public String duplicateStagesNotAllowed; + /***/ public String eitherGIT_DIRorGIT_WORK_TREEmustBePassed; + /***/ public String emptyPathNotPermitted; + /***/ public String encryptionError; + /***/ public String endOfFileInEscape; + /***/ public String entryNotFoundByPath; + /***/ public String errorDecodingFromFile; + /***/ public String errorEncodingFromFile; + /***/ public String errorInBase64CodeReadingStream; + /***/ public String errorInPackedRefs; + /***/ public String errorInvalidProtocolWantedOldNewRef; + /***/ public String errorListing; + /***/ public String errorOccurredDuringUnpackingOnTheRemoteEnd; + /***/ public String errorReadingInfoRefs; + /***/ public String exceptionCaughtDuringExecutionOfCommitCommand; + /***/ public String exceptionOccuredDuringAddingOfOptionToALogCommand; + /***/ public String expectedACKNAKFoundEOF; + /***/ public String expectedACKNAKGot; + /***/ public String expectedBooleanStringValue; + /***/ public String expectedCharacterEncodingGuesses; + /***/ public String expectedEOFReceived; + /***/ public String expectedGot; + /***/ public String expectedPktLineWithService; + /***/ public String expectedReceivedContentType; + /***/ public String expectedReportForRefNotReceived; + /***/ public String failedUpdatingRefs; + /***/ public String failureDueToOneOfTheFollowing; + /***/ public String failureUpdatingFETCH_HEAD; + /***/ public String failureUpdatingTrackingRef; + /***/ public String fileCannotBeDeleted; + /***/ public String fileIsTooBigForThisConvenienceMethod; + /***/ public String fileIsTooLarge; + /***/ public String fileModeNotSetForPath; + /***/ public String flagIsDisposed; + /***/ public String flagNotFromThis; + /***/ public String flagsAlreadyCreated; + /***/ public String funnyRefname; + /***/ public String hugeIndexesAreNotSupportedByJgitYet; + /***/ public String hunkBelongsToAnotherFile; + /***/ public String hunkDisconnectedFromFile; + /***/ public String hunkHeaderDoesNotMatchBodyLineCountOf; + /***/ public String illegalArgumentNotA; + /***/ public String illegalStateExists; + /***/ public String improperlyPaddedBase64Input; + /***/ public String inMemoryBufferLimitExceeded; + /***/ public String incorrectHashFor; + /***/ public String incorrectOBJECT_ID_LENGTH; + /***/ public String incorrectObjectType_COMMITnorTREEnorBLOBnorTAG; + /***/ public String indexFileIsInUse; + /***/ public String indexFileIsTooLargeForJgit; + /***/ public String indexSignatureIsInvalid; + /***/ public String integerValueOutOfRange; + /***/ public String internalRevisionError; + /***/ public String interruptedWriting; + /***/ public String invalidAdvertisementOf; + /***/ public String invalidAncestryLength; + /***/ public String invalidBooleanValue; + /***/ public String invalidChannel; + /***/ public String invalidCharacterInBase64Data; + /***/ public String invalidCommitParentNumber; + /***/ public String invalidEncryption; + /***/ public String invalidGitType; + /***/ public String invalidId; + /***/ public String invalidIdLength; + /***/ public String invalidIntegerValue; + /***/ public String invalidKey; + /***/ public String invalidLineInConfigFile; + /***/ public String invalidModeFor; + /***/ public String invalidModeForPath; + /***/ public String invalidObject; + /***/ public String invalidOldIdSent; + /***/ public String invalidPacketLineHeader; + /***/ public String invalidPath; + /***/ public String invalidRefName; + /***/ public String invalidStageForPath; + /***/ public String invalidTagOption; + /***/ public String invalidTimeout; + /***/ public String invalidURL; + /***/ public String invalidWildcards; + /***/ public String invalidWindowSize; + /***/ public String isAStaticFlagAndHasNorevWalkInstance; + /***/ public String kNotInRange; + /***/ public String lengthExceedsMaximumArraySize; + /***/ public String listingAlternates; + /***/ public String localObjectsIncomplete; + /***/ public String localRefIsMissingObjects; + /***/ public String lockCountMustBeGreaterOrEqual1; + /***/ public String lockError; + /***/ public String lockOnNotClosed; + /***/ public String lockOnNotHeld; + /***/ public String malformedpersonIdentString; + /***/ public String mergeStrategyAlreadyExistsAsDefault; + /***/ public String missingAccesskey; + /***/ public String missingForwardImageInGITBinaryPatch; + /***/ public String missingObject; + /***/ public String missingPrerequisiteCommits; + /***/ public String missingSecretkey; + /***/ public String mixedStagesNotAllowed; + /***/ public String multipleMergeBasesFor; + /***/ public String need2Arguments; + /***/ public String needPackOut; + /***/ public String needsAtLeastOneEntry; + /***/ public String needsWorkdir; + /***/ public String newlineInQuotesNotAllowed; + /***/ public String noApplyInDelete; + /***/ public String noClosingBracket; + /***/ public String noHEADExistsAndNoExplicitStartingRevisionWasSpecified; + /***/ public String noHMACsupport; + /***/ public String noSuchRef; + /***/ public String noXMLParserAvailable; + /***/ public String notABoolean; + /***/ public String notABundle; + /***/ public String notADIRCFile; + /***/ public String notAGitDirectory; + /***/ public String notAPACKFile; + /***/ public String notARef; + /***/ public String notASCIIString; + /***/ public String notAValidPack; + /***/ public String notFound; + /***/ public String notValid; + /***/ public String nothingToFetch; + /***/ public String nothingToPush; + /***/ public String objectAtHasBadZlibStream; + /***/ public String objectAtPathDoesNotHaveId; + /***/ public String objectIsCorrupt; + /***/ public String objectIsNotA; + /***/ public String objectNotFoundIn; + /***/ public String offsetWrittenDeltaBaseForObjectNotFoundInAPack; + /***/ public String onlyOneFetchSupported; + /***/ public String onlyOneOperationCallPerConnectionIsSupported; + /***/ public String openFilesMustBeAtLeast1; + /***/ public String openingConnection; + /***/ public String outputHasAlreadyBeenStarted; + /***/ public String packChecksumMismatch; + /***/ public String packCorruptedWhileWritingToFilesystem; + /***/ public String packDoesNotMatchIndex; + /***/ public String packFileInvalid; + /***/ public String packHasUnresolvedDeltas; + /***/ public String packObjectCountMismatch; + /***/ public String packTooLargeForIndexVersion1; + /***/ public String packetSizeMustBeAtLeast; + /***/ public String packetSizeMustBeAtMost; + /***/ public String packfileCorruptionDetected; + /***/ public String packfileIsTruncated; + /***/ public String packingCancelledDuringObjectsWriting; + /***/ public String pathIsNotInWorkingDir; + /***/ public String peeledLineBeforeRef; + /***/ public String peerDidNotSupplyACompleteObjectGraph; + /***/ public String prefixRemote; + /***/ public String problemWithResolvingPushRefSpecsLocally; + /***/ public String progressMonUploading; + /***/ public String propertyIsAlreadyNonNull; + /***/ public String pushCancelled; + /***/ public String pushIsNotSupportedForBundleTransport; + /***/ public String pushNotPermitted; + /***/ public String rawLogMessageDoesNotParseAsLogEntry; + /***/ public String readTimedOut; + /***/ public String readingObjectsFromLocalRepositoryFailed; + /***/ public String receivingObjects; + /***/ public String refUpdateReturnCodeWas; + /***/ public String reflogsNotYetSupportedByRevisionParser; + /***/ public String remoteConfigHasNoURIAssociated; + /***/ public String remoteDoesNotHaveSpec; + /***/ public String remoteDoesNotSupportSmartHTTPPush; + /***/ public String remoteHungUpUnexpectedly; + /***/ public String remoteNameCantBeNull; + /***/ public String repositoryAlreadyExists; + /***/ public String repositoryNotFound; + /***/ public String requiredHashFunctionNotAvailable; + /***/ public String resolvingDeltas; + /***/ public String serviceNotPermitted; + /***/ public String shortCompressedStreamAt; + /***/ public String shortReadOfBlock; + /***/ public String shortReadOfOptionalDIRCExtensionExpectedAnotherBytes; + /***/ public String shortSkipOfBlock; + /***/ public String smartHTTPPushDisabled; + /***/ public String sourceDestinationMustMatch; + /***/ public String sourceIsNotAWildcard; + /***/ public String sourceRefDoesntResolveToAnyObject; + /***/ public String sourceRefNotSpecifiedForRefspec; + /***/ public String staleRevFlagsOn; + /***/ public String startingReadStageWithoutWrittenRequestDataPendingIsNotSupported; + /***/ public String statelessRPCRequiresOptionToBeEnabled; + /***/ public String symlinkCannotBeWrittenAsTheLinkTarget; + /***/ public String tSizeMustBeGreaterOrEqual1; + /***/ public String theFactoryMustNotBeNull; + /***/ public String timerAlreadyTerminated; + /***/ public String topologicalSortRequired; + /***/ public String transportExceptionBadRef; + /***/ public String transportExceptionEmptyRef; + /***/ public String transportExceptionInvalid; + /***/ public String transportExceptionMissingAssumed; + /***/ public String transportExceptionReadRef; + /***/ public String treeEntryAlreadyExists; + /***/ public String treeIteratorDoesNotSupportRemove; + /***/ public String truncatedHunkLinesMissingForAncestor; + /***/ public String truncatedHunkNewLinesMissing; + /***/ public String truncatedHunkOldLinesMissing; + /***/ public String unableToCheckConnectivity; + /***/ public String unableToLockTag; + /***/ public String unableToStore; + /***/ public String unableToWrite; + /***/ public String unencodeableFile; + /***/ public String unexpectedEndOfConfigFile; + /***/ public String unexpectedHunkTrailer; + /***/ public String unexpectedOddResult; + /***/ public String unexpectedRefReport; + /***/ public String unexpectedReportLine2; + /***/ public String unexpectedReportLine; + /***/ public String unknownDIRCVersion; + /***/ public String unknownHost; + /***/ public String unknownIndexVersionOrCorruptIndex; + /***/ public String unknownObjectType; + /***/ public String unknownRepositoryFormat2; + /***/ public String unknownRepositoryFormat; + /***/ public String unmergedPath; + /***/ public String unpackError; + /***/ public String unreadablePackIndex; + /***/ public String unrecognizedRef; + /***/ public String unsupportedCommand0; + /***/ public String unsupportedEncryptionAlgorithm; + /***/ public String unsupportedEncryptionVersion; + /***/ public String unsupportedOperationNotAddAtEnd; + /***/ public String unsupportedPackIndexVersion; + /***/ public String unsupportedPackVersion; + /***/ public String updatingRefFailed; + /***/ public String userConfigFileInvalid; + /***/ public String walkFailure; + /***/ public String windowSizeMustBeLesserThanLimit; + /***/ public String windowSizeMustBePowerOf2; + /***/ public String writeTimedOut; + /***/ public String writerAlreadyInitialized; + /***/ public String writingNotPermitted; + /***/ public String writingNotSupported; + /***/ public String writingObjects; + /***/ public String wrongDecompressedLength; +} diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java index 7501509d11..542c821451 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java @@ -43,7 +43,9 @@ package org.eclipse.jgit.api; import java.io.IOException; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.errors.UnmergedPathException; import org.eclipse.jgit.lib.Commit; @@ -112,7 +114,7 @@ public class CommitCommand extends GitCommand<RevCommit> { Ref head = repo.getRef(Constants.HEAD); if (head == null) throw new NoHeadException( - "Commit on repo without HEAD currently not supported"); + JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported); // determine the current HEAD and the commit it is referring to ObjectId parentID = repo.resolve(Constants.HEAD + "^{commit}"); @@ -153,15 +155,11 @@ public class CommitCommand extends GitCommand<RevCommit> { case REJECTED: case LOCK_FAILURE: throw new ConcurrentRefUpdateException( - "Could lock HEAD during commit", ru.getRef(), rc); + JGitText.get().couldNotLockHEAD, ru.getRef(), rc); default: - throw new JGitInternalException( - "Updating the ref " - + Constants.HEAD - + " to " - + commitId.toString() - + " failed. ReturnCode from RefUpdate.update() was " - + rc); + throw new JGitInternalException(MessageFormat.format( + JGitText.get().updatingRefFailed + , Constants.HEAD, commitId.toString(), rc)); } } finally { index.unlock(); @@ -173,7 +171,7 @@ public class CommitCommand extends GitCommand<RevCommit> { throw e; } catch (IOException e) { throw new JGitInternalException( - "Exception caught during execution of commit command", e); + JGitText.get().exceptionCaughtDuringExecutionOfCommitCommand, e); } } @@ -188,7 +186,7 @@ public class CommitCommand extends GitCommand<RevCommit> { if (message == null) // as long as we don't suppport -C option we have to have // an explicit message - throw new NoMessageException("commit message not specified"); + throw new NoMessageException(JGitText.get().commitMessageNotSpecified); if (committer == null) committer = new PersonIdent(repo); if (author == null) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ConcurrentRefUpdateException.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/ConcurrentRefUpdateException.java index c5d9fe68dd..02bb494f66 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ConcurrentRefUpdateException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ConcurrentRefUpdateException.java @@ -37,6 +37,9 @@ */ package org.eclipse.jgit.api; +import java.text.MessageFormat; + +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.RefUpdate; @@ -53,16 +56,16 @@ public class ConcurrentRefUpdateException extends GitAPIException { ConcurrentRefUpdateException(String message, Ref ref, RefUpdate.Result rc, Throwable cause) { - super((rc == null) ? message : message - + ". RefUpdate return code was: " + rc, cause); + super((rc == null) ? message : message + ". " + + MessageFormat.format(JGitText.get().refUpdateReturnCodeWas, rc), cause); this.rc = rc; this.ref = ref; } ConcurrentRefUpdateException(String message, Ref ref, RefUpdate.Result rc) { - super((rc == null) ? message : message - + ". RefUpdate return code was: " + rc); + super((rc == null) ? message : message + ". " + + MessageFormat.format(JGitText.get().refUpdateReturnCodeWas, rc)); this.rc = rc; this.ref = ref; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/GitCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/GitCommand.java index 4df5b4437b..ece467aa07 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/GitCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/GitCommand.java @@ -37,8 +37,10 @@ */ package org.eclipse.jgit.api; +import java.text.MessageFormat; import java.util.concurrent.Callable; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.lib.Repository; /** @@ -110,8 +112,8 @@ public abstract class GitCommand<T> implements Callable<T> { */ protected void checkCallable() { if (!callable) - throw new IllegalStateException("Command " - + this.getClass().getName() - + " was called in the wrong state"); + throw new IllegalStateException(MessageFormat.format( + JGitText.get().commandWasCalledInTheWrongState + , this.getClass().getName())); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java index 4ce57201d3..414fac4f38 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java @@ -43,7 +43,9 @@ package org.eclipse.jgit.api; import java.io.IOException; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.lib.AnyObjectId; @@ -97,13 +99,13 @@ public class LogCommand extends GitCommand<Iterable<RevCommit>> { ObjectId headId = repo.resolve(Constants.HEAD); if (headId == null) throw new NoHeadException( - "No HEAD exists and no explicit starting revision was specified"); + JGitText.get().noHEADExistsAndNoExplicitStartingRevisionWasSpecified); add(headId); } catch (IOException e) { // all exceptions thrown by add() shouldn't occur and represent // severe low-level exception which are therefore wrapped throw new JGitInternalException( - "An exception occured while trying to add the Id of HEAD", + JGitText.get().anExceptionOccurredWhileTryingToAddTheIdOfHEAD, e); } } @@ -214,9 +216,9 @@ public class LogCommand extends GitCommand<Iterable<RevCommit>> { } catch (IncorrectObjectTypeException e) { throw e; } catch (IOException e) { - throw new JGitInternalException( - "Exception occured during adding of " + start - + " as option to a Log command", e); + throw new JGitInternalException(MessageFormat.format( + JGitText.get().exceptionOccuredDuringAddingOfOptionToALogCommand + , start), e); } } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java index 115d9baff3..2d552d40d9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java @@ -50,6 +50,7 @@ import java.io.IOException; import java.io.OutputStream; import java.util.List; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.patch.FileHeader; /** @@ -75,7 +76,7 @@ public class DiffFormatter { */ public void setContext(final int lineCount) { if (lineCount < 0) - throw new IllegalArgumentException("context must be >= 0"); + throw new IllegalArgumentException(JGitText.get().contextMustBeNonNegative); context = lineCount; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/MyersDiff.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/MyersDiff.java index 055729961b..6a4b44bff1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/MyersDiff.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/MyersDiff.java @@ -44,6 +44,9 @@ package org.eclipse.jgit.diff; +import java.text.MessageFormat; + +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.util.IntList; import org.eclipse.jgit.util.LongList; @@ -292,21 +295,21 @@ public class MyersDiff { final int getIndex(int d, int k) { // TODO: remove if (((d + k - middleK) % 2) == 1) - throw new RuntimeException("odd: " + d + " + " + k + " - " + middleK); + throw new RuntimeException(MessageFormat.format(JGitText.get().unexpectedOddResult, d, k, middleK)); return (d + k - middleK) / 2; } final int getX(int d, int k) { // TODO: remove if (k < beginK || k > endK) - throw new RuntimeException("k " + k + " not in " + beginK + " - " + endK); + throw new RuntimeException(MessageFormat.format(JGitText.get().kNotInRange, k, beginK, endK)); return x.get(getIndex(d, k)); } final long getSnake(int d, int k) { // TODO: remove if (k < beginK || k > endK) - throw new RuntimeException("k " + k + " not in " + beginK + " - " + endK); + throw new RuntimeException(MessageFormat.format(JGitText.get().kNotInRange, k, beginK, endK)); return snake.get(getIndex(d, k)); } @@ -520,7 +523,7 @@ if (k < beginK || k > endK) */ public static void main(String[] args) { if (args.length != 2) { - System.err.println("Need 2 arguments"); + System.err.println(JGitText.get().need2Arguments); System.exit(1); } try { @@ -532,4 +535,4 @@ if (k < beginK || k > endK) e.printStackTrace(); } } -}
\ No newline at end of file +} diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java index 3a8abc1a73..42fea48520 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java @@ -56,9 +56,11 @@ import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.security.DigestOutputStream; import java.security.MessageDigest; +import java.text.MessageFormat; import java.util.Arrays; import java.util.Comparator; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.errors.UnmergedPathException; import org.eclipse.jgit.lib.Constants; @@ -200,7 +202,7 @@ public class DirCache { throws CorruptObjectException, IOException { final DirCache c = new DirCache(indexLocation); if (!c.lock()) - throw new IOException("Cannot lock " + indexLocation); + throw new IOException(MessageFormat.format(JGitText.get().cannotLock, indexLocation)); try { c.read(); @@ -319,7 +321,7 @@ public class DirCache { */ public void read() throws IOException, CorruptObjectException { if (liveFile == null) - throw new IOException("DirCache does not have a backing file"); + throw new IOException(JGitText.get().dirCacheDoesNotHaveABackingFile); if (!liveFile.exists()) clear(); else if (liveFile.lastModified() != lastModified) { @@ -363,13 +365,13 @@ public class DirCache { IO.readFully(in, hdr, 0, 12); md.update(hdr, 0, 12); if (!is_DIRC(hdr)) - throw new CorruptObjectException("Not a DIRC file."); + throw new CorruptObjectException(JGitText.get().notADIRCFile); final int ver = NB.decodeInt32(hdr, 4); if (ver != 2) - throw new CorruptObjectException("Unknown DIRC version " + ver); + throw new CorruptObjectException(MessageFormat.format(JGitText.get().unknownDIRCVersion, ver)); entryCnt = NB.decodeInt32(hdr, 8); if (entryCnt < 0) - throw new CorruptObjectException("DIRC has too many entries."); + throw new CorruptObjectException(JGitText.get().DIRCHasTooManyEntries); // Load the individual file entries. // @@ -398,9 +400,8 @@ public class DirCache { switch (NB.decodeInt32(hdr, 0)) { case EXT_TREE: { if (Integer.MAX_VALUE < sz) { - throw new CorruptObjectException("DIRC extension " - + formatExtensionName(hdr) + " is too large at " - + sz + " bytes."); + throw new CorruptObjectException(MessageFormat.format(JGitText.get().DIRCExtensionIsTooLargeAt + , formatExtensionName(hdr), sz)); } final byte[] raw = new byte[(int) sz]; IO.readFully(in, raw, 0, raw.length); @@ -421,16 +422,15 @@ public class DirCache { // _required_ to understand this index format. // Since we did not trap it above we must abort. // - throw new CorruptObjectException("DIRC extension " - + formatExtensionName(hdr) - + " not supported by this version."); + throw new CorruptObjectException(MessageFormat.format(JGitText.get().DIRCExtensionNotSupportedByThisVersion + , formatExtensionName(hdr))); } } } final byte[] exp = md.digest(); if (!Arrays.equals(exp, hdr)) { - throw new CorruptObjectException("DIRC checksum mismatch"); + throw new CorruptObjectException(JGitText.get().DIRCChecksumMismatch); } } @@ -441,9 +441,8 @@ public class DirCache { while (0 < sz) { int n = in.read(b, 0, (int) Math.min(b.length, sz)); if (n < 0) { - throw new EOFException("Short read of optional DIRC extension " - + formatExtensionName(hdr) + "; expected another " + sz - + " bytes within the section."); + throw new EOFException(MessageFormat.format(JGitText.get().shortReadOfOptionalDIRCExtensionExpectedAnotherBytes + , formatExtensionName(hdr), sz)); } md.update(b, 0, n); sz -= n; @@ -475,7 +474,7 @@ public class DirCache { */ public boolean lock() throws IOException { if (liveFile == null) - throw new IOException("DirCache does not have a backing file"); + throw new IOException(JGitText.get().dirCacheDoesNotHaveABackingFile); final LockFile tmp = new LockFile(liveFile); if (tmp.lock()) { tmp.setNeedStatInformation(true); @@ -585,10 +584,10 @@ public class DirCache { private void requireLocked(final LockFile tmp) { if (liveFile == null) - throw new IllegalStateException("DirCache is not locked"); + throw new IllegalStateException(JGitText.get().dirCacheIsNotLocked); if (tmp == null) - throw new IllegalStateException("DirCache " - + liveFile.getAbsolutePath() + " not locked."); + throw new IllegalStateException(MessageFormat.format(JGitText.get().dirCacheFileIsNotLocked + , liveFile.getAbsolutePath())); } /** diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheBuilder.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheBuilder.java index 69f5444c64..e6b6197819 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheBuilder.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheBuilder.java @@ -45,8 +45,10 @@ package org.eclipse.jgit.dircache; import java.io.IOException; +import java.text.MessageFormat; import java.util.Arrays; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.WindowCursor; @@ -101,8 +103,8 @@ public class DirCacheBuilder extends BaseDirCacheEditor { */ public void add(final DirCacheEntry newEntry) { if (newEntry.getRawMode() == 0) - throw new IllegalArgumentException("FileMode not set for path " - + newEntry.getPathString()); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().fileModeNotSetForPath + , newEntry.getPathString())); beforeAdd(newEntry); fastAdd(newEntry); } @@ -214,9 +216,9 @@ public class DirCacheBuilder extends BaseDirCacheEditor { final int peStage = lastEntry.getStage(); final int dceStage = newEntry.getStage(); if (peStage == dceStage) - throw bad(newEntry, "Duplicate stages not allowed"); + throw bad(newEntry, JGitText.get().duplicateStagesNotAllowed); if (peStage == 0 || dceStage == 0) - throw bad(newEntry, "Mixed stages not allowed"); + throw bad(newEntry, JGitText.get().mixedStagesNotAllowed); if (peStage > dceStage) sorted = false; } @@ -237,9 +239,9 @@ public class DirCacheBuilder extends BaseDirCacheEditor { final int peStage = pe.getStage(); final int ceStage = ce.getStage(); if (peStage == ceStage) - throw bad(ce, "Duplicate stages not allowed"); + throw bad(ce, JGitText.get().duplicateStagesNotAllowed); if (peStage == 0 || ceStage == 0) - throw bad(ce, "Mixed stages not allowed"); + throw bad(ce, JGitText.get().mixedStagesNotAllowed); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEditor.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEditor.java index 85ad8b4d79..77e9d51e05 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEditor.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEditor.java @@ -45,11 +45,13 @@ package org.eclipse.jgit.dircache; import java.io.IOException; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.lib.Constants; /** @@ -149,8 +151,8 @@ public class DirCacheEditor extends BaseDirCacheEditor { ent = new DirCacheEntry(e.path); e.apply(ent); if (ent.getRawMode() == 0) - throw new IllegalArgumentException("FileMode not set" - + " for path " + ent.getPathString()); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().fileModeNotSetForPath + , ent.getPathString())); } else { ent = cache.getEntry(eIdx); e.apply(ent); @@ -241,7 +243,7 @@ public class DirCacheEditor extends BaseDirCacheEditor { } public void apply(final DirCacheEntry ent) { - throw new UnsupportedOperationException("No apply in delete"); + throw new UnsupportedOperationException(JGitText.get().noApplyInDelete); } } @@ -271,7 +273,7 @@ public class DirCacheEditor extends BaseDirCacheEditor { } public void apply(final DirCacheEntry ent) { - throw new UnsupportedOperationException("No apply in delete"); + throw new UnsupportedOperationException(JGitText.get().noApplyInDelete); } } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java index 415de095b2..afa6bef05b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java @@ -51,8 +51,10 @@ import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteBuffer; import java.security.MessageDigest; +import java.text.MessageFormat; import java.util.Arrays; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.FileMode; @@ -145,7 +147,7 @@ public class DirCacheEntry { for (;;) { final int c = in.read(); if (c < 0) - throw new EOFException("Short read of block."); + throw new EOFException(JGitText.get().shortReadOfBlock); if (c == 0) break; tmp.write(c); @@ -229,11 +231,11 @@ public class DirCacheEntry { */ public DirCacheEntry(final byte[] newPath, final int stage) { if (!isValidPath(newPath)) - throw new IllegalArgumentException("Invalid path: " - + toString(newPath)); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().invalidPath + , toString(newPath))); if (stage < 0 || 3 < stage) - throw new IllegalArgumentException("Invalid stage " + stage - + " for path " + toString(newPath)); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().invalidStageForPath + , stage, toString(newPath))); info = new byte[INFO_LEN]; infoOffset = 0; @@ -397,8 +399,8 @@ public class DirCacheEntry { switch (mode.getBits() & FileMode.TYPE_MASK) { case FileMode.TYPE_MISSING: case FileMode.TYPE_TREE: - throw new IllegalArgumentException("Invalid mode " + mode - + " for path " + getPathString()); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().invalidModeForPath + , mode, getPathString())); } NB.encodeInt32(info, infoOffset + P_MODE, mode.getBits()); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/CheckoutConflictException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/CheckoutConflictException.java index b602033dc0..7c6560a3ec 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/CheckoutConflictException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/CheckoutConflictException.java @@ -46,6 +46,9 @@ package org.eclipse.jgit.errors; import java.io.IOException; +import java.text.MessageFormat; + +import org.eclipse.jgit.JGitText; /** * Exception thrown if a conflict occurs during a merge checkout. @@ -59,7 +62,7 @@ public class CheckoutConflictException extends IOException { * @param file */ public CheckoutConflictException(String file) { - super("Checkout conflict with file: " + file); + super(MessageFormat.format(JGitText.get().checkoutConflictWithFile, file)); } /** @@ -68,7 +71,7 @@ public class CheckoutConflictException extends IOException { * @param files */ public CheckoutConflictException(String[] files) { - super("Checkout conflict with files: " + buildList(files)); + super(MessageFormat.format(JGitText.get().checkoutConflictWithFiles, buildList(files))); } private static String buildList(String[] files) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/CompoundException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/CompoundException.java index edee6084b3..1c432a817d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/CompoundException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/CompoundException.java @@ -48,13 +48,15 @@ import java.util.Collection; import java.util.Collections; import java.util.List; +import org.eclipse.jgit.JGitText; + /** An exception detailing multiple reasons for failure. */ public class CompoundException extends Exception { private static final long serialVersionUID = 1L; private static String format(final Collection<Throwable> causes) { final StringBuilder msg = new StringBuilder(); - msg.append("Failure due to one of the following:"); + msg.append(JGitText.get().failureDueToOneOfTheFollowing); for (final Throwable c : causes) { msg.append(" "); msg.append(c.getMessage()); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/CorruptObjectException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/CorruptObjectException.java index f42b0d7e19..939dc21604 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/CorruptObjectException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/CorruptObjectException.java @@ -47,7 +47,9 @@ package org.eclipse.jgit.errors; import java.io.IOException; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.ObjectId; @@ -76,7 +78,7 @@ public class CorruptObjectException extends IOException { * @param why */ public CorruptObjectException(final ObjectId id, final String why) { - super("Object " + id.name() + " is corrupt: " + why); + super(MessageFormat.format(JGitText.get().objectIsCorrupt, id.name(), why)); } /** diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/EntryExistsException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/EntryExistsException.java index 893ee9ceb2..d7e587e3d0 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/EntryExistsException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/EntryExistsException.java @@ -45,6 +45,9 @@ package org.eclipse.jgit.errors; import java.io.IOException; +import java.text.MessageFormat; + +import org.eclipse.jgit.JGitText; /** * Attempt to add an entry to a tree that already exists. @@ -59,6 +62,6 @@ public class EntryExistsException extends IOException { * @param name workdir relative file name */ public EntryExistsException(final String name) { - super("Tree entry \"" + name + "\" already exists."); + super(MessageFormat.format(JGitText.get().treeEntryAlreadyExists, name)); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/IncorrectObjectTypeException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/IncorrectObjectTypeException.java index 7cf1de214f..0dac326f40 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/IncorrectObjectTypeException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/IncorrectObjectTypeException.java @@ -47,7 +47,9 @@ package org.eclipse.jgit.errors; import java.io.IOException; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; @@ -69,7 +71,7 @@ public class IncorrectObjectTypeException extends IOException { * @param type object type */ public IncorrectObjectTypeException(final ObjectId id, final String type) { - super("Object " + id.name() + " is not a " + type + "."); + super(MessageFormat.format(JGitText.get().objectIsNotA, id.name(), type)); } /** diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/InvalidObjectIdException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/InvalidObjectIdException.java index e6577213ee..96c75f5558 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/InvalidObjectIdException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/InvalidObjectIdException.java @@ -46,6 +46,9 @@ package org.eclipse.jgit.errors; import java.io.UnsupportedEncodingException; +import java.text.MessageFormat; + +import org.eclipse.jgit.JGitText; /** * Thrown when an invalid object id is passed in as an argument. @@ -61,7 +64,7 @@ public class InvalidObjectIdException extends IllegalArgumentException { * @param length of the sequence of invalid bytes. */ public InvalidObjectIdException(byte[] bytes, int offset, int length) { - super("Invalid id" + asAscii(bytes, offset, length)); + super(MessageFormat.format(JGitText.get().invalidId, asAscii(bytes, offset, length))); } private static String asAscii(byte[] bytes, int offset, int length) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingBundlePrerequisiteException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingBundlePrerequisiteException.java index 2d399543a0..63b0e200ca 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingBundlePrerequisiteException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingBundlePrerequisiteException.java @@ -46,6 +46,7 @@ package org.eclipse.jgit.errors; import java.util.Map; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.transport.URIish; @@ -57,7 +58,7 @@ public class MissingBundlePrerequisiteException extends TransportException { private static String format(final Map<ObjectId, String> missingCommits) { final StringBuilder r = new StringBuilder(); - r.append("missing prerequisite commits:"); + r.append(JGitText.get().missingPrerequisiteCommits); for (final Map.Entry<ObjectId, String> e : missingCommits.entrySet()) { r.append("\n "); r.append(e.getKey().name()); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingObjectException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingObjectException.java index 41cacb84ad..1d193e18c7 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingObjectException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingObjectException.java @@ -47,7 +47,9 @@ package org.eclipse.jgit.errors; import java.io.IOException; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; @@ -65,7 +67,7 @@ public class MissingObjectException extends IOException { * @param type object type */ public MissingObjectException(final ObjectId id, final String type) { - super("Missing " + type + " " + id.name()); + super(MessageFormat.format(JGitText.get().missingObject, type, id.name())); } /** diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/NoClosingBracketException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/NoClosingBracketException.java index 623dfa6ec6..25cf800fa7 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/NoClosingBracketException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/NoClosingBracketException.java @@ -46,6 +46,10 @@ package org.eclipse.jgit.errors; +import java.text.MessageFormat; + +import org.eclipse.jgit.JGitText; + /** * Thrown when a pattern contains a character group which is open to the right * side or a character class which is open to the right side. @@ -72,7 +76,7 @@ public class NoClosingBracketException extends InvalidPatternException { private static String createMessage(final int indexOfOpeningBracket, final String openingBracket, final String closingBracket) { - return String.format("No closing %s found for %s at index %s.", + return MessageFormat.format(JGitText.get().noClosingBracket, closingBracket, openingBracket, Integer.valueOf(indexOfOpeningBracket)); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/PackInvalidException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/PackInvalidException.java index a34b80db81..59354ddb70 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/PackInvalidException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/PackInvalidException.java @@ -45,6 +45,9 @@ package org.eclipse.jgit.errors; import java.io.File; import java.io.IOException; +import java.text.MessageFormat; + +import org.eclipse.jgit.JGitText; /** Thrown when a PackFile previously failed and is known to be unusable */ public class PackInvalidException extends IOException { @@ -57,6 +60,6 @@ public class PackInvalidException extends IOException { * path of the invalid pack file. */ public PackInvalidException(final File path) { - super("Pack file invalid: " + path.getAbsolutePath()); + super(MessageFormat.format(JGitText.get().packFileInvalid, path.getAbsolutePath())); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/RepositoryNotFoundException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/RepositoryNotFoundException.java index c745e7326e..d00a766880 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/RepositoryNotFoundException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/RepositoryNotFoundException.java @@ -44,6 +44,9 @@ package org.eclipse.jgit.errors; import java.io.File; +import java.text.MessageFormat; + +import org.eclipse.jgit.JGitText; /** Indicates a local repository does not exist. */ public class RepositoryNotFoundException extends TransportException { @@ -94,6 +97,6 @@ public class RepositoryNotFoundException extends TransportException { } private static String message(final String location) { - return "repository not found: " + location; + return MessageFormat.format(JGitText.get().repositoryNotFound, location); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/RevWalkException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/RevWalkException.java index 0ad41ed173..7b9c70736b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/RevWalkException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/RevWalkException.java @@ -44,6 +44,7 @@ package org.eclipse.jgit.errors; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.revwalk.RevWalk; /** @@ -65,6 +66,6 @@ public class RevWalkException extends RuntimeException { * the checked exception that describes why the walk failed. */ public RevWalkException(final Throwable cause) { - super("Walk failure.", cause); + super(JGitText.get().walkFailure, cause); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/UnmergedPathException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/UnmergedPathException.java index 51e651ca5e..ccc960e967 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/UnmergedPathException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/UnmergedPathException.java @@ -44,7 +44,9 @@ package org.eclipse.jgit.errors; import java.io.IOException; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.dircache.DirCacheEntry; /** @@ -62,7 +64,7 @@ public class UnmergedPathException extends IOException { * the first non-zero stage of the unmerged path. */ public UnmergedPathException(final DirCacheEntry dce) { - super("Unmerged path: " + dce.getPathString()); + super(MessageFormat.format(JGitText.get().unmergedPath, dce.getPathString())); entry = dce; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/AbstractHead.java b/org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/AbstractHead.java index 42182965a0..cff542be2e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/AbstractHead.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/AbstractHead.java @@ -46,6 +46,8 @@ package org.eclipse.jgit.fnmatch; import java.util.List; +import org.eclipse.jgit.JGitText; + abstract class AbstractHead implements Head { private List<Head> newHeads = null; @@ -64,7 +66,7 @@ abstract class AbstractHead implements Head { */ public final void setNewHeads(List<Head> newHeads) { if (this.newHeads != null) - throw new IllegalStateException("Property is already non null"); + throw new IllegalStateException(JGitText.get().propertyIsAlreadyNonNull); this.newHeads = newHeads; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/GroupHead.java b/org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/GroupHead.java index 79f64f859e..ffa34a7104 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/GroupHead.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/GroupHead.java @@ -44,11 +44,13 @@ package org.eclipse.jgit.fnmatch; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.InvalidPatternException; final class GroupHead extends AbstractHead { @@ -112,9 +114,9 @@ final class GroupHead extends AbstractHead { characterClasses.add(LetterPattern.INSTANCE); characterClasses.add(DigitPattern.INSTANCE); } else { - final String message = String.format( - "The character class %s is not supported.", - characterClass); + final String message = String.format(MessageFormat.format( + JGitText.get().characterClassIsNotSupported, + characterClass)); throw new InvalidPatternException(message, wholePattern); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/AbbreviatedObjectId.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/AbbreviatedObjectId.java index 9d9174111b..a150e8fea1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/AbbreviatedObjectId.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/AbbreviatedObjectId.java @@ -43,6 +43,9 @@ package org.eclipse.jgit.lib; +import java.text.MessageFormat; + +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.InvalidObjectIdException; import org.eclipse.jgit.util.NB; import org.eclipse.jgit.util.RawParseUtils; @@ -74,7 +77,8 @@ public final class AbbreviatedObjectId { public static final AbbreviatedObjectId fromString(final byte[] buf, final int offset, final int end) { if (end - offset > Constants.OBJECT_ID_STRING_LENGTH) - throw new IllegalArgumentException("Invalid id"); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().invalidIdLength + , end - offset, Constants.OBJECT_ID_STRING_LENGTH)); return fromHexString(buf, offset, end); } @@ -87,7 +91,7 @@ public final class AbbreviatedObjectId { */ public static final AbbreviatedObjectId fromString(final String str) { if (str.length() > Constants.OBJECT_ID_STRING_LENGTH) - throw new IllegalArgumentException("Invalid id: " + str); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().invalidId, str)); final byte[] b = Constants.encodeASCII(str); return fromHexString(b, 0, b.length); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BinaryDelta.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BinaryDelta.java index 461e6d4026..a59b335330 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BinaryDelta.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BinaryDelta.java @@ -44,6 +44,8 @@ package org.eclipse.jgit.lib; +import org.eclipse.jgit.JGitText; + /** * Recreate a stream from a base stream and a GIT pack delta. * <p> @@ -78,7 +80,7 @@ public class BinaryDelta { shift += 7; } while ((c & 0x80) != 0); if (base.length != baseLen) - throw new IllegalArgumentException("base length incorrect"); + throw new IllegalArgumentException(JGitText.get().baseLengthIncorrect); // Length of the resulting object (a variable length int). // @@ -132,7 +134,7 @@ public class BinaryDelta { // cmd == 0 has been reserved for future encoding but // for now its not acceptable. // - throw new IllegalArgumentException("unsupported command 0"); + throw new IllegalArgumentException(JGitText.get().unsupportedCommand0); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BlobBasedConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BlobBasedConfig.java index 0a4222fc38..b05942b02c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BlobBasedConfig.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BlobBasedConfig.java @@ -47,7 +47,9 @@ package org.eclipse.jgit.lib; import java.io.FileNotFoundException; import java.io.IOException; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.treewalk.TreeWalk; import org.eclipse.jgit.util.RawParseUtils; @@ -91,7 +93,7 @@ public class BlobBasedConfig extends Config { super(base); final ObjectLoader loader = r.openBlob(objectId); if (loader == null) - throw new IOException("Blob not found: " + objectId); + throw new IOException(MessageFormat.format(JGitText.get().blobNotFound, objectId)); fromText(RawParseUtils.decode(loader.getBytes())); } @@ -118,12 +120,12 @@ public class BlobBasedConfig extends Config { final Repository r = commit.getRepository(); final TreeWalk tree = TreeWalk.forPath(r, path, treeId); if (tree == null) - throw new FileNotFoundException("Entry not found by path: " + path); + throw new FileNotFoundException(MessageFormat.format(JGitText.get().entryNotFoundByPath, path)); final ObjectId blobId = tree.getObjectId(0); final ObjectLoader loader = tree.getRepository().openBlob(blobId); if (loader == null) - throw new IOException("Blob not found: " + blobId + " for path: " - + path); + throw new IOException(MessageFormat.format(JGitText.get().blobNotFoundForPath + , blobId, path)); fromText(RawParseUtils.decode(loader.getBytes())); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Commit.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Commit.java index 65921e53c7..66dd89120c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Commit.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Commit.java @@ -49,7 +49,9 @@ import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; import java.nio.charset.Charset; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.errors.MissingObjectException; @@ -279,18 +281,18 @@ public class Commit implements Treeish { DataInputStream br = new DataInputStream(new ByteArrayInputStream(raw)); String n = br.readLine(); if (n == null || !n.startsWith("tree ")) { - throw new CorruptObjectException(commitId, "no tree"); + throw new CorruptObjectException(commitId, JGitText.get().corruptObjectNotree); } while ((n = br.readLine()) != null && n.startsWith("parent ")) { // empty body } if (n == null || !n.startsWith("author ")) { - throw new CorruptObjectException(commitId, "no author"); + throw new CorruptObjectException(commitId, JGitText.get().corruptObjectNoAuthor); } String rawAuthor = n.substring("author ".length()); n = br.readLine(); if (n == null || !n.startsWith("committer ")) { - throw new CorruptObjectException(commitId, "no committer"); + throw new CorruptObjectException(commitId, JGitText.get().corruptObjectNoCommitter); } String rawCommitter = n.substring("committer ".length()); n = br.readLine(); @@ -298,8 +300,8 @@ public class Commit implements Treeish { encoding = Charset.forName(n.substring("encoding ".length())); else if (n == null || !n.equals("")) { - throw new CorruptObjectException(commitId, - "malformed header:"+n); + throw new CorruptObjectException(commitId, MessageFormat.format( + JGitText.get().corruptObjectMalformedHeader, n)); } byte[] readBuf = new byte[br.available()]; // in-memory stream so this is all bytes left br.read(readBuf); @@ -336,12 +338,12 @@ public class Commit implements Treeish { */ public void commit() throws IOException { if (getCommitId() != null) - throw new IllegalStateException("exists " + getCommitId()); + throw new IllegalStateException(MessageFormat.format(JGitText.get().commitAlreadyExists, getCommitId())); setCommitId(new ObjectWriter(objdb).writeCommit(this)); } public String toString() { - return "Commit[" + ObjectId.toString(getCommitId()) + " " + getAuthor() + "]"; + return "Commit[" + ObjectId.toString(getCommitId()) + " " + getAuthor() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } /** diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java index 062c1c3974..7c5af1e648 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java @@ -50,6 +50,7 @@ package org.eclipse.jgit.lib; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; @@ -59,6 +60,7 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicReference; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.util.StringUtils; @@ -210,8 +212,8 @@ public class Config { final long val = getLong(section, subsection, name, defaultValue); if (Integer.MIN_VALUE <= val && val <= Integer.MAX_VALUE) return (int) val; - throw new IllegalArgumentException("Integer value " + section + "." - + name + " out of range"); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().integerValueOutOfRange + , section, name)); } /** @@ -257,8 +259,8 @@ public class Config { try { return mul * Long.parseLong(n); } catch (NumberFormatException nfe) { - throw new IllegalArgumentException("Invalid integer value: " - + section + "." + name + "=" + str); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().invalidIntegerValue + , section, name, str)); } } @@ -303,8 +305,8 @@ public class Config { try { return StringUtils.toBoolean(n); } catch (IllegalArgumentException err) { - throw new IllegalArgumentException("Invalid boolean value: " - + section + "." + name + "=" + n); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().invalidBooleanValue + , section, name, n)); } } @@ -819,7 +821,7 @@ public class Config { input = in.read(); } if (']' != input) - throw new ConfigInvalidException("Bad group header"); + throw new ConfigInvalidException(JGitText.get().badGroupHeader); e.suffix = ""; } else if (last != null) { @@ -835,7 +837,7 @@ public class Config { e.value = readValue(in, false, -1); } else - throw new ConfigInvalidException("Invalid line in config file"); + throw new ConfigInvalidException(JGitText.get().invalidLineInConfigFile); } state.set(newState(newEntries)); @@ -862,7 +864,7 @@ public class Config { for (;;) { int c = in.read(); if (c < 0) - throw new ConfigInvalidException("Unexpected end of config file"); + throw new ConfigInvalidException(JGitText.get().unexpectedEndOfConfigFile); if (']' == c) { in.reset(); @@ -873,7 +875,7 @@ public class Config { for (;;) { c = in.read(); if (c < 0) - throw new ConfigInvalidException("Unexpected end of config file"); + throw new ConfigInvalidException(JGitText.get().unexpectedEndOfConfigFile); if ('"' == c) { in.reset(); @@ -882,7 +884,7 @@ public class Config { if (' ' == c || '\t' == c) continue; // Skipped... - throw new ConfigInvalidException("Bad section entry: " + name); + throw new ConfigInvalidException(MessageFormat.format(JGitText.get().badSectionEntry, name)); } break; } @@ -890,7 +892,7 @@ public class Config { if (Character.isLetterOrDigit((char) c) || '.' == c || '-' == c) name.append((char) c); else - throw new ConfigInvalidException("Bad section entry: " + name); + throw new ConfigInvalidException(MessageFormat.format(JGitText.get().badSectionEntry, name)); } return name.toString(); } @@ -901,7 +903,7 @@ public class Config { for (;;) { int c = in.read(); if (c < 0) - throw new ConfigInvalidException("Unexpected end of config file"); + throw new ConfigInvalidException(JGitText.get().unexpectedEndOfConfigFile); if ('=' == c) break; @@ -910,7 +912,7 @@ public class Config { for (;;) { c = in.read(); if (c < 0) - throw new ConfigInvalidException("Unexpected end of config file"); + throw new ConfigInvalidException(JGitText.get().unexpectedEndOfConfigFile); if ('=' == c) break; @@ -922,7 +924,7 @@ public class Config { if (' ' == c || '\t' == c) continue; // Skipped... - throw new ConfigInvalidException("Bad entry delimiter"); + throw new ConfigInvalidException(JGitText.get().badEntryDelimiter); } break; } @@ -937,7 +939,7 @@ public class Config { name.append((char) c); break; } else - throw new ConfigInvalidException("Bad entry name: " + name); + throw new ConfigInvalidException(MessageFormat.format(JGitText.get().badEntryName, name)); } return name.toString(); } @@ -950,13 +952,13 @@ public class Config { int c = in.read(); if (c < 0) { if (value.length() == 0) - throw new ConfigInvalidException("Unexpected end of config file"); + throw new ConfigInvalidException(JGitText.get().unexpectedEndOfConfigFile); break; } if ('\n' == c) { if (quote) - throw new ConfigInvalidException("Newline in quotes not allowed"); + throw new ConfigInvalidException(JGitText.get().newlineInQuotesNotAllowed); in.reset(); break; } @@ -985,7 +987,7 @@ public class Config { c = in.read(); switch (c) { case -1: - throw new ConfigInvalidException("End of file in escape"); + throw new ConfigInvalidException(JGitText.get().endOfFileInEscape); case '\n': continue; case 't': @@ -1004,7 +1006,7 @@ public class Config { value.append('"'); continue; default: - throw new ConfigInvalidException("Bad escape: " + ((char) c)); + throw new ConfigInvalidException(MessageFormat.format(JGitText.get().badEscape, ((char) c))); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java index 348905dd12..37836f3246 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java @@ -49,7 +49,9 @@ import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.util.MutableInteger; @@ -327,8 +329,8 @@ public final class Constants { try { return MessageDigest.getInstance(HASH_FUNCTION); } catch (NoSuchAlgorithmException nsae) { - throw new RuntimeException("Required hash function " - + HASH_FUNCTION + " not available.", nsae); + throw new RuntimeException(MessageFormat.format( + JGitText.get().requiredHashFunctionNotAvailable, HASH_FUNCTION), nsae); } } @@ -349,7 +351,7 @@ public final class Constants { case OBJ_TAG: return TYPE_TAG; default: - throw new IllegalArgumentException("Bad object type: " + typeCode); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().badObjectType, typeCode)); } } @@ -373,7 +375,7 @@ public final class Constants { case OBJ_TAG: return ENCODED_TYPE_TAG; default: - throw new IllegalArgumentException("Bad object type: " + typeCode); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().badObjectType, typeCode)); } } @@ -408,7 +410,7 @@ public final class Constants { || typeString[position + 2] != 'o' || typeString[position + 3] != 'b' || typeString[position + 4] != endMark) - throw new CorruptObjectException(id, "invalid type"); + throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType); offset.value = position + 5; return Constants.OBJ_BLOB; @@ -419,7 +421,7 @@ public final class Constants { || typeString[position + 4] != 'i' || typeString[position + 5] != 't' || typeString[position + 6] != endMark) - throw new CorruptObjectException(id, "invalid type"); + throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType); offset.value = position + 7; return Constants.OBJ_COMMIT; @@ -428,7 +430,7 @@ public final class Constants { case 'a': if (typeString[position + 2] != 'g' || typeString[position + 3] != endMark) - throw new CorruptObjectException(id, "invalid type"); + throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType); offset.value = position + 4; return Constants.OBJ_TAG; @@ -436,19 +438,19 @@ public final class Constants { if (typeString[position + 2] != 'e' || typeString[position + 3] != 'e' || typeString[position + 4] != endMark) - throw new CorruptObjectException(id, "invalid type"); + throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType); offset.value = position + 5; return Constants.OBJ_TREE; default: - throw new CorruptObjectException(id, "invalid type"); + throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType); } default: - throw new CorruptObjectException(id, "invalid type"); + throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType); } } catch (ArrayIndexOutOfBoundsException bad) { - throw new CorruptObjectException(id, "invalid type"); + throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType); } } @@ -481,7 +483,7 @@ public final class Constants { for (int k = r.length - 1; k >= 0; k--) { final char c = s.charAt(k); if (c > 127) - throw new IllegalArgumentException("Not ASCII string: " + s); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().notASCIIString, s)); r[k] = (byte) c; } return r; @@ -512,7 +514,7 @@ public final class Constants { static { if (OBJECT_ID_LENGTH != newMessageDigest().getDigestLength()) - throw new LinkageError("Incorrect OBJECT_ID_LENGTH."); + throw new LinkageError(JGitText.get().incorrectOBJECT_ID_LENGTH); CHARSET = Charset.forName(CHARACTER_ENCODING); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/DeltaOfsPackedObjectLoader.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/DeltaOfsPackedObjectLoader.java index 0b7c6c45f8..d0e98a2a92 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/DeltaOfsPackedObjectLoader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/DeltaOfsPackedObjectLoader.java @@ -48,6 +48,7 @@ package org.eclipse.jgit.lib; import java.io.IOException; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.CorruptObjectException; /** Reads a deltified object which uses an offset to find its base. */ @@ -75,7 +76,7 @@ class DeltaOfsPackedObjectLoader extends DeltaPackedObjectLoader { final ObjectId id = pack.findObjectForOffset(deltaBase); if (id == null) throw new CorruptObjectException( - "Offset-written delta base for object not found in a pack"); + JGitText.get().offsetWrittenDeltaBaseForObjectNotFoundInAPack); return id; } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/DeltaPackedObjectLoader.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/DeltaPackedObjectLoader.java index b42549943a..bbc1c62a8a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/DeltaPackedObjectLoader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/DeltaPackedObjectLoader.java @@ -47,8 +47,10 @@ package org.eclipse.jgit.lib; import java.io.IOException; +import java.text.MessageFormat; import java.util.zip.DataFormatException; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.CorruptObjectException; /** Reader for a deltified object stored in a pack file. */ @@ -93,8 +95,8 @@ abstract class DeltaPackedObjectLoader extends PackedObjectLoader { pack.saveCache(objectOffset, cachedBytes, objectType); } catch (DataFormatException dfe) { final CorruptObjectException coe; - coe = new CorruptObjectException("Object at " + objectOffset - + " in " + pack.getPackFile() + " has bad zlib stream"); + coe = new CorruptObjectException(MessageFormat.format(JGitText.get().objectAtHasBadZlibStream, + objectOffset, pack.getPackFile())); coe.initCause(dfe); throw coe; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/FileBasedConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/FileBasedConfig.java index 315c4670ad..eb00917917 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/FileBasedConfig.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/FileBasedConfig.java @@ -52,7 +52,9 @@ package org.eclipse.jgit.lib; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.util.IO; import org.eclipse.jgit.util.RawParseUtils; @@ -110,11 +112,11 @@ public class FileBasedConfig extends Config { } catch (FileNotFoundException noFile) { clear(); } catch (IOException e) { - final IOException e2 = new IOException("Cannot read " + getFile()); + final IOException e2 = new IOException(MessageFormat.format(JGitText.get().cannotReadFile, getFile())); e2.initCause(e); throw e2; } catch (ConfigInvalidException e) { - throw new ConfigInvalidException("Cannot read " + getFile(), e); + throw new ConfigInvalidException(MessageFormat.format(JGitText.get().cannotReadFile, getFile()), e); } } @@ -134,12 +136,12 @@ public class FileBasedConfig extends Config { final byte[] out = Constants.encode(toText()); final LockFile lf = new LockFile(getFile()); if (!lf.lock()) - throw new IOException("Cannot lock " + getFile()); + throw new IOException(MessageFormat.format(JGitText.get().cannotLockFile, getFile())); try { lf.setNeedStatInformation(true); lf.write(out); if (!lf.commit()) - throw new IOException("Cannot commit write to " + getFile()); + throw new IOException(MessageFormat.format(JGitText.get().cannotCommitWriteTo, getFile())); } finally { lf.unlock(); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitIndex.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitIndex.java index bba18408c8..0203d5d44a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitIndex.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitIndex.java @@ -59,6 +59,7 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.channels.FileChannel; import java.security.MessageDigest; +import java.text.MessageFormat; import java.util.Comparator; import java.util.Date; import java.util.Iterator; @@ -66,6 +67,7 @@ import java.util.Map; import java.util.Stack; import java.util.TreeMap; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.errors.NotSupportedException; @@ -238,7 +240,8 @@ public class GitIndex { buffer.order(ByteOrder.BIG_ENDIAN); int j = channel.read(buffer); if (j != buffer.capacity()) - throw new IOException("Could not read index in one go, only "+j+" out of "+buffer.capacity()+" read"); + throw new IOException(MessageFormat.format(JGitText.get().couldNotReadIndexInOneGo + , j, buffer.capacity())); buffer.flip(); header = new Header(buffer); entries.clear(); @@ -266,7 +269,7 @@ public class GitIndex { File tmpIndex = new File(cacheFile.getAbsoluteFile() + ".tmp"); File lock = new File(cacheFile.getAbsoluteFile() + ".lock"); if (!lock.createNewFile()) - throw new IOException("Index file is in use"); + throw new IOException(JGitText.get().indexFileIsInUse); try { FileOutputStream fileOutputStream = new FileOutputStream(tmpIndex); FileChannel fc = fileOutputStream.getChannel(); @@ -298,10 +301,10 @@ public class GitIndex { if (cacheFile.exists()) if (!cacheFile.delete()) throw new IOException( - "Could not rename delete old index"); + JGitText.get().couldNotRenameDeleteOldIndex); if (!tmpIndex.renameTo(cacheFile)) throw new IOException( - "Could not rename temporary index file to index"); + JGitText.get().couldNotRenameTemporaryIndexFileToIndex); changed = false; statDirty = false; lastCacheTime = cacheFile.lastModified(); @@ -309,10 +312,10 @@ public class GitIndex { } finally { if (!lock.delete()) throw new IOException( - "Could not delete lock file. Should not happen"); + JGitText.get().couldNotDeleteLockFileShouldNotHappen); if (tmpIndex.exists() && !tmpIndex.delete()) throw new IOException( - "Could not delete temporary index file. Should not happen"); + JGitText.get().couldNotDeleteTemporaryIndexFileShouldNotHappen); } } @@ -320,7 +323,7 @@ public class GitIndex { for (Iterator i = entries.values().iterator(); i.hasNext();) { Entry e = (Entry) i.next(); if (e.getStage() != 0) { - throw new NotSupportedException("Cannot work with other stages than zero right now. Won't write corrupt index."); + throw new NotSupportedException(JGitText.get().cannotWorkWithOtherStagesThanZeroRightNow); } } } @@ -339,7 +342,7 @@ public class GitIndex { static byte[] makeKey(File wd, File f) { if (!f.getPath().startsWith(wd.getPath())) - throw new Error("Path is not in working dir"); + throw new Error(JGitText.get().pathIsNotInWorkingDir); String relName = Repository.stripWorkDir(wd, f); return Constants.encode(relName); } @@ -608,7 +611,8 @@ public class GitIndex { if (!file.isDirectory()) return true; } else { - System.out.println("Does not handle mode "+mode+" ("+file+")"); + System.out.println(MessageFormat.format(JGitText.get().doesNotHandleMode + , mode, file)); return true; } } @@ -781,11 +785,11 @@ public class GitIndex { version = buf.getInt(); entries = buf.getInt(); if (signature != 0x44495243) - throw new CorruptObjectException("Index signature is invalid: " - + signature); + throw new CorruptObjectException(MessageFormat.format( + JGitText.get().indexSignatureIsInvalid, signature)); if (version != 2) - throw new CorruptObjectException( - "Unknown index version (or corrupt index):" + version); + throw new CorruptObjectException(MessageFormat.format( + JGitText.get().unknownIndexVersionOrCorruptIndex, version)); } void write(ByteBuffer buf) { @@ -877,7 +881,7 @@ public class GitIndex { ByteBuffer buffer = ByteBuffer.wrap(bytes); int j = channel.write(buffer); if (j != bytes.length) - throw new IOException("Could not write file " + file); + throw new IOException(MessageFormat.format(JGitText.get().couldNotWriteFile, file)); channel.close(); if (config_filemode() && File_hasExecute()) { if (FileMode.EXECUTABLE_FILE.equals(e.mode)) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexTreeWalker.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexTreeWalker.java index b1ee94eff7..12f9af727d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexTreeWalker.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexTreeWalker.java @@ -48,6 +48,7 @@ package org.eclipse.jgit.lib; import java.io.File; import java.io.IOException; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.lib.GitIndex.Entry; /** @@ -143,8 +144,8 @@ public class IndexTreeWalker { private void visitEntry(TreeEntry t1, TreeEntry t2, Entry i) throws IOException { - assert t1 != null || t2 != null || i != null : "Needs at least one entry"; - assert root != null : "Needs workdir"; + assert t1 != null || t2 != null || i != null : JGitText.get().needsAtLeastOneEntry; + assert root != null : JGitText.get().needsWorkdir; if (t1 != null && t1.getParent() == null) t1 = null; @@ -169,8 +170,8 @@ public class IndexTreeWalker { private void finishVisitTree(TreeEntry t1, TreeEntry t2, int curIndexPos) throws IOException { - assert t1 != null || t2 != null : "Needs at least one entry"; - assert root != null : "Needs workdir"; + assert t1 != null || t2 != null : JGitText.get().needsAtLeastOneEntry; + assert root != null : JGitText.get().needsWorkdir; if (t1 != null && t1.getParent() == null) t1 = null; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/LockFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/LockFile.java index bd773c4705..13f158dedf 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/LockFile.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/LockFile.java @@ -54,6 +54,9 @@ import java.io.IOException; import java.io.OutputStream; import java.nio.channels.FileLock; import java.nio.channels.OverlappingFileLockException; +import java.text.MessageFormat; + +import org.eclipse.jgit.JGitText; /** * Git style file locking and replacement. @@ -330,7 +333,7 @@ public class LockFile { private void requireLock() { if (os == null) { unlock(); - throw new IllegalStateException("Lock on " + ref + " not held."); + throw new IllegalStateException(MessageFormat.format(JGitText.get().lockOnNotHeld, ref)); } } @@ -382,7 +385,7 @@ public class LockFile { public boolean commit() { if (os != null) { unlock(); - throw new IllegalStateException("Lock on " + ref + " not closed."); + throw new IllegalStateException(MessageFormat.format(JGitText.get().lockOnNotClosed, ref)); } saveStatInformation(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/MutableObjectId.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/MutableObjectId.java index a6680d0551..2e0e0118f0 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/MutableObjectId.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/MutableObjectId.java @@ -46,6 +46,9 @@ package org.eclipse.jgit.lib; +import java.text.MessageFormat; + +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.InvalidObjectIdException; import org.eclipse.jgit.util.NB; import org.eclipse.jgit.util.RawParseUtils; @@ -162,7 +165,8 @@ public class MutableObjectId extends AnyObjectId { */ public void fromString(final String str) { if (str.length() != Constants.OBJECT_ID_STRING_LENGTH) - throw new IllegalArgumentException("Invalid id: " + str); + throw new IllegalArgumentException(MessageFormat.format( + JGitText.get().invalidId, str)); fromHexString(Constants.encodeASCII(str), 0); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java index 5906802d18..f32ae59510 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java @@ -48,6 +48,9 @@ import static org.eclipse.jgit.util.RawParseUtils.match; import static org.eclipse.jgit.util.RawParseUtils.nextLF; import static org.eclipse.jgit.util.RawParseUtils.parseBase10; +import java.text.MessageFormat; + +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.util.MutableInteger; @@ -123,7 +126,8 @@ public class ObjectChecker { checkBlob(raw); break; default: - throw new CorruptObjectException("Invalid object type: " + objType); + throw new CorruptObjectException(MessageFormat.format( + JGitText.get().corruptObjectInvalidType2, objType)); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDirectory.java index 024bd15b03..06700ebe1d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDirectory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDirectory.java @@ -48,6 +48,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -59,6 +60,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.PackMismatchException; import org.eclipse.jgit.lib.RepositoryCache.FileKey; import org.eclipse.jgit.util.FS; @@ -175,13 +177,13 @@ public class ObjectDirectory extends ObjectDatabase { final String i = idx.getName(); if (p.length() != 50 || !p.startsWith("pack-") || !p.endsWith(".pack")) - throw new IOException("Not a valid pack " + pack); + throw new IOException(MessageFormat.format(JGitText.get().notAValidPack, pack)); if (i.length() != 49 || !i.startsWith("pack-") || !i.endsWith(".idx")) - throw new IOException("Not a valid pack " + idx); + throw new IOException(MessageFormat.format(JGitText.get().notAValidPack, idx)); if (!p.substring(0, 45).equals(i.substring(0, 45))) - throw new IOException("Pack " + pack + "does not match index"); + throw new IOException(MessageFormat.format(JGitText.get().packDoesNotMatchIndex, pack)); insertPack(new PackFile(idx, pack)); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectWriter.java index b75328330f..ea57a0215e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectWriter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectWriter.java @@ -53,9 +53,11 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.security.MessageDigest; +import java.text.MessageFormat; import java.util.zip.Deflater; import java.util.zip.DeflaterOutputStream; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.ObjectWritingException; /** @@ -147,10 +149,8 @@ public class ObjectWriter { final ObjectId id = e.getId(); if (id == null) - throw new ObjectWritingException("Object at path \"" - + e.getFullName() + "\" does not have an id assigned." - + " All object ids must be assigned prior" - + " to writing a tree."); + throw new ObjectWritingException(MessageFormat.format( + JGitText.get().objectAtPathDoesNotHaveId, e.getFullName())); e.getMode().copyTo(o); o.write(' '); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackFile.java index 63f5162631..8f4e691630 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackFile.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackFile.java @@ -52,6 +52,7 @@ import java.io.OutputStream; import java.io.RandomAccessFile; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel.MapMode; +import java.text.MessageFormat; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; @@ -60,6 +61,7 @@ import java.util.zip.CRC32; import java.util.zip.CheckedOutputStream; import java.util.zip.DataFormatException; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.errors.PackInvalidException; import org.eclipse.jgit.errors.PackMismatchException; @@ -135,7 +137,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> { if (packChecksum == null) packChecksum = idx.packChecksum; else if (!Arrays.equals(packChecksum, idx.packChecksum)) - throw new PackMismatchException("Pack checksum mismatch"); + throw new PackMismatchException(JGitText.get().packChecksumMismatch); loadedIdx = idx; } catch (IOException e) { @@ -261,7 +263,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> { final WindowCursor curs) throws DataFormatException, IOException { final byte[] dstbuf = new byte[totalSize]; if (curs.inflate(this, position, dstbuf, 0) != totalSize) - throw new EOFException("Short compressed stream at " + position); + throw new EOFException(MessageFormat.format(JGitText.get().shortCompressedStreamAt, position)); return dstbuf; } @@ -289,15 +291,15 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> { final ObjectId id = findObjectForOffset(objectOffset); final long expected = idx.findCRC32(id); if (computed != expected) - throw new CorruptObjectException("Object at " + objectOffset - + " in " + getPackFile() + " has bad zlib stream"); + throw new CorruptObjectException(MessageFormat.format( + JGitText.get().objectAtHasBadZlibStream, objectOffset, getPackFile())); } else { try { curs.inflateVerify(this, dataOffset); } catch (DataFormatException dfe) { final CorruptObjectException coe; - coe = new CorruptObjectException("Object at " + objectOffset - + " in " + getPackFile() + " has bad zlib stream"); + coe = new CorruptObjectException(MessageFormat.format( + JGitText.get().objectAtHasBadZlibStream, objectOffset, getPackFile())); coe.initCause(dfe); throw coe; } @@ -433,24 +435,23 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> { IO.readFully(fd.getChannel(), 0, buf, 0, 12); if (RawParseUtils.match(buf, 0, Constants.PACK_SIGNATURE) != 4) - throw new IOException("Not a PACK file."); + throw new IOException(JGitText.get().notAPACKFile); final long vers = NB.decodeUInt32(buf, 4); final long packCnt = NB.decodeUInt32(buf, 8); if (vers != 2 && vers != 3) - throw new IOException("Unsupported pack version " + vers + "."); + throw new IOException(MessageFormat.format(JGitText.get().unsupportedPackVersion, vers)); if (packCnt != idx.getObjectCount()) - throw new PackMismatchException("Pack object count mismatch:" - + " pack " + packCnt - + " index " + idx.getObjectCount() - + ": " + getPackFile()); + throw new PackMismatchException(MessageFormat.format( + JGitText.get().packObjectCountMismatch, packCnt, idx.getObjectCount(), getPackFile())); IO.readFully(fd.getChannel(), length - 20, buf, 0, 20); if (!Arrays.equals(buf, packChecksum)) - throw new PackMismatchException("Pack checksum mismatch:" - + " pack " + ObjectId.fromRaw(buf).name() - + " index " + ObjectId.fromRaw(idx.packChecksum).name() - + ": " + getPackFile()); + throw new PackMismatchException(MessageFormat.format( + JGitText.get().packObjectCountMismatch + , ObjectId.fromRaw(buf).name() + , ObjectId.fromRaw(idx.packChecksum).name() + , getPackFile())); } private PackedObjectLoader reader(final WindowCursor curs, @@ -494,7 +495,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> { (int) dataSize, ObjectId.fromRaw(ib)); } default: - throw new IOException("Unknown object type " + typeCode + "."); + throw new IOException(MessageFormat.format(JGitText.get().unknownObjectType, typeCode)); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackIndex.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackIndex.java index 2043145b89..25b4f569c1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackIndex.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackIndex.java @@ -48,8 +48,10 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; +import java.text.MessageFormat; import java.util.Iterator; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.util.IO; import org.eclipse.jgit.util.NB; @@ -92,14 +94,14 @@ public abstract class PackIndex implements Iterable<PackIndex.MutableEntry> { case 2: return new PackIndexV2(fd); default: - throw new IOException("Unsupported pack index version " + v); + throw new IOException(MessageFormat.format(JGitText.get().unsupportedPackIndexVersion, v)); } } return new PackIndexV1(fd, hdr); } catch (IOException ioe) { final String path = idxFile.getAbsolutePath(); final IOException err; - err = new IOException("Unreadable pack index: " + path); + err = new IOException(MessageFormat.format(JGitText.get().unreadablePackIndex, path)); err.initCause(ioe); throw err; } finally { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackIndexV2.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackIndexV2.java index eb644c51c4..128b2df8cb 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackIndexV2.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackIndexV2.java @@ -49,6 +49,7 @@ import java.util.Arrays; import java.util.Iterator; import java.util.NoSuchElementException; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.util.IO; import org.eclipse.jgit.util.NB; @@ -111,7 +112,7 @@ class PackIndexV2 extends PackIndex { final long nameLen = bucketCnt * Constants.OBJECT_ID_LENGTH; if (nameLen > Integer.MAX_VALUE) - throw new IOException("Index file is too large for jgit"); + throw new IOException(JGitText.get().indexFileIsTooLargeForJgit); final int intNameLen = (int) nameLen; final byte[] raw = new byte[intNameLen]; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackIndexWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackIndexWriter.java index 5fcf71a781..4d2714bc55 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackIndexWriter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackIndexWriter.java @@ -48,8 +48,10 @@ import java.io.BufferedOutputStream; import java.io.IOException; import java.io.OutputStream; import java.security.DigestOutputStream; +import java.text.MessageFormat; import java.util.List; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.transport.PackedObjectInfo; import org.eclipse.jgit.util.NB; @@ -131,8 +133,8 @@ public abstract class PackIndexWriter { case 2: return new PackIndexWriterV2(dst); default: - throw new IllegalArgumentException( - "Unsupported pack index version " + version); + throw new IllegalArgumentException(MessageFormat.format( + JGitText.get().unsupportedPackIndexVersion, version)); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackIndexWriterV1.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackIndexWriterV1.java index b3be5480c9..eb44b3a8c7 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackIndexWriterV1.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackIndexWriterV1.java @@ -47,6 +47,7 @@ package org.eclipse.jgit.lib; import java.io.IOException; import java.io.OutputStream; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.transport.PackedObjectInfo; import org.eclipse.jgit.util.NB; @@ -73,7 +74,7 @@ class PackIndexWriterV1 extends PackIndexWriter { for (final PackedObjectInfo oe : entries) { if (!canStore(oe)) - throw new IOException("Pack too large for index version 1"); + throw new IOException(JGitText.get().packTooLargeForIndexVersion1); NB.encodeInt32(tmp, 0, (int) oe.getOffset()); oe.copyRawTo(tmp, 4); out.write(tmp); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackReverseIndex.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackReverseIndex.java index c0ed7b29a6..f4f57aed43 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackReverseIndex.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackReverseIndex.java @@ -43,8 +43,10 @@ package org.eclipse.jgit.lib; +import java.text.MessageFormat; import java.util.Arrays; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.lib.PackIndex.MutableEntry; @@ -94,7 +96,7 @@ class PackReverseIndex { if (n32 > Integer.MAX_VALUE || n64 > Integer.MAX_VALUE || cnt > 0xffffffffL) throw new IllegalArgumentException( - "Huge indexes are not supported by jgit, yet"); + JGitText.get().hugeIndexesAreNotSupportedByJgitYet); offsets32 = new int[(int) n32]; offsets64 = new long[(int) n64]; @@ -166,9 +168,9 @@ class PackReverseIndex { if (offset <= Integer.MAX_VALUE) { final int i32 = Arrays.binarySearch(offsets32, (int) offset); if (i32 < 0) - throw new CorruptObjectException( - "Can't find object in (reverse) pack index for the specified offset " - + offset); + throw new CorruptObjectException(MessageFormat.format( + JGitText.get().cantFindObjectInReversePackIndexForTheSpecifiedOffset + , offset)); if (i32 + 1 == offsets32.length) { if (offsets64.length > 0) @@ -179,9 +181,9 @@ class PackReverseIndex { } else { final int i64 = Arrays.binarySearch(offsets64, offset); if (i64 < 0) - throw new CorruptObjectException( - "Can't find object in (reverse) pack index for the specified offset " - + offset); + throw new CorruptObjectException(MessageFormat.format( + JGitText.get().cantFindObjectInReversePackIndexForTheSpecifiedOffset + , offset)); if (i64 + 1 == offsets64.length) return maxOffset; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackWriter.java index 4a205fffbe..48f41a5586 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackWriter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackWriter.java @@ -54,6 +54,7 @@ import java.util.Iterator; import java.util.List; import java.util.zip.Deflater; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.revwalk.ObjectWalk; @@ -103,7 +104,7 @@ public class PackWriter { * * @see #preparePack(Collection, Collection) */ - public static final String COUNTING_OBJECTS_PROGRESS = "Counting objects"; + public static final String COUNTING_OBJECTS_PROGRESS = JGitText.get().countingObjects; /** * Title of {@link ProgressMonitor} task used during searching for objects @@ -111,7 +112,7 @@ public class PackWriter { * * @see #writePack(OutputStream) */ - public static final String SEARCHING_REUSE_PROGRESS = "Compressing objects"; + public static final String SEARCHING_REUSE_PROGRESS = JGitText.get().compressingObjects; /** * Title of {@link ProgressMonitor} task used during writing out pack @@ -119,7 +120,7 @@ public class PackWriter { * * @see #writePack(OutputStream) */ - public static final String WRITING_OBJECTS_PROGRESS = "Writing objects"; + public static final String WRITING_OBJECTS_PROGRESS = JGitText.get().writingObjects; /** * Default value of deltas reuse option. @@ -605,7 +606,7 @@ public class PackWriter { for (ObjectToPack otp : list) { if (initMonitor.isCancelled()) throw new IOException( - "Packing cancelled during objects writing"); + JGitText.get().packingCancelledDuringObjectsWriting); reuseLoaders.clear(); searchForReuse(reuseLoaders, otp); initMonitor.update(1); @@ -688,7 +689,7 @@ public class PackWriter { for (ObjectToPack otp : list) { if (writeMonitor.isCancelled()) throw new IOException( - "Packing cancelled during objects writing"); + JGitText.get().packingCancelledDuringObjectsWriting); if (!otp.isWritten()) writeObject(otp); } @@ -727,7 +728,7 @@ public class PackWriter { reuse.endCopyRawData(); } } else if (otp.isDeltaRepresentation()) { - throw new IOException("creating deltas is not implemented"); + throw new IOException(JGitText.get().creatingDeltasIsNotImplemented); } else { writeWholeObjectDeflate(otp); } @@ -886,11 +887,11 @@ public class PackWriter { objectsLists[object.getType()].add(otp); } catch (ArrayIndexOutOfBoundsException x) { throw new IncorrectObjectTypeException(object, - "COMMIT nor TREE nor BLOB nor TAG"); + JGitText.get().incorrectObjectType_COMMITnorTREEnorBLOBnorTAG); } catch (UnsupportedOperationException x) { // index pointing to "dummy" empty list throw new IncorrectObjectTypeException(object, - "COMMIT nor TREE nor BLOB nor TAG"); + JGitText.get().incorrectObjectType_COMMITnorTREEnorBLOBnorTAG); } objectsMap.add(otp); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PersonIdent.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PersonIdent.java index 0bc2e7a2df..522f8477b1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PersonIdent.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PersonIdent.java @@ -45,11 +45,13 @@ package org.eclipse.jgit.lib; +import java.text.MessageFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.TimeZone; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.util.SystemReader; /** @@ -197,13 +199,13 @@ public class PersonIdent { public PersonIdent(final String in) { final int lt = in.indexOf('<'); if (lt == -1) { - throw new IllegalArgumentException("Malformed PersonIdent string" - + " (no < was found): " + in); + throw new IllegalArgumentException(MessageFormat.format( + JGitText.get().malformedpersonIdentString, in)); } final int gt = in.indexOf('>', lt); if (gt == -1) { - throw new IllegalArgumentException("Malformed PersonIdent string" - + " (no > was found): " + in); + throw new IllegalArgumentException(MessageFormat.format( + JGitText.get().malformedpersonIdentString, in)); } final int sp = in.indexOf(' ', gt + 2); if (sp == -1) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDirectory.java index faebbf67cc..5ba186955f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDirectory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDirectory.java @@ -67,11 +67,13 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; +import java.text.MessageFormat; import java.util.Arrays; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.ObjectWritingException; import org.eclipse.jgit.revwalk.RevObject; import org.eclipse.jgit.revwalk.RevTag; @@ -493,7 +495,8 @@ public class RefDirectory extends RefDatabase { if (packed.contains(name)) { LockFile lck = new LockFile(packedRefsFile); if (!lck.lock()) - throw new IOException("Cannot lock " + packedRefsFile); + throw new IOException(MessageFormat.format( + JGitText.get().cannotLockFile, packedRefsFile)); try { PackedRefList cur = readPackedRefs(0, 0); int idx = cur.find(name); @@ -574,7 +577,7 @@ public class RefDirectory extends RefDatabase { if (dir.exists()) throw err; if (!dir.mkdirs() && !dir.isDirectory()) - throw new IOException("Cannot create directory " + dir); + throw new IOException(MessageFormat.format(JGitText.get().cannotCreateDirectory, dir)); out = new FileOutputStream(log, true); } try { @@ -677,7 +680,7 @@ public class RefDirectory extends RefDatabase { if (p.charAt(0) == '^') { if (last == null) - throw new IOException("Peeled line before ref."); + throw new IOException(JGitText.get().peeledLineBeforeRef); ObjectId id = ObjectId.fromString(p.substring(1)); last = new ObjectIdRef.PeeledTag(PACKED, last.getName(), last @@ -721,18 +724,16 @@ public class RefDirectory extends RefDatabase { try { lck.write(content); } catch (IOException ioe) { - throw new ObjectWritingException("Unable to write " + name, - ioe); + throw new ObjectWritingException(MessageFormat.format(JGitText.get().unableToWrite, name), ioe); } try { lck.waitForStatChange(); } catch (InterruptedException e) { lck.unlock(); - throw new ObjectWritingException("Interrupted writing " - + name); + throw new ObjectWritingException(MessageFormat.format(JGitText.get().interruptedWriting, name)); } if (!lck.commit()) - throw new ObjectWritingException("Unable to write " + name); + throw new ObjectWritingException(MessageFormat.format(JGitText.get().unableToWrite, name)); packedRefs.compareAndSet(oldPackedList, new PackedRefList(refs, content.length, lck.getCommitLastModified())); @@ -795,7 +796,7 @@ public class RefDirectory extends RefDatabase { n--; if (n < 6) { String content = RawParseUtils.decode(buf, 0, n); - throw new IOException("Not a ref: " + name + ": " + content); + throw new IOException(MessageFormat.format(JGitText.get().notARef, name, content)); } final String target = RawParseUtils.decode(buf, 5, n); return newSymbolicRef(modified, name, target); @@ -811,7 +812,7 @@ public class RefDirectory extends RefDatabase { while (0 < n && Character.isWhitespace(buf[n - 1])) n--; String content = RawParseUtils.decode(buf, 0, n); - throw new IOException("Not a ref: " + name + ": " + content); + throw new IOException(MessageFormat.format(JGitText.get().notARef, name, content)); } return new LooseUnpeeled(modified, name, id); } @@ -889,7 +890,7 @@ public class RefDirectory extends RefDatabase { static void delete(final File file, final int depth) throws IOException { if (!file.delete() && file.isFile()) - throw new IOException("File cannot be deleted: " + file); + throw new IOException(MessageFormat.format(JGitText.get().fileCannotBeDeleted, file)); File dir = file.getParentFile(); for (int i = 0; i < depth; ++i) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java index 553266284b..89f59150a0 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java @@ -45,7 +45,9 @@ package org.eclipse.jgit.lib; import java.io.IOException; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevObject; @@ -395,7 +397,7 @@ public abstract class RefUpdate { private void requireCanDoUpdate() { if (newValue == null) - throw new IllegalStateException("A NewObjectId is required."); + throw new IllegalStateException(JGitText.get().aNewObjectIdIsRequired); } /** @@ -524,7 +526,7 @@ public abstract class RefUpdate { */ public Result link(String target) throws IOException { if (!target.startsWith(Constants.R_REFS)) - throw new IllegalArgumentException("Not " + Constants.R_REFS); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().illegalArgumentNotA, Constants.R_REFS)); if (getRefDatabase().isNameConflicting(getName())) return Result.LOCK_FAILURE; try { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ReflogReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ReflogReader.java index b394f34bb7..4c5503f321 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ReflogReader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ReflogReader.java @@ -51,6 +51,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.util.IO; import org.eclipse.jgit.util.RawParseUtils; @@ -75,24 +76,24 @@ public class ReflogReader { pos += Constants.OBJECT_ID_STRING_LENGTH; if (raw[pos++] != ' ') throw new IllegalArgumentException( - "Raw log message does not parse as log entry"); + JGitText.get().rawLogMessageDoesNotParseAsLogEntry); newId = ObjectId.fromString(raw, pos); pos += Constants.OBJECT_ID_STRING_LENGTH; if (raw[pos++] != ' ') { throw new IllegalArgumentException( - "Raw log message does not parse as log entry"); + JGitText.get().rawLogMessageDoesNotParseAsLogEntry); } who = RawParseUtils.parsePersonIdentOnly(raw, pos); int p0 = RawParseUtils.next(raw, pos, '\t'); // personident has no // \t if (p0 == -1) { throw new IllegalArgumentException( - "Raw log message does not parse as log entry"); + JGitText.get().rawLogMessageDoesNotParseAsLogEntry); } int p1 = RawParseUtils.nextLF(raw, p0); if (p1 == -1) { throw new IllegalArgumentException( - "Raw log message does not parse as log entry"); + JGitText.get().rawLogMessageDoesNotParseAsLogEntry); } comment = RawParseUtils.decode(raw, p0, p1 - 1); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java index 9f4bb100f8..e4d857bf8d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java @@ -48,6 +48,7 @@ package org.eclipse.jgit.lib; import java.io.File; import java.io.IOException; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -61,6 +62,7 @@ import java.util.Vector; import java.util.concurrent.atomic.AtomicInteger; import org.eclipse.jgit.dircache.DirCache; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.RevisionSyntaxException; @@ -191,7 +193,7 @@ public class Repository { if (d != null) gitDir = d; else - throw new IllegalArgumentException("Either GIT_DIR or GIT_WORK_TREE must be passed to Repository constructor"); + throw new IllegalArgumentException(JGitText.get().eitherGIT_DIRorGIT_WORK_TREEmustBePassed); } userConfig = SystemReader.getInstance().openUserConfig(); @@ -226,8 +228,8 @@ public class Repository { final String repositoryFormatVersion = getConfig().getString( "core", null, "repositoryFormatVersion"); if (!"0".equals(repositoryFormatVersion)) { - throw new IOException("Unknown repository format \"" - + repositoryFormatVersion + "\"; expected \"0\"."); + throw new IOException(MessageFormat.format( + JGitText.get().unknownRepositoryFormat2, repositoryFormatVersion)); } } } @@ -236,9 +238,8 @@ public class Repository { try { userConfig.load(); } catch (ConfigInvalidException e1) { - IOException e2 = new IOException("User config file " - + userConfig.getFile().getAbsolutePath() + " invalid: " - + e1); + IOException e2 = new IOException(MessageFormat.format( + JGitText.get().userConfigFileInvalid, userConfig.getFile().getAbsolutePath(), e1)); e2.initCause(e1); throw e2; } @@ -248,7 +249,7 @@ public class Repository { try { config.load(); } catch (ConfigInvalidException e1) { - IOException e2 = new IOException("Unknown repository format"); + IOException e2 = new IOException(JGitText.get().unknownRepositoryFormat); e2.initCause(e1); throw e2; } @@ -279,8 +280,7 @@ public class Repository { public void create(boolean bare) throws IOException { final RepositoryConfig cfg = getConfig(); if (cfg.getFile().exists()) { - throw new IllegalStateException("Repository already exists: " - + gitDir); + throw new IllegalStateException(MessageFormat.format(JGitText.get().repositoryAlreadyExists, gitDir)); } gitDir.mkdirs(); refs.create(); @@ -506,7 +506,7 @@ public class Repository { default: throw new IncorrectObjectTypeException(id, - "COMMIT nor TREE nor BLOB nor TAG"); + JGitText.get().incorrectObjectType_COMMITnorTREEnorBLOBnorTAG); } } @@ -727,7 +727,7 @@ public class Repository { pnum = Integer.parseInt(parentnum); } catch (NumberFormatException e) { throw new RevisionSyntaxException( - "Invalid commit parent number", + JGitText.get().invalidCommitParentNumber, revstr); } if (pnum != 0) { @@ -853,7 +853,7 @@ public class Repository { dist = Integer.parseInt(distnum); } catch (NumberFormatException e) { throw new RevisionSyntaxException( - "Invalid ancestry length", revstr); + JGitText.get().invalidAncestryLength, revstr); } while (dist > 0) { final ObjectId[] parents = ((Commit) ref).getParentIds(); @@ -877,7 +877,7 @@ public class Repository { } } if (time != null) - throw new RevisionSyntaxException("reflogs not yet supported by revision parser", revstr); + throw new RevisionSyntaxException(JGitText.get().reflogsNotYetSupportedByRevisionParser, revstr); i = m - 1; break; default: diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Tag.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Tag.java index 35ccf773cf..5b3531eb1f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Tag.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Tag.java @@ -48,7 +48,9 @@ import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStreamReader; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.errors.ObjectWritingException; @@ -135,18 +137,18 @@ public class Tag { new ByteArrayInputStream(raw))); String n = br.readLine(); if (n == null || !n.startsWith("object ")) { - throw new CorruptObjectException(tagId, "no object"); + throw new CorruptObjectException(tagId, JGitText.get().corruptObjectNoObject); } objId = ObjectId.fromString(n.substring(7)); n = br.readLine(); if (n == null || !n.startsWith("type ")) { - throw new CorruptObjectException(tagId, "no type"); + throw new CorruptObjectException(tagId, JGitText.get().corruptObjectNoType); } type = n.substring("type ".length()); n = br.readLine(); if (n == null || !n.startsWith("tag ")) { - throw new CorruptObjectException(tagId, "no tag name"); + throw new CorruptObjectException(tagId, JGitText.get().corruptObjectNoTagName); } tag = n.substring("tag ".length()); n = br.readLine(); @@ -154,13 +156,13 @@ public class Tag { // We should see a "tagger" header here, but some repos have tags // without it. if (n == null) - throw new CorruptObjectException(tagId, "no tagger header"); + throw new CorruptObjectException(tagId, JGitText.get().corruptObjectNoTaggerHeader); if (n.length()>0) if (n.startsWith("tagger ")) tagger = new PersonIdent(n.substring("tagger ".length())); else - throw new CorruptObjectException(tagId, "no tagger/bad header"); + throw new CorruptObjectException(tagId, JGitText.get().corruptObjectNoTaggerBadHeader); // Message should start with an empty line, but StringBuilder tempMessage = new StringBuilder(); @@ -196,7 +198,7 @@ public class Tag { */ public void tag() throws IOException { if (getTagId() != null) - throw new IllegalStateException("exists " + getTagId()); + throw new IllegalStateException(MessageFormat.format(JGitText.get().illegalStateExists, getTagId())); final ObjectId id; final RefUpdate ru; @@ -212,7 +214,7 @@ public class Tag { ru.setNewObjectId(id); ru.setRefLogMessage("tagged " + getTag(), false); if (ru.forceUpdate() == RefUpdate.Result.LOCK_FAILURE) - throw new ObjectWritingException("Unable to lock tag " + getTag()); + throw new ObjectWritingException(MessageFormat.format(JGitText.get().unableToLockTag, getTag())); } public String toString() { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Tree.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Tree.java index 61607cba95..2aa3098f17 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Tree.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Tree.java @@ -46,7 +46,9 @@ package org.eclipse.jgit.lib; import java.io.IOException; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.errors.EntryExistsException; import org.eclipse.jgit.errors.MissingObjectException; @@ -245,7 +247,7 @@ public class Tree extends TreeEntry implements Treeish { */ public void unload() { if (isModified()) - throw new IllegalStateException("Cannot unload a modified tree."); + throw new IllegalStateException(JGitText.get().cannotUnloadAModifiedTree); contents = null; } @@ -555,14 +557,14 @@ public class Tree extends TreeEntry implements Treeish { while (rawPtr < rawSize) { int c = raw[rawPtr++]; if (c < '0' || c > '7') - throw new CorruptObjectException(getId(), "invalid entry mode"); + throw new CorruptObjectException(getId(), JGitText.get().corruptObjectInvalidEntryMode); int mode = c - '0'; for (;;) { c = raw[rawPtr++]; if (' ' == c) break; else if (c < '0' || c > '7') - throw new CorruptObjectException(getId(), "invalid mode"); + throw new CorruptObjectException(getId(), JGitText.get().corruptObjectInvalidMode); mode <<= 3; mode += c - '0'; } @@ -589,8 +591,8 @@ public class Tree extends TreeEntry implements Treeish { else if (FileMode.GITLINK.equals(mode)) ent = new GitlinkTreeEntry(this, id, name); else - throw new CorruptObjectException(getId(), "Invalid mode: " - + Integer.toOctalString(mode)); + throw new CorruptObjectException(getId(), MessageFormat.format( + JGitText.get().corruptObjectInvalidMode2, Integer.toOctalString(mode))); temp[nextIndex++] = ent; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/TreeIterator.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/TreeIterator.java index 937baf6cc5..1f46c8f1b9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/TreeIterator.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/TreeIterator.java @@ -47,6 +47,8 @@ package org.eclipse.jgit.lib; import java.io.IOException; import java.util.Iterator; +import org.eclipse.jgit.JGitText; + /** * A tree iterator iterates over a tree and all its members recursing into * subtrees according to order. @@ -204,6 +206,6 @@ public class TreeIterator implements Iterator<TreeEntry> { public void remove() { throw new IllegalStateException( - "TreeIterator does not support remove()"); + JGitText.get().treeIteratorDoesNotSupportRemove); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/UnpackedObjectLoader.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/UnpackedObjectLoader.java index 96a1f80241..cd2eb38ef1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/UnpackedObjectLoader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/UnpackedObjectLoader.java @@ -50,6 +50,7 @@ import java.io.IOException; import java.util.zip.DataFormatException; import java.util.zip.Inflater; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.util.IO; import org.eclipse.jgit.util.MutableInteger; @@ -118,25 +119,25 @@ public class UnpackedObjectLoader extends ObjectLoader { hdr.length - avail); if (uncompressed == 0) { throw new CorruptObjectException(id, - "bad stream, corrupt header"); + JGitText.get().corruptObjectBadStreamCorruptHeader); } avail += uncompressed; } catch (DataFormatException dfe) { final CorruptObjectException coe; - coe = new CorruptObjectException(id, "bad stream"); + coe = new CorruptObjectException(id, JGitText.get().corruptObjectBadStream); coe.initCause(dfe); throw coe; } if (avail < 5) - throw new CorruptObjectException(id, "no header"); + throw new CorruptObjectException(id, JGitText.get().corruptObjectNoHeader); final MutableInteger p = new MutableInteger(); objectType = Constants.decodeTypeString(id, hdr, (byte) ' ', p); objectSize = RawParseUtils.parseBase10(hdr, p.value, p); if (objectSize < 0) - throw new CorruptObjectException(id, "negative size"); + throw new CorruptObjectException(id, JGitText.get().corruptObjectNegativeSize); if (hdr[p.value++] != 0) - throw new CorruptObjectException(id, "garbage after size"); + throw new CorruptObjectException(id, JGitText.get().corruptObjectGarbageAfterSize); bytes = new byte[objectSize]; if (p.value < avail) System.arraycopy(hdr, p.value, bytes, 0, avail - p.value); @@ -161,7 +162,7 @@ public class UnpackedObjectLoader extends ObjectLoader { objectType = typeCode; break; default: - throw new CorruptObjectException(id, "invalid type"); + throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType); } objectSize = size; @@ -182,17 +183,17 @@ public class UnpackedObjectLoader extends ObjectLoader { p += uncompressed; if (uncompressed == 0 && !inf.finished()) { throw new CorruptObjectException(id, - "bad stream, corrupt header"); + JGitText.get().corruptObjectBadStreamCorruptHeader); } } } catch (DataFormatException dfe) { final CorruptObjectException coe; - coe = new CorruptObjectException(id, "bad stream"); + coe = new CorruptObjectException(id, JGitText.get().corruptObjectBadStream); coe.initCause(dfe); throw coe; } if (p != objectSize) - throw new CorruptObjectException(id, "incorrect length"); + throw new CorruptObjectException(id, JGitText.get().corruptObjectIncorrectLength); } @Override diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/WholePackedObjectLoader.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/WholePackedObjectLoader.java index 5005d37f18..fcfa57339e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/WholePackedObjectLoader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/WholePackedObjectLoader.java @@ -46,8 +46,10 @@ package org.eclipse.jgit.lib; import java.io.IOException; +import java.text.MessageFormat; import java.util.zip.DataFormatException; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.CorruptObjectException; /** Reader for a non-delta (just deflated) object in a pack file. */ @@ -84,8 +86,8 @@ class WholePackedObjectLoader extends PackedObjectLoader { pack.saveCache(objectOffset, cachedBytes, objectType); } catch (DataFormatException dfe) { final CorruptObjectException coe; - coe = new CorruptObjectException("Object at " + objectOffset - + " in " + pack.getPackFile() + " has bad zlib stream"); + coe = new CorruptObjectException(MessageFormat.format(JGitText.get().objectAtHasBadZlibStream, + objectOffset, pack.getPackFile())); coe.initCause(dfe); throw coe; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/WindowCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/WindowCache.java index b2c79c1089..a44a30ee2d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/WindowCache.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/WindowCache.java @@ -53,6 +53,8 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReferenceArray; import java.util.concurrent.locks.ReentrantLock; +import org.eclipse.jgit.JGitText; + /** * Caches slices of a {@link PackFile} in memory for faster read access. * <p> @@ -121,9 +123,9 @@ import java.util.concurrent.locks.ReentrantLock; public class WindowCache { private static final int bits(int newSize) { if (newSize < 4096) - throw new IllegalArgumentException("Invalid window size"); + throw new IllegalArgumentException(JGitText.get().invalidWindowSize); if (Integer.bitCount(newSize) != 1) - throw new IllegalArgumentException("Window size must be power of 2"); + throw new IllegalArgumentException(JGitText.get().windowSizeMustBePowerOf2); return Integer.numberOfTrailingZeros(newSize); } @@ -247,9 +249,9 @@ public class WindowCache { tableSize = tableSize(cfg); final int lockCount = lockCount(cfg); if (tableSize < 1) - throw new IllegalArgumentException("tSize must be >= 1"); + throw new IllegalArgumentException(JGitText.get().tSizeMustBeGreaterOrEqual1); if (lockCount < 1) - throw new IllegalArgumentException("lockCount must be >= 1"); + throw new IllegalArgumentException(JGitText.get().lockCountMustBeGreaterOrEqual1); queue = new ReferenceQueue<ByteWindow>(); clock = new AtomicLong(1); @@ -278,9 +280,9 @@ public class WindowCache { openBytes = new AtomicLong(); if (maxFiles < 1) - throw new IllegalArgumentException("Open files must be >= 1"); + throw new IllegalArgumentException(JGitText.get().openFilesMustBeAtLeast1); if (maxBytes < windowSize) - throw new IllegalArgumentException("Window size must be < limit"); + throw new IllegalArgumentException(JGitText.get().windowSizeMustBeLesserThanLimit); } int getOpenFiles() { @@ -343,9 +345,9 @@ public class WindowCache { final int wsz = cfg.getPackedGitWindowSize(); final long limit = cfg.getPackedGitLimit(); if (wsz <= 0) - throw new IllegalArgumentException("Invalid window size"); + throw new IllegalArgumentException(JGitText.get().invalidWindowSize); if (limit < wsz) - throw new IllegalArgumentException("Window size must be < limit"); + throw new IllegalArgumentException(JGitText.get().windowSizeMustBeLesserThanLimit); return (int) Math.min(5 * (limit / wsz) / 2, 2000000000); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/WorkDirCheckout.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/WorkDirCheckout.java index 76585add1e..ee78202868 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/WorkDirCheckout.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/WorkDirCheckout.java @@ -49,9 +49,11 @@ package org.eclipse.jgit.lib; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.HashMap; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.CheckoutConflictException; import org.eclipse.jgit.lib.GitIndex.Entry; @@ -189,7 +191,7 @@ public class WorkDirCheckout { for (String c : conflicts) { File conflict = new File(root, c); if (!conflict.delete()) - throw new CheckoutConflictException("Cannot delete file: " + c); + throw new CheckoutConflictException(MessageFormat.format(JGitText.get().cannotDeleteFile, c)); removeEmptyParents(conflict); } for (String r : removed) { @@ -263,7 +265,7 @@ public class WorkDirCheckout { public void visitEntry(TreeEntry treeEntry, TreeEntry auxEntry, Entry indexEntry, File file) throws IOException { if (treeEntry instanceof Tree || auxEntry instanceof Tree) { - throw new IllegalArgumentException("Can't pass me a tree!"); + throw new IllegalArgumentException(JGitText.get().cantPassMeATree); } processEntry(treeEntry, auxEntry, indexEntry); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/WriteTree.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/WriteTree.java index 5bb4e535e0..bb97ccced0 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/WriteTree.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/WriteTree.java @@ -47,7 +47,9 @@ package org.eclipse.jgit.lib; import java.io.File; import java.io.IOException; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.GitlinksNotSupportedException; import org.eclipse.jgit.errors.SymlinksNotSupportedException; @@ -75,10 +77,8 @@ public class WriteTree extends TreeVisitorWithCurrentDirectory { public void visitSymlink(final SymlinkTreeEntry s) throws IOException { if (s.isModified()) { - throw new SymlinksNotSupportedException("Symlink \"" - + s.getFullName() - + "\" cannot be written as the link target" - + " cannot be read from within Java."); + throw new SymlinksNotSupportedException(MessageFormat.format( + JGitText.get().symlinkCannotBeWrittenAsTheLinkTarget, s.getFullName())); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeStrategy.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeStrategy.java index e7d84c68ac..d678f7c0fc 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeStrategy.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeStrategy.java @@ -44,8 +44,10 @@ package org.eclipse.jgit.merge; +import java.text.MessageFormat; import java.util.HashMap; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.lib.Repository; /** @@ -97,8 +99,7 @@ public abstract class MergeStrategy { public static synchronized void register(final String name, final MergeStrategy imp) { if (STRATEGIES.containsKey(name)) - throw new IllegalArgumentException("Merge strategy \"" + name - + "\" already exists as a default strategy"); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().mergeStrategyAlreadyExistsAsDefault, name)); STRATEGIES.put(name, imp); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/Merger.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/Merger.java index 275a6d68ff..38af20fb8f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/Merger.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/Merger.java @@ -44,7 +44,9 @@ package org.eclipse.jgit.merge; import java.io.IOException; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.Constants; @@ -180,10 +182,9 @@ public abstract class Merger { return new EmptyTreeIterator(); final RevCommit base2 = walk.next(); if (base2 != null) { - throw new IOException("Multiple merge bases for:" + "\n " - + sourceCommits[aIdx].name() + "\n " - + sourceCommits[bIdx].name() + "found:" + "\n " - + base.name() + "\n " + base2.name()); + throw new IOException(MessageFormat.format(JGitText.get().multipleMergeBasesFor + , sourceCommits[aIdx].name(), sourceCommits[bIdx].name() + , base.name(), base2.name())); } return openTree(base.getTree()); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/nls/NLS.java b/org.eclipse.jgit/src/org/eclipse/jgit/nls/NLS.java index f2e379e136..6f81af845b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/nls/NLS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/nls/NLS.java @@ -68,7 +68,8 @@ import org.eclipse.jgit.errors.TranslationStringMissingException; * </pre> */ public class NLS { - static final Locale ROOT_LOCALE = new Locale("", "", ""); + /** The root locale constant. It is defined here because the Locale.ROOT is not defined in Java 5 */ + public static final Locale ROOT_LOCALE = new Locale("", "", ""); private static final InheritableThreadLocal<NLS> local = new InheritableThreadLocal<NLS>() { protected NLS initialValue() { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/nls/TranslationBundle.java b/org.eclipse.jgit/src/org/eclipse/jgit/nls/TranslationBundle.java index c908aa0557..2c745e1f3e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/nls/TranslationBundle.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/nls/TranslationBundle.java @@ -99,7 +99,7 @@ import org.eclipse.jgit.errors.TranslationStringMissingException; * {@link ResourceBundle#getBundle(String, Locale)} method to load a resource * bundle. See the documentation of this method for a detailed explanation of * resource bundle loading strategy. After a bundle is created the - * {@link #getEffectiveLocale()} method can be used to determine whether the + * {@link #effectiveLocale()} method can be used to determine whether the * bundle really corresponds to the requested locale or is a fallback. * * <p> @@ -122,16 +122,24 @@ import org.eclipse.jgit.errors.TranslationStringMissingException; public abstract class TranslationBundle { private Locale effectiveLocale; + private ResourceBundle resourceBundle; /** * @return the locale locale used for loading the resource bundle from which * the field values were taken */ - public Locale getEffectiveLocale() { + public Locale effectiveLocale() { return effectiveLocale; } /** + * @return the resource bundle on which this translation bundle is based + */ + public ResourceBundle resourceBundle() { + return resourceBundle; + } + + /** * Injects locale specific text in all instance fields of this instance. * Only public instance fields of type <code>String</code> are considered. * <p> @@ -150,18 +158,17 @@ public abstract class TranslationBundle { */ void load(Locale locale) throws TranslationBundleLoadingException { Class bundleClass = getClass(); - ResourceBundle bundle; try { - bundle = ResourceBundle.getBundle(bundleClass.getName(), locale); + resourceBundle = ResourceBundle.getBundle(bundleClass.getName(), locale); } catch (MissingResourceException e) { throw new TranslationBundleLoadingException(bundleClass, locale, e); } - this.effectiveLocale = bundle.getLocale(); + this.effectiveLocale = resourceBundle.getLocale(); for (Field field : bundleClass.getFields()) { if (field.getType().equals(String.class)) { try { - String translatedText = bundle.getString(field.getName()); + String translatedText = resourceBundle.getString(field.getName()); field.set(this, translatedText); } catch (MissingResourceException e) { throw new TranslationStringMissingException(bundleClass, locale, field.getName(), e); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/patch/CombinedHunkHeader.java b/org.eclipse.jgit/src/org/eclipse/jgit/patch/CombinedHunkHeader.java index 781190539f..042c778510 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/patch/CombinedHunkHeader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/patch/CombinedHunkHeader.java @@ -48,7 +48,9 @@ import static org.eclipse.jgit.util.RawParseUtils.parseBase10; import java.io.IOException; import java.io.OutputStream; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.lib.AbbreviatedObjectId; import org.eclipse.jgit.util.MutableInteger; @@ -183,16 +185,14 @@ public class CombinedHunkHeader extends HunkHeader { final int cmp = o.nContext + o.nDeleted; if (cmp < o.lineCount) { final int missingCnt = o.lineCount - cmp; - script.error(buf, startOffset, "Truncated hunk, at least " - + missingCnt + " lines is missing for ancestor " - + (ancestor + 1)); + script.error(buf, startOffset, MessageFormat.format( + JGitText.get().truncatedHunkLinesMissingForAncestor, missingCnt, (ancestor + 1))); } } if (nContext + nAdded < newLineCount) { final int missingCount = newLineCount - (nContext + nAdded); - script.error(buf, startOffset, "Truncated hunk, at least " - + missingCount + " new lines is missing"); + script.error(buf, startOffset, MessageFormat.format(JGitText.get().truncatedHunkNewLinesMissing, missingCount)); } return c; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/patch/FileHeader.java b/org.eclipse.jgit/src/org/eclipse/jgit/patch/FileHeader.java index c35b613a22..25dc72af20 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/patch/FileHeader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/patch/FileHeader.java @@ -54,10 +54,12 @@ import static org.eclipse.jgit.util.RawParseUtils.parseBase10; import java.io.IOException; import java.nio.charset.CharacterCodingException; import java.nio.charset.Charset; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.diff.EditList; import org.eclipse.jgit.lib.AbbreviatedObjectId; import org.eclipse.jgit.lib.Constants; @@ -241,8 +243,7 @@ public class FileHeader { } if (charsetGuess != null && charsetGuess.length != getParentCount() + 1) - throw new IllegalArgumentException("Expected " - + (getParentCount() + 1) + " character encoding guesses"); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().expectedCharacterEncodingGuesses, (getParentCount() + 1))); if (trySimpleConversion(charsetGuess)) { Charset cs = charsetGuess != null ? charsetGuess[0] : null; @@ -302,7 +303,7 @@ public class FileHeader { } return r; } catch (IOException ioe) { - throw new RuntimeException("Cannot convert script to text", ioe); + throw new RuntimeException(JGitText.get().cannotConvertScriptToText, ioe); } finally { for (final TemporaryBuffer b : tmp) { if (b != null) @@ -410,7 +411,7 @@ public class FileHeader { void addHunk(final HunkHeader h) { if (h.getFileHeader() != this) - throw new IllegalArgumentException("Hunk belongs to another file"); + throw new IllegalArgumentException(JGitText.get().hunkBelongsToAnotherFile); if (hunks == null) hunks = new ArrayList<HunkHeader>(); hunks.add(h); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/patch/HunkHeader.java b/org.eclipse.jgit/src/org/eclipse/jgit/patch/HunkHeader.java index 9d78d0b99f..bfb20b64e9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/patch/HunkHeader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/patch/HunkHeader.java @@ -49,7 +49,9 @@ import static org.eclipse.jgit.util.RawParseUtils.parseBase10; import java.io.IOException; import java.io.OutputStream; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.diff.Edit; import org.eclipse.jgit.diff.EditList; import org.eclipse.jgit.lib.AbbreviatedObjectId; @@ -278,21 +280,21 @@ public class HunkHeader { if (nContext + old.nDeleted < old.lineCount) { final int missingCount = old.lineCount - (nContext + old.nDeleted); - script.error(buf, startOffset, "Truncated hunk, at least " - + missingCount + " old lines is missing"); + script.error(buf, startOffset, MessageFormat.format( + JGitText.get().truncatedHunkOldLinesMissing, missingCount)); } else if (nContext + old.nAdded < newLineCount) { final int missingCount = newLineCount - (nContext + old.nAdded); - script.error(buf, startOffset, "Truncated hunk, at least " - + missingCount + " new lines is missing"); + script.error(buf, startOffset, MessageFormat.format( + JGitText.get().truncatedHunkNewLinesMissing, missingCount)); } else if (nContext + old.nDeleted > old.lineCount || nContext + old.nAdded > newLineCount) { final String oldcnt = old.lineCount + ":" + newLineCount; final String newcnt = (nContext + old.nDeleted) + ":" + (nContext + old.nAdded); - script.warn(buf, startOffset, "Hunk header " + oldcnt - + " does not match body line count of " + newcnt); + script.warn(buf, startOffset, MessageFormat.format( + JGitText.get().hunkHeaderDoesNotMatchBodyLineCountOf, oldcnt, newcnt)); } return c; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/patch/Patch.java b/org.eclipse.jgit/src/org/eclipse/jgit/patch/Patch.java index eff5303dc5..ce006dadbf 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/patch/Patch.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/patch/Patch.java @@ -55,6 +55,7 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.List; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.util.TemporaryBuffer; /** A parsed collection of {@link FileHeader}s from a unified diff patch file */ @@ -175,7 +176,7 @@ public class Patch { // have missed a file header previously. The hunk // isn't valid without knowing where it comes from. // - error(buf, c, "Hunk disconnected from file"); + error(buf, c, JGitText.get().hunkDisconnectedFromFile); c = nextLF(buf, c); continue; } @@ -300,7 +301,7 @@ public class Patch { break; default: if (match(buf, c, SIG_FOOTER) < 0) - warn(buf, c, "Unexpected hunk trailer"); + warn(buf, c, JGitText.get().unexpectedHunkTrailer); } } continue; @@ -345,7 +346,7 @@ public class Patch { if (nEnd < 0) { // Not a binary hunk. // - error(fh.buf, c, "Missing forward-image in GIT binary patch"); + error(fh.buf, c, JGitText.get().missingForwardImageInGITBinaryPatch); return c; } c = nEnd; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java index 8f6d083a32..61eed3fa9a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java @@ -43,10 +43,12 @@ package org.eclipse.jgit.revplot; +import java.text.MessageFormat; import java.util.Collection; import java.util.HashSet; import java.util.TreeSet; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.revwalk.RevCommitList; import org.eclipse.jgit.revwalk.RevWalk; @@ -83,7 +85,7 @@ public class PlotCommitList<L extends PlotLane> extends @Override public void source(final RevWalk w) { if (!(w instanceof PlotWalk)) - throw new ClassCastException("Not a " + PlotWalk.class.getName()); + throw new ClassCastException(MessageFormat.format(JGitText.get().classCastNotA, PlotWalk.class.getName())); super.source(w); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotWalk.java index 66756ae996..6b4ed80e15 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotWalk.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotWalk.java @@ -51,6 +51,7 @@ import java.util.Comparator; import java.util.Map; import java.util.Set; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.Commit; import org.eclipse.jgit.lib.Ref; @@ -86,7 +87,7 @@ public class PlotWalk extends RevWalk { @Override public void sort(final RevSort s, final boolean use) { if (s == RevSort.TOPO && !use) - throw new IllegalArgumentException("Topological sort required."); + throw new IllegalArgumentException(JGitText.get().topologicalSortRequired); super.sort(s, use); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/MergeBaseGenerator.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/MergeBaseGenerator.java index 2f01f541de..edb883714b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/MergeBaseGenerator.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/MergeBaseGenerator.java @@ -44,7 +44,9 @@ package org.eclipse.jgit.revwalk; import java.io.IOException; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; @@ -118,7 +120,7 @@ class MergeBaseGenerator extends Generator { // commit admitted to the initial queue only once. If // we see this marks aren't correctly erased. // - throw new IllegalStateException("Stale RevFlags on " + c.name()); + throw new IllegalStateException(MessageFormat.format(JGitText.get().staleRevFlagsOn, c.name())); } c.flags |= flag; pending.add(c); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/ObjectWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/ObjectWalk.java index ddf40ac104..11d40012c5 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/ObjectWalk.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/ObjectWalk.java @@ -44,7 +44,9 @@ package org.eclipse.jgit.revwalk; import java.io.IOException; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; @@ -273,10 +275,8 @@ public class ObjectWalk extends RevWalk { if (FileMode.GITLINK.equals(mode)) break; treeWalk.getEntryObjectId(idBuffer); - throw new CorruptObjectException("Invalid mode " + mode - + " for " + idBuffer.name() + " '" - + treeWalk.getEntryPathString() + "' in " - + currentTree.name() + "."); + throw new CorruptObjectException(MessageFormat.format(JGitText.get().corruptObjectInvalidMode3 + , mode , idBuffer.name() , treeWalk.getEntryPathString() , currentTree.name())); } treeWalk = treeWalk.next(); @@ -428,9 +428,8 @@ public class ObjectWalk extends RevWalk { if (FileMode.GITLINK.equals(mode)) break; treeWalk.getEntryObjectId(idBuffer); - throw new CorruptObjectException("Invalid mode " + mode - + " for " + idBuffer.name() + " " - + treeWalk.getEntryPathString() + " in " + tree + "."); + throw new CorruptObjectException(MessageFormat.format(JGitText.get().corruptObjectInvalidMode3 + , mode , idBuffer.name() , treeWalk.getEntryPathString() , tree)); } treeWalk = treeWalk.next(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevFlag.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevFlag.java index 83f57d266d..e09fae43a8 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevFlag.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevFlag.java @@ -43,6 +43,10 @@ package org.eclipse.jgit.revwalk; +import java.text.MessageFormat; + +import org.eclipse.jgit.JGitText; + /** * Application level mark bit for {@link RevObject}s. * <p> @@ -94,8 +98,8 @@ public class RevFlag { @Override public RevWalk getRevWalk() { - throw new UnsupportedOperationException(toString() - + " is a static flag and has no RevWalk instance"); + throw new UnsupportedOperationException(MessageFormat.format( + JGitText.get().isAStaticFlagAndHasNorevWalkInstance, toString())); } } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevObjectList.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevObjectList.java index 0454b6ea77..5f8f419569 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevObjectList.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevObjectList.java @@ -45,8 +45,11 @@ package org.eclipse.jgit.revwalk; +import java.text.MessageFormat; import java.util.AbstractList; +import org.eclipse.jgit.JGitText; + /** * An ordered list of {@link RevObject} subclasses. * @@ -77,7 +80,7 @@ public class RevObjectList<E extends RevObject> extends AbstractList<E> { public void add(final int index, final E element) { if (index != size) - throw new UnsupportedOperationException("Not add-at-end: " + index); + throw new UnsupportedOperationException(MessageFormat.format(JGitText.get().unsupportedOperationNotAddAtEnd, index)); set(index, element); size++; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java index 4c43aa14e1..94e11752c6 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java @@ -45,11 +45,13 @@ package org.eclipse.jgit.revwalk; import java.io.IOException; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.EnumSet; import java.util.Iterator; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.errors.RevWalkException; @@ -630,7 +632,7 @@ public class RevWalk implements Iterable<RevCommit> { r = new RevTag(id); break; default: - throw new IllegalArgumentException("invalid git type: " + type); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().invalidGitType, type)); } objects.add(r); } @@ -755,7 +757,7 @@ public class RevWalk implements Iterable<RevCommit> { break; } default: - throw new IllegalArgumentException("Bad object type: " + type); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().badObjectType, type)); } objects.add(r); } else @@ -820,8 +822,8 @@ public class RevWalk implements Iterable<RevCommit> { int allocFlag() { if (freeFlags == 0) - throw new IllegalArgumentException(32 - RESERVED_FLAGS - + " flags already created."); + throw new IllegalArgumentException(MessageFormat.format( + JGitText.get().flagsAlreadyCreated, 32 - RESERVED_FLAGS)); final int m = Integer.lowestOneBit(freeFlags); freeFlags &= ~m; return m; @@ -838,9 +840,9 @@ public class RevWalk implements Iterable<RevCommit> { */ public void carry(final RevFlag flag) { if ((freeFlags & flag.mask) != 0) - throw new IllegalArgumentException(flag.name + " is disposed."); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().flagIsDisposed, flag.name)); if (flag.walker != this) - throw new IllegalArgumentException(flag.name + " not from this."); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().flagNotFromThis, flag.name)); carryFlags |= flag.mask; } @@ -1059,7 +1061,7 @@ public class RevWalk implements Iterable<RevCommit> { protected void assertNotStarted() { if (isNotStarted()) return; - throw new IllegalStateException("Output has already been started."); + throw new IllegalStateException(JGitText.get().outputHasAlreadyBeenStarted); } private boolean isNotStarted() { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/StartGenerator.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/StartGenerator.java index c5353fe8c5..5e778a416e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/StartGenerator.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/StartGenerator.java @@ -46,7 +46,9 @@ package org.eclipse.jgit.revwalk; import java.io.IOException; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.revwalk.filter.AndRevFilter; @@ -88,8 +90,8 @@ class StartGenerator extends Generator { // use the bulk of the generator pipeline. // if (tf != TreeFilter.ALL) - throw new IllegalStateException("Cannot combine TreeFilter " - + tf + " with RevFilter " + rf + "."); + throw new IllegalStateException(MessageFormat.format( + JGitText.get().cannotCombineTreeFilterWithRevFilter, tf, rf)); final MergeBaseGenerator mbg = new MergeBaseGenerator(w); walker.pending = mbg; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/AndRevFilter.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/AndRevFilter.java index 112f07aede..d4790f870c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/AndRevFilter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/AndRevFilter.java @@ -47,6 +47,7 @@ package org.eclipse.jgit.revwalk.filter; import java.io.IOException; import java.util.Collection; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.revwalk.RevCommit; @@ -90,7 +91,7 @@ public abstract class AndRevFilter extends RevFilter { if (list.length == 2) return create(list[0], list[1]); if (list.length < 2) - throw new IllegalArgumentException("At least two filters needed."); + throw new IllegalArgumentException(JGitText.get().atLeastTwoFiltersNeeded); final RevFilter[] subfilters = new RevFilter[list.length]; System.arraycopy(list, 0, subfilters, 0, list.length); return new List(subfilters); @@ -106,7 +107,7 @@ public abstract class AndRevFilter extends RevFilter { */ public static RevFilter create(final Collection<RevFilter> list) { if (list.size() < 2) - throw new IllegalArgumentException("At least two filters needed."); + throw new IllegalArgumentException(JGitText.get().atLeastTwoFiltersNeeded); final RevFilter[] subfilters = new RevFilter[list.size()]; list.toArray(subfilters); if (subfilters.length == 2) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/AuthorRevFilter.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/AuthorRevFilter.java index 2ede91b57f..3f88c7b8c3 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/AuthorRevFilter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/AuthorRevFilter.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.revwalk.filter; import java.util.regex.Pattern; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.util.RawCharSequence; import org.eclipse.jgit.util.RawParseUtils; @@ -68,7 +69,7 @@ public class AuthorRevFilter { */ public static RevFilter create(String pattern) { if (pattern.length() == 0) - throw new IllegalArgumentException("Cannot match on empty string."); + throw new IllegalArgumentException(JGitText.get().cannotMatchOnEmptyString); if (SubStringRevFilter.safe(pattern)) return new SubStringSearch(pattern); return new PatternSearch(pattern); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/CommitterRevFilter.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/CommitterRevFilter.java index 59c3e080d5..e607f4f920 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/CommitterRevFilter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/CommitterRevFilter.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.revwalk.filter; import java.util.regex.Pattern; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.util.RawCharSequence; import org.eclipse.jgit.util.RawParseUtils; @@ -68,7 +69,7 @@ public class CommitterRevFilter { */ public static RevFilter create(String pattern) { if (pattern.length() == 0) - throw new IllegalArgumentException("Cannot match on empty string."); + throw new IllegalArgumentException(JGitText.get().cannotMatchOnEmptyString); if (SubStringRevFilter.safe(pattern)) return new SubStringSearch(pattern); return new PatternSearch(pattern); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/MessageRevFilter.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/MessageRevFilter.java index 6ab3b1d3b0..e40fb01835 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/MessageRevFilter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/MessageRevFilter.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.revwalk.filter; import java.util.regex.Pattern; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.util.RawCharSequence; import org.eclipse.jgit.util.RawParseUtils; @@ -68,7 +69,7 @@ public class MessageRevFilter { */ public static RevFilter create(String pattern) { if (pattern.length() == 0) - throw new IllegalArgumentException("Cannot match on empty string."); + throw new IllegalArgumentException(JGitText.get().cannotMatchOnEmptyString); if (SubStringRevFilter.safe(pattern)) return new SubStringSearch(pattern); return new PatternSearch(pattern); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/OrRevFilter.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/OrRevFilter.java index bd1314a934..586c138fff 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/OrRevFilter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/OrRevFilter.java @@ -47,6 +47,7 @@ package org.eclipse.jgit.revwalk.filter; import java.io.IOException; import java.util.Collection; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.revwalk.RevCommit; @@ -88,7 +89,7 @@ public abstract class OrRevFilter extends RevFilter { if (list.length == 2) return create(list[0], list[1]); if (list.length < 2) - throw new IllegalArgumentException("At least two filters needed."); + throw new IllegalArgumentException(JGitText.get().atLeastTwoFiltersNeeded); final RevFilter[] subfilters = new RevFilter[list.length]; System.arraycopy(list, 0, subfilters, 0, list.length); return new List(subfilters); @@ -104,7 +105,7 @@ public abstract class OrRevFilter extends RevFilter { */ public static RevFilter create(final Collection<RevFilter> list) { if (list.size() < 2) - throw new IllegalArgumentException("At least two filters needed."); + throw new IllegalArgumentException(JGitText.get().atLeastTwoFiltersNeeded); final RevFilter[] subfilters = new RevFilter[list.size()]; list.toArray(subfilters); if (subfilters.length == 2) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/PatternMatchRevFilter.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/PatternMatchRevFilter.java index 5f2bcf26ab..c2a287958a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/PatternMatchRevFilter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/PatternMatchRevFilter.java @@ -48,6 +48,7 @@ import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.lib.Constants; @@ -101,7 +102,7 @@ public abstract class PatternMatchRevFilter extends RevFilter { protected PatternMatchRevFilter(String pattern, final boolean innerString, final boolean rawEncoding, final int flags) { if (pattern.length() == 0) - throw new IllegalArgumentException("Cannot match on empty string."); + throw new IllegalArgumentException(JGitText.get().cannotMatchOnEmptyString); patternText = pattern; if (innerString) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/RevFilter.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/RevFilter.java index 2d67d9763a..378c906992 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/RevFilter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/RevFilter.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.revwalk.filter; import java.io.IOException; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.errors.StopWalkException; @@ -157,7 +158,7 @@ public abstract class RevFilter { public static final RevFilter MERGE_BASE = new RevFilter() { @Override public boolean include(final RevWalk walker, final RevCommit c) { - throw new UnsupportedOperationException("Cannot be combined."); + throw new UnsupportedOperationException(JGitText.get().cannotBeCombined); } @Override diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java index c5d6db7e3e..0430b5fdca 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java @@ -60,6 +60,7 @@ import java.security.InvalidKeyException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.spec.InvalidKeySpecException; +import java.text.MessageFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; @@ -78,6 +79,7 @@ import java.util.TreeMap; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.NullProgressMonitor; import org.eclipse.jgit.lib.ProgressMonitor; @@ -158,7 +160,7 @@ public class AmazonS3 { try { return MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { - throw new RuntimeException("JRE lacks MD5 implementation", e); + throw new RuntimeException(JGitText.get().JRELacksMD5Implementation, e); } } @@ -211,11 +213,11 @@ public class AmazonS3 { public AmazonS3(final Properties props) { publicKey = props.getProperty("accesskey"); if (publicKey == null) - throw new IllegalArgumentException("Missing accesskey."); + throw new IllegalArgumentException(JGitText.get().missingAccesskey); final String secret = props.getProperty("secretkey"); if (secret == null) - throw new IllegalArgumentException("Missing secretkey."); + throw new IllegalArgumentException(JGitText.get().missingSecretkey); privateKey = new SecretKeySpec(Constants.encodeASCII(secret), HMAC); final String pacl = props.getProperty("acl", "PRIVATE"); @@ -241,9 +243,9 @@ public class AmazonS3 { encryption = WalkEncryption.NONE; } } catch (InvalidKeySpecException e) { - throw new IllegalArgumentException("Invalid encryption", e); + throw new IllegalArgumentException(JGitText.get().invalidEncryption, e); } catch (NoSuchAlgorithmException e) { - throw new IllegalArgumentException("Invalid encryption", e); + throw new IllegalArgumentException(JGitText.get().invalidEncryption, e); } maxAttempts = Integer.parseInt(props.getProperty( @@ -471,7 +473,7 @@ public class AmazonS3 { if (monitor == null) monitor = NullProgressMonitor.INSTANCE; if (monitorTask == null) - monitorTask = "Uploading " + key; + monitorTask = MessageFormat.format(JGitText.get().progressMonUploading, key); final String md5str = Base64.encodeBytes(csum); final long len = buf.length(); @@ -508,9 +510,8 @@ public class AmazonS3 { private IOException error(final String action, final String key, final HttpURLConnection c) throws IOException { - final IOException err = new IOException(action + " of '" + key - + "' failed: " + HttpSupport.response(c) + " " - + c.getResponseMessage()); + final IOException err = new IOException(MessageFormat.format(JGitText.get().amazonS3ActionFailed + , action, key, HttpSupport.response(c), c.getResponseMessage())); final ByteArrayOutputStream b = new ByteArrayOutputStream(); byte[] buf = new byte[2048]; for (;;) { @@ -527,8 +528,8 @@ public class AmazonS3 { } private IOException maxAttempts(final String action, final String key) { - return new IOException(action + " of '" + key + "' failed:" - + " Giving up after " + maxAttempts + " attempts."); + return new IOException(MessageFormat.format(JGitText.get().amazonS3ActionFailedGivingUp + , action, key, maxAttempts)); } private HttpURLConnection open(final String method, final String bucket, @@ -614,9 +615,9 @@ public class AmazonS3 { m.init(privateKey); sec = Base64.encodeBytes(m.doFinal(s.toString().getBytes("UTF-8"))); } catch (NoSuchAlgorithmException e) { - throw new IOException("No " + HMAC + " support:" + e.getMessage()); + throw new IOException(MessageFormat.format(JGitText.get().noHMACsupport, HMAC, e.getMessage())); } catch (InvalidKeyException e) { - throw new IOException("Invalid key: " + e.getMessage()); + throw new IOException(MessageFormat.format(JGitText.get().invalidKey, e.getMessage())); } c.setRequestProperty("Authorization", "AWS " + publicKey + ":" + sec); } @@ -668,7 +669,7 @@ public class AmazonS3 { try { xr = XMLReaderFactory.createXMLReader(); } catch (SAXException e) { - throw new IOException("No XML parser available."); + throw new IOException(JGitText.get().noXMLParserAvailable); } xr.setContentHandler(this); final InputStream in = c.getInputStream(); @@ -676,7 +677,7 @@ public class AmazonS3 { xr.parse(new InputSource(in)); } catch (SAXException parsingError) { final IOException p; - p = new IOException("Error listing " + prefix); + p = new IOException(MessageFormat.format(JGitText.get().errorListing, prefix)); p.initCause(parsingError); throw p; } finally { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseConnection.java index 1339b86913..30d3bb13e7 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseConnection.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseConnection.java @@ -52,6 +52,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Map; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.TransportException; import org.eclipse.jgit.lib.Ref; @@ -111,7 +112,7 @@ public abstract class BaseConnection implements Connection { protected void markStartedOperation() throws TransportException { if (startedOperation) throw new TransportException( - "Only one operation call per connection is supported."); + JGitText.get().onlyOneOperationCallPerConnectionIsSupported); startedOperation = true; } @@ -136,7 +137,7 @@ public abstract class BaseConnection implements Connection { */ protected void setMessageWriter(Writer writer) { if (messageWriter != null) - throw new IllegalStateException("Writer already initialized"); + throw new IllegalStateException(JGitText.get().writerAlreadyInitialized); messageWriter = writer; } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java index 7b6d3e121a..2927cada9c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java @@ -50,10 +50,12 @@ import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.text.MessageFormat; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.Set; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.NoRemoteRepositoryException; import org.eclipse.jgit.errors.PackProtocolException; import org.eclipse.jgit.errors.RemoteRepositoryException; @@ -230,8 +232,8 @@ abstract class BasePackConnection extends BaseConnection { name = name.substring(0, name.length() - 3); final Ref prior = avail.get(name); if (prior == null) - throw new PackProtocolException(uri, "advertisement of " - + name + "^{} came before " + name); + throw new PackProtocolException(uri, MessageFormat.format( + JGitText.get().advertisementCameBefore, name, name)); if (prior.getPeeledObjectId() != null) throw duplicateAdvertisement(name + "^{}"); @@ -258,7 +260,7 @@ abstract class BasePackConnection extends BaseConnection { * possibly why. */ protected TransportException noRepository() { - return new NoRemoteRepositoryException(uri, "not found."); + return new NoRemoteRepositoryException(uri, JGitText.get().notFound); } protected boolean isCapableOf(final String option) { @@ -274,8 +276,7 @@ abstract class BasePackConnection extends BaseConnection { } private PackProtocolException duplicateAdvertisement(final String name) { - return new PackProtocolException(uri, "duplicate advertisements of " - + name); + return new PackProtocolException(uri, MessageFormat.format(JGitText.get().duplicateAdvertisementsOf, name)); } @Override diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java index 7b90ec199f..2819ae26de 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java @@ -47,11 +47,13 @@ package org.eclipse.jgit.transport; import java.io.IOException; import java.io.InputStream; +import java.text.MessageFormat; import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.Set; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.PackProtocolException; import org.eclipse.jgit.errors.TransportException; import org.eclipse.jgit.lib.AnyObjectId; @@ -391,8 +393,7 @@ abstract class BasePackFetchConnection extends BasePackConnection implements // ACK status to tell us common objects for reuse in future // requests. If its not enabled, we can't talk to the peer. // - throw new PackProtocolException(uri, "stateless RPC requires " - + OPTION_MULTI_ACK_DETAILED + " to be enabled"); + throw new PackProtocolException(uri, MessageFormat.format(JGitText.get().statelessRPCRequiresOptionToBeEnabled, OPTION_MULTI_ACK_DETAILED)); } return line.toString(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackPushConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackPushConnection.java index e10cefd3ab..44ccd2d6ad 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackPushConnection.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackPushConnection.java @@ -45,10 +45,12 @@ package org.eclipse.jgit.transport; import java.io.IOException; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Map; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.NoRemoteRepositoryException; import org.eclipse.jgit.errors.NotSupportedException; import org.eclipse.jgit.errors.PackProtocolException; @@ -137,7 +139,7 @@ class BasePackPushConnection extends BasePackConnection implements } catch (TransportException e) { // Fall through. } - return new TransportException(uri, "push not permitted"); + return new TransportException(uri, JGitText.get().pushNotPermitted); } protected void doPush(final ProgressMonitor monitor, @@ -158,8 +160,7 @@ class BasePackPushConnection extends BasePackConnection implements // int b = in.read(); if (0 <= b) - throw new TransportException(uri, "expected EOF;" - + " received '" + (char) b + "' instead"); + throw new TransportException(uri, MessageFormat.format(JGitText.get().expectedEOFReceived, (char) b)); } } } catch (TransportException e) { @@ -201,7 +202,7 @@ class BasePackPushConnection extends BasePackConnection implements } if (monitor.isCancelled()) - throw new TransportException(uri, "push cancelled"); + throw new TransportException(uri, JGitText.get().pushCancelled); pckOut.end(); outNeedsEnd = false; } @@ -252,13 +253,11 @@ class BasePackPushConnection extends BasePackConnection implements throws IOException { final String unpackLine = readStringLongTimeout(); if (!unpackLine.startsWith("unpack ")) - throw new PackProtocolException(uri, "unexpected report line: " - + unpackLine); + throw new PackProtocolException(uri, MessageFormat.format(JGitText.get().unexpectedReportLine, unpackLine)); final String unpackStatus = unpackLine.substring("unpack ".length()); if (!unpackStatus.equals("ok")) - throw new TransportException(uri, - "error occurred during unpacking on the remote end: " - + unpackStatus); + throw new TransportException(uri, MessageFormat.format( + JGitText.get().errorOccurredDuringUnpackingOnTheRemoteEnd, unpackStatus)); String refLine; while ((refLine = pckIn.readString()) != PacketLineIn.END) { @@ -272,16 +271,15 @@ class BasePackPushConnection extends BasePackConnection implements refNameEnd = refLine.indexOf(" ", 3); } if (refNameEnd == -1) - throw new PackProtocolException(uri - + ": unexpected report line: " + refLine); + throw new PackProtocolException(MessageFormat.format(JGitText.get().unexpectedReportLine2 + , uri, refLine)); final String refName = refLine.substring(3, refNameEnd); final String message = (ok ? null : refLine .substring(refNameEnd + 1)); final RemoteRefUpdate rru = refUpdates.get(refName); if (rru == null) - throw new PackProtocolException(uri - + ": unexpected ref report: " + refName); + throw new PackProtocolException(MessageFormat.format(JGitText.get().unexpectedRefReport, uri, refName)); if (ok) { rru.setStatus(Status.OK); } else { @@ -291,9 +289,8 @@ class BasePackPushConnection extends BasePackConnection implements } for (final RemoteRefUpdate rru : refUpdates.values()) { if (rru.getStatus() == Status.AWAITING_REPORT) - throw new PackProtocolException(uri - + ": expected report for ref " + rru.getRemoteName() - + " not received"); + throw new PackProtocolException(MessageFormat.format( + JGitText.get().expectedReportForRefNotReceived , uri, rru.getRemoteName())); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java index c788244f74..3b97dfc0d6 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java @@ -50,6 +50,7 @@ package org.eclipse.jgit.transport; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -59,6 +60,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.MissingBundlePrerequisiteException; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.errors.PackProtocolException; @@ -101,7 +103,7 @@ class BundleFetchConnection extends BaseFetchConnection { readBundleV2(); break; default: - throw new TransportException(transport.uri, "not a bundle"); + throw new TransportException(transport.uri, JGitText.get().notABundle); } } catch (TransportException err) { close(); @@ -119,7 +121,7 @@ class BundleFetchConnection extends BaseFetchConnection { final String rev = readLine(new byte[1024]); if (TransportBundle.V2_BUNDLE_SIGNATURE.equals(rev)) return 2; - throw new TransportException(transport.uri, "not a bundle"); + throw new TransportException(transport.uri, JGitText.get().notABundle); } private void readBundleV2() throws IOException { @@ -151,7 +153,7 @@ class BundleFetchConnection extends BaseFetchConnection { private PackProtocolException duplicateAdvertisement(final String name) { return new PackProtocolException(transport.uri, - "duplicate advertisements of " + name); + MessageFormat.format(JGitText.get().duplicateAdvertisementsOf, name)); } private String readLine(final byte[] hdrbuf) throws IOException { @@ -227,8 +229,8 @@ class BundleFetchConnection extends BaseFetchConnection { } catch (MissingObjectException notFound) { missing.put(p, e.getValue()); } catch (IOException err) { - throw new TransportException(transport.uri, "Cannot read commit " - + p.name(), err); + throw new TransportException(transport.uri + , MessageFormat.format(JGitText.get().cannotReadCommit, p.name()), err); } } if (!missing.isEmpty()) @@ -253,7 +255,7 @@ class BundleFetchConnection extends BaseFetchConnection { } } } catch (IOException err) { - throw new TransportException(transport.uri, "Cannot read object", err); + throw new TransportException(transport.uri, JGitText.get().cannotReadObject, err); } if (remaining > 0) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleWriter.java index 7b0a5eec45..7e91557b09 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleWriter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleWriter.java @@ -47,11 +47,13 @@ import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; +import java.text.MessageFormat; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.TreeMap; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; @@ -112,9 +114,9 @@ public class BundleWriter { */ public void include(final String name, final AnyObjectId id) { if (!Repository.isValidRefName(name)) - throw new IllegalArgumentException("Invalid ref name: " + name); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().invalidRefName, name)); if (include.containsKey(name)) - throw new IllegalStateException("Duplicate ref: " + name); + throw new IllegalStateException(JGitText.get().duplicateRef + name); include.put(name, id.toObjectId()); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Daemon.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Daemon.java index cafcd7b4bd..39c7ae8f01 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Daemon.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Daemon.java @@ -57,6 +57,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.PersonIdent; import org.eclipse.jgit.lib.Repository; @@ -250,7 +251,7 @@ public class Daemon { */ public synchronized void start() throws IOException { if (acceptThread != null) - throw new IllegalStateException("Daemon already running"); + throw new IllegalStateException(JGitText.get().daemonAlreadyRunning); final ServerSocket listenSock = new ServerSocket( myAddress != null ? myAddress.getPort() : 0, BACKLOG, diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java index b86f86d2f9..fc203f69c8 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java @@ -48,6 +48,7 @@ import java.io.File; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.Writer; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -57,6 +58,7 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.errors.NotSupportedException; import org.eclipse.jgit.errors.TransportException; @@ -122,8 +124,8 @@ class FetchProcess { final Set<Ref> matched = new HashSet<Ref>(); for (final RefSpec spec : toFetch) { if (spec.getSource() == null) - throw new TransportException( - "Source ref not specified for refspec: " + spec); + throw new TransportException(MessageFormat.format( + JGitText.get().sourceRefNotSpecifiedForRefspec, spec)); if (spec.isWildcard()) expandWildcard(spec, matched); @@ -181,8 +183,8 @@ class FetchProcess { u.update(walk); result.add(u); } catch (IOException err) { - throw new TransportException("Failure updating tracking ref " - + u.getLocalName() + ": " + err.getMessage(), err); + throw new TransportException(MessageFormat.format( + JGitText.get().failureUpdatingTrackingRef, u.getLocalName(), err.getMessage()), err); } } @@ -190,8 +192,8 @@ class FetchProcess { try { updateFETCH_HEAD(result); } catch (IOException err) { - throw new TransportException("Failure updating FETCH_HEAD: " - + err.getMessage(), err); + throw new TransportException(MessageFormat.format( + JGitText.get().failureUpdatingFETCH_HEAD, err.getMessage()), err); } } } @@ -207,7 +209,7 @@ class FetchProcess { if (transport.isCheckFetchedObjects() && !conn.didFetchTestConnectivity() && !askForIsComplete()) throw new TransportException(transport.getURI(), - "peer did not supply a complete object graph"); + JGitText.get().peerDidNotSupplyACompleteObjectGraph); } private void closeConnection(final FetchResult result) { @@ -301,7 +303,7 @@ class FetchProcess { } catch (MissingObjectException e) { return false; } catch (IOException e) { - throw new TransportException("Unable to check connectivity.", e); + throw new TransportException(JGitText.get().unableToCheckConnectivity, e); } } @@ -317,8 +319,7 @@ class FetchProcess { throws TransportException { final Ref src = conn.getRef(spec.getSource()); if (src == null) { - throw new TransportException("Remote does not have " - + spec.getSource() + " available for fetch."); + throw new TransportException(MessageFormat.format(JGitText.get().remoteDoesNotHaveSpec, spec.getSource())); } if (matched.add(src)) want(src, spec); @@ -376,9 +377,8 @@ class FetchProcess { } catch (IOException err) { // Bad symbolic ref? That is the most likely cause. // - throw new TransportException("Cannot resolve" - + " local tracking ref " + spec.getDestination() - + " for updating.", err); + throw new TransportException( MessageFormat.format( + JGitText.get().cannotResolveLocalTrackingRefForUpdating, spec.getDestination()), err); } } @@ -432,13 +432,12 @@ class FetchProcess { case FORCED: break; default: - throw new TransportException(transport.getURI(), - "Cannot delete stale tracking ref " + name + ": " - + u.getResult().name()); + throw new TransportException(transport.getURI(), MessageFormat.format( + JGitText.get().cannotDeleteStaleTrackingRef2, name, u.getResult().name())); } } catch (IOException e) { - throw new TransportException(transport.getURI(), - "Cannot delete stale tracking ref " + name, e); + throw new TransportException(transport.getURI(), MessageFormat.format( + JGitText.get().cannotDeleteStaleTrackingRef, name), e); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/IndexPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/IndexPack.java index 6eeccea841..2a5b4344f5 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/IndexPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/IndexPack.java @@ -52,6 +52,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.RandomAccessFile; import java.security.MessageDigest; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -60,6 +61,7 @@ import java.util.zip.DataFormatException; import java.util.zip.Deflater; import java.util.zip.Inflater; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.lib.AnyObjectId; @@ -82,10 +84,10 @@ import org.eclipse.jgit.util.NB; /** Indexes Git pack files for local use. */ public class IndexPack { /** Progress message when reading raw data from the pack. */ - public static final String PROGRESS_DOWNLOAD = "Receiving objects"; + public static final String PROGRESS_DOWNLOAD = JGitText.get().receivingObjects; /** Progress message when computing names of delta compressed objects. */ - public static final String PROGRESS_RESOLVE_DELTA = "Resolving deltas"; + public static final String PROGRESS_RESOLVE_DELTA = JGitText.get().resolvingDeltas; /** * Size of the internal stream buffer. @@ -392,20 +394,19 @@ public class IndexPack { indexOneObject(); progress.update(1); if (progress.isCancelled()) - throw new IOException("Download cancelled"); + throw new IOException(JGitText.get().downloadCancelled); } readPackFooter(); endInput(); progress.endTask(); if (deltaCount > 0) { if (packOut == null) - throw new IOException("need packOut"); + throw new IOException(JGitText.get().needPackOut); resolveDeltas(progress); if (entryCount < objectCount) { if (!fixThin) { - throw new IOException("pack has " - + (objectCount - entryCount) - + " unresolved deltas"); + throw new IOException(MessageFormat.format( + JGitText.get().packHasUnresolvedDeltas, (objectCount - entryCount))); } fixThinPack(progress); } @@ -458,7 +459,7 @@ public class IndexPack { resolveDeltas(entries[i]); progress.update(entryCount - before); if (progress.isCancelled()) - throw new IOException("Download cancelled during indexing"); + throw new IOException(JGitText.get().downloadCancelledDuringIndexing); } progress.endTask(); } @@ -505,12 +506,12 @@ public class IndexPack { break; } default: - throw new IOException("Unknown object type " + typeCode + "."); + throw new IOException(MessageFormat.format(JGitText.get().unknownObjectType, typeCode)); } final int crc32 = (int) crc.getValue(); if (oldCRC != crc32) - throw new IOException("Corruption detected re-reading at " + pos); + throw new IOException(MessageFormat.format(JGitText.get().corruptionDetectedReReadingAt, pos)); if (oe == null) { objectDigest.update(Constants.encodedTypeString(type)); objectDigest.update((byte) ' '); @@ -602,7 +603,7 @@ public class IndexPack { resolveChildDeltas(oe.getOffset(), typeCode, data, oe); if (progress.isCancelled()) - throw new IOException("Download cancelled during indexing"); + throw new IOException(JGitText.get().downloadCancelledDuringIndexing); } def.end(); @@ -691,7 +692,7 @@ public class IndexPack { if (!Arrays.equals(origDigest.digest(), origcsum) || !Arrays.equals(tailDigest.digest(), tailcsum)) - throw new IOException("Pack corrupted while writing to filesystem"); + throw new IOException(JGitText.get().packCorruptedWhileWritingToFilesystem); packcsum = packDigest.digest(); packOut.write(packcsum); @@ -730,11 +731,11 @@ public class IndexPack { final int p = fillFromInput(hdrln); for (int k = 0; k < Constants.PACK_SIGNATURE.length; k++) if (buf[p + k] != Constants.PACK_SIGNATURE[k]) - throw new IOException("Not a PACK file."); + throw new IOException(JGitText.get().notAPACKFile); final long vers = NB.decodeUInt32(buf, p + 4); if (vers != 2 && vers != 3) - throw new IOException("Unsupported pack version " + vers + "."); + throw new IOException(MessageFormat.format(JGitText.get().unsupportedPackVersion, vers)); objectCount = NB.decodeUInt32(buf, p + 8); use(hdrln); } @@ -750,7 +751,7 @@ public class IndexPack { packOut.write(packcsum); if (!Arrays.equals(cmpcsum, packcsum)) - throw new CorruptObjectException("Packfile checksum incorrect."); + throw new CorruptObjectException(JGitText.get().corruptObjectPackfileChecksumIncorrect); } // Cleanup all resources associated with our input parsing. @@ -814,7 +815,7 @@ public class IndexPack { break; } default: - throw new IOException("Unknown object type " + typeCode + "."); + throw new IOException(MessageFormat.format(JGitText.get().unknownObjectType, typeCode)); } } @@ -839,9 +840,8 @@ public class IndexPack { try { objCheck.check(type, data); } catch (CorruptObjectException e) { - throw new IOException("Invalid " - + Constants.typeString(type) + " " + id.name() - + ":" + e.getMessage()); + throw new IOException(MessageFormat.format(JGitText.get().invalidObject + , Constants.typeString(type) , id.name() , e.getMessage())); } } @@ -849,7 +849,7 @@ public class IndexPack { if (ldr != null) { final byte[] existingData = ldr.getCachedBytes(); if (ldr.getType() != type || !Arrays.equals(data, existingData)) { - throw new IOException("Collision on " + id.name()); + throw new IOException(MessageFormat.format(JGitText.get().collisionOn, id.name())); } } } @@ -904,7 +904,7 @@ public class IndexPack { } next = in.read(buf, next, free); if (next <= 0) - throw new EOFException("Packfile is truncated."); + throw new EOFException(JGitText.get().packfileIsTruncated); bAvail += next; } return bOffset; @@ -924,7 +924,7 @@ public class IndexPack { } next = packOut.read(buf, next, free); if (next <= 0) - throw new EOFException("Packfile is truncated."); + throw new EOFException(JGitText.get().packfileIsTruncated); bAvail += next; } return bOffset; @@ -966,7 +966,7 @@ public class IndexPack { n += inf.inflate(dst, n, free); } if (n != sz) - throw new DataFormatException("wrong decompressed length"); + throw new DataFormatException(JGitText.get().wrongDecompressedLength); n = bAvail - inf.getRemaining(); if (n > 0) { crc.update(buf, p, n); @@ -998,7 +998,7 @@ public class IndexPack { n += inf.inflate(dst, n, dst.length - n); } if (n != sz) - throw new DataFormatException("wrong decompressed length"); + throw new DataFormatException(JGitText.get().wrongDecompressedLength); n = bAvail - inf.getRemaining(); if (n > 0) { crc.update(buf, p, n); @@ -1043,8 +1043,8 @@ public class IndexPack { } private static CorruptObjectException corrupt(final DataFormatException dfe) { - return new CorruptObjectException("Packfile corruption detected: " - + dfe.getMessage()); + return new CorruptObjectException(MessageFormat.format( + JGitText.get().packfileCorruptionDetected, dfe.getMessage())); } private static class DeltaChain extends ObjectId { @@ -1138,7 +1138,7 @@ public class IndexPack { // to create it. There is no way to move this pack in. // cleanupTemporaryFiles(); - throw new IOException("Cannot create " + packDir.getAbsolutePath()); + throw new IOException(MessageFormat.format(JGitText.get().cannotCreateDirectory, packDir.getAbsolutePath())); } if (finalPack.exists()) { @@ -1154,7 +1154,7 @@ public class IndexPack { // try { if (!keep.lock(lockMessage)) - throw new IOException("Cannot lock pack in " + finalPack); + throw new IOException(MessageFormat.format(JGitText.get().cannotLockPackIn, finalPack)); } catch (IOException e) { cleanupTemporaryFiles(); throw e; @@ -1164,7 +1164,7 @@ public class IndexPack { if (!dstPack.renameTo(finalPack)) { cleanupTemporaryFiles(); keep.unlock(); - throw new IOException("Cannot move pack to " + finalPack); + throw new IOException(MessageFormat.format(JGitText.get().cannotMovePackTo, finalPack)); } if (!dstIdx.renameTo(finalIdx)) { @@ -1172,7 +1172,7 @@ public class IndexPack { keep.unlock(); if (!finalPack.delete()) finalPack.deleteOnExit(); - throw new IOException("Cannot move index to " + finalIdx); + throw new IOException(MessageFormat.format(JGitText.get().cannotMoveIndexTo, finalIdx)); } try { @@ -1199,4 +1199,4 @@ public class IndexPack { if (needNewObjectIds()) newObjectIds.add(oe); } -}
\ No newline at end of file +} diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java index 170e4ddbe0..3821d696ed 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java @@ -47,7 +47,9 @@ package org.eclipse.jgit.transport; import java.io.IOException; import java.io.InputStream; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.PackProtocolException; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.MutableObjectId; @@ -82,7 +84,7 @@ class PacketLineIn { AckNackResult readACK(final MutableObjectId returnedId) throws IOException { final String line = readString(); if (line.length() == 0) - throw new PackProtocolException("Expected ACK/NAK, found EOF"); + throw new PackProtocolException(JGitText.get().expectedACKNAKFoundEOF); if ("NAK".equals(line)) return AckNackResult.NAK; if (line.startsWith("ACK ")) { @@ -98,7 +100,7 @@ class PacketLineIn { else if (arg.equals(" ready")) return AckNackResult.ACK_READY; } - throw new PackProtocolException("Expected ACK/NAK, got: " + line); + throw new PackProtocolException(MessageFormat.format(JGitText.get().expectedACKNAKGot, line)); } String readString() throws IOException { @@ -142,9 +144,9 @@ class PacketLineIn { throw new ArrayIndexOutOfBoundsException(); return len; } catch (ArrayIndexOutOfBoundsException err) { - throw new IOException("Invalid packet line header: " - + (char) lineBuffer[0] + (char) lineBuffer[1] - + (char) lineBuffer[2] + (char) lineBuffer[3]); + throw new IOException(MessageFormat.format(JGitText.get().invalidPacketLineHeader, + "" + (char) lineBuffer[0] + (char) lineBuffer[1] + + (char) lineBuffer[2] + (char) lineBuffer[3])); } } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushProcess.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushProcess.java index 03b783427a..02497cb06f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushProcess.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushProcess.java @@ -44,10 +44,12 @@ package org.eclipse.jgit.transport; import java.io.IOException; +import java.text.MessageFormat; import java.util.Collection; import java.util.HashMap; import java.util.Map; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.errors.NotSupportedException; import org.eclipse.jgit.errors.TransportException; @@ -66,7 +68,7 @@ import org.eclipse.jgit.transport.RemoteRefUpdate.Status; */ class PushProcess { /** Task name for {@link ProgressMonitor} used during opening connection. */ - static final String PROGRESS_OPENING_CONNECTION = "Opening connection"; + static final String PROGRESS_OPENING_CONNECTION = JGitText.get().openingConnection; /** Transport used to perform this operation. */ private final Transport transport; @@ -97,9 +99,8 @@ class PushProcess { this.toPush = new HashMap<String, RemoteRefUpdate>(); for (final RemoteRefUpdate rru : toPush) { if (this.toPush.put(rru.getRemoteName(), rru) != null) - throw new TransportException( - "Duplicate remote ref update is illegal. Affected remote name: " - + rru.getRemoteName()); + throw new TransportException(MessageFormat.format( + JGitText.get().duplicateRemoteRefUpdateIsIllegal, rru.getRemoteName())); } } @@ -200,9 +201,8 @@ class PushProcess { } catch (MissingObjectException x) { fastForward = false; } catch (Exception x) { - throw new TransportException(transport.getURI(), - "reading objects from local repository failed: " - + x.getMessage(), x); + throw new TransportException(transport.getURI(), MessageFormat.format( + JGitText.get().readingObjectsFromLocalRepositoryFailed, x.getMessage()), x); } rru.setFastForward(fastForward); if (!fastForward && !rru.isForceUpdate()) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java index 4e62d7427f..e42b7fe0c9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java @@ -57,6 +57,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; @@ -64,6 +65,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.errors.PackProtocolException; import org.eclipse.jgit.lib.Config; @@ -724,7 +726,7 @@ public class ReceivePack { } if (line.length() < 83) { - final String m = "error: invalid protocol: wanted 'old new ref'"; + final String m = JGitText.get().errorInvalidProtocolWantedOldNewRef; sendError(m); throw new PackProtocolException(m); } @@ -898,7 +900,7 @@ public class ReceivePack { // other requested old id is invalid. // cmd.setResult(Result.REJECTED_OTHER_REASON, - "invalid old id sent"); + JGitText.get().invalidOldIdSent); continue; } @@ -906,7 +908,7 @@ public class ReceivePack { if (ref == null) { // The ref must have been advertised in order to be updated. // - cmd.setResult(Result.REJECTED_OTHER_REASON, "no such ref"); + cmd.setResult(Result.REJECTED_OTHER_REASON, JGitText.get().noSuchRef); continue; } @@ -915,7 +917,7 @@ public class ReceivePack { // object id we advertised. // cmd.setResult(Result.REJECTED_OTHER_REASON, - "invalid old id sent"); + JGitText.get().invalidOldIdSent); continue; } @@ -958,7 +960,7 @@ public class ReceivePack { if (!cmd.getRefName().startsWith(Constants.R_REFS) || !Repository.isValidRefName(cmd.getRefName())) { - cmd.setResult(Result.REJECTED_OTHER_REASON, "funny refname"); + cmd.setResult(Result.REJECTED_OTHER_REASON, JGitText.get().funnyRefname); } } } @@ -997,8 +999,8 @@ public class ReceivePack { break; } } catch (IOException err) { - cmd.setResult(Result.REJECTED_OTHER_REASON, "lock error: " - + err.getMessage()); + cmd.setResult(Result.REJECTED_OTHER_REASON, MessageFormat.format( + JGitText.get().lockError, err.getMessage())); } } @@ -1047,7 +1049,7 @@ public class ReceivePack { private void sendStatusReport(final boolean forClient, final Reporter out) throws IOException { if (unpackError != null) { - out.sendString("unpack error " + unpackError.getMessage()); + out.sendString(MessageFormat.format(JGitText.get().unpackError, unpackError.getMessage())); if (forClient) { for (final ReceiveCommand cmd : commands) { out.sendString("ng " + cmd.getRefName() diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/RefSpec.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/RefSpec.java index 154ae3fedc..ca6f01500b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/RefSpec.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/RefSpec.java @@ -43,6 +43,9 @@ package org.eclipse.jgit.transport; +import java.text.MessageFormat; + +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Ref; @@ -125,7 +128,7 @@ public class RefSpec { if (c == 0) { s = s.substring(1); if (isWildcard(s)) - throw new IllegalArgumentException("Invalid wildcards " + spec); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().invalidWildcards, spec)); dstName = s; } else if (c > 0) { srcName = s.substring(0, c); @@ -133,10 +136,10 @@ public class RefSpec { if (isWildcard(srcName) && isWildcard(dstName)) wildcard = true; else if (isWildcard(srcName) || isWildcard(dstName)) - throw new IllegalArgumentException("Invalid wildcards " + spec); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().invalidWildcards, spec)); } else { if (isWildcard(s)) - throw new IllegalArgumentException("Invalid wildcards " + spec); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().invalidWildcards, spec)); srcName = s; } } @@ -211,9 +214,9 @@ public class RefSpec { final RefSpec r = new RefSpec(this); r.srcName = source; if (isWildcard(r.srcName) && r.dstName == null) - throw new IllegalStateException("Destination is not a wildcard."); + throw new IllegalStateException(JGitText.get().destinationIsNotAWildcard); if (isWildcard(r.srcName) != isWildcard(r.dstName)) - throw new IllegalStateException("Source/Destination must match."); + throw new IllegalStateException(JGitText.get().sourceDestinationMustMatch); return r; } @@ -250,9 +253,9 @@ public class RefSpec { final RefSpec r = new RefSpec(this); r.dstName = destination; if (isWildcard(r.dstName) && r.srcName == null) - throw new IllegalStateException("Source is not a wildcard."); + throw new IllegalStateException(JGitText.get().sourceIsNotAWildcard); if (isWildcard(r.srcName) != isWildcard(r.dstName)) - throw new IllegalStateException("Source/Destination must match."); + throw new IllegalStateException(JGitText.get().sourceDestinationMustMatch); return r; } @@ -271,7 +274,7 @@ public class RefSpec { public RefSpec setSourceDestination(final String source, final String destination) { if (isWildcard(source) != isWildcard(destination)) - throw new IllegalArgumentException("Source/Destination must match."); + throw new IllegalStateException(JGitText.get().sourceDestinationMustMatch); final RefSpec r = new RefSpec(this); r.wildcard = isWildcard(source); r.srcName = source; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteRefUpdate.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteRefUpdate.java index b2aa6335d8..1b17c9f0f4 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteRefUpdate.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteRefUpdate.java @@ -44,7 +44,9 @@ package org.eclipse.jgit.transport; import java.io.IOException; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.revwalk.RevWalk; @@ -184,13 +186,13 @@ public class RemoteRefUpdate { final String localName, final ObjectId expectedOldObjectId) throws IOException { if (remoteName == null) - throw new IllegalArgumentException("Remote name can't be null."); + throw new IllegalArgumentException(JGitText.get().remoteNameCantBeNull); this.srcRef = srcRef; this.newObjectId = (srcRef == null ? ObjectId.zeroId() : localDb .resolve(srcRef)); if (newObjectId == null) - throw new IOException("Source ref " + srcRef - + " doesn't resolve to any object."); + throw new IOException(MessageFormat.format( + JGitText.get().sourceRefDoesntResolveToAnyObject, srcRef)); this.remoteName = remoteName; this.forceUpdate = forceUpdate; if (localName != null && localDb != null) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/SideBandInputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/SideBandInputStream.java index 796cb745a1..1f9883e504 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/SideBandInputStream.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/SideBandInputStream.java @@ -49,9 +49,11 @@ import static org.eclipse.jgit.transport.SideBandOutputStream.HDR_SIZE; import java.io.IOException; import java.io.InputStream; import java.io.Writer; +import java.text.MessageFormat; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.PackProtocolException; import org.eclipse.jgit.errors.TransportException; import org.eclipse.jgit.lib.Constants; @@ -75,7 +77,7 @@ import org.eclipse.jgit.util.RawParseUtils; * @see SideBandOutputStream */ class SideBandInputStream extends InputStream { - private static final String PFX_REMOTE = "remote: "; + private static final String PFX_REMOTE = JGitText.get().prefixRemote; static final int CH_DATA = 1; @@ -170,7 +172,7 @@ class SideBandInputStream extends InputStream { eof = true; throw new TransportException(PFX_REMOTE + readString(available)); default: - throw new PackProtocolException("Invalid channel " + channel); + throw new PackProtocolException(MessageFormat.format(JGitText.get().invalidChannel, channel)); } } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/SideBandOutputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/SideBandOutputStream.java index 6e0a52627e..31acdcde5b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/SideBandOutputStream.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/SideBandOutputStream.java @@ -45,6 +45,9 @@ package org.eclipse.jgit.transport; import java.io.IOException; import java.io.OutputStream; +import java.text.MessageFormat; + +import org.eclipse.jgit.JGitText; /** * Multiplexes data and progress messages. @@ -94,14 +97,11 @@ class SideBandOutputStream extends OutputStream { */ SideBandOutputStream(final int chan, final int sz, final OutputStream os) { if (chan <= 0 || chan > 255) - throw new IllegalArgumentException("channel " + chan - + " must be in range [0, 255]"); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().channelMustBeInRange0_255, chan)); if (sz <= HDR_SIZE) - throw new IllegalArgumentException("packet size " + sz - + " must be >= " + HDR_SIZE); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().packetSizeMustBeAtLeast, sz, HDR_SIZE)); else if (MAX_BUF < sz) - throw new IllegalArgumentException("packet size " + sz - + " must be <= " + MAX_BUF); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().packetSizeMustBeAtMost, sz, MAX_BUF)); out = os; buffer = new byte[sz]; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/SshTransport.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/SshTransport.java index 5c6b498cad..d25a7b6180 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/SshTransport.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/SshTransport.java @@ -50,6 +50,7 @@ package org.eclipse.jgit.transport; import java.net.ConnectException; import java.net.UnknownHostException; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.TransportException; import org.eclipse.jgit.lib.Repository; @@ -96,10 +97,10 @@ public abstract class SshTransport extends TcpTransport { */ public void setSshSessionFactory(SshSessionFactory factory) { if (factory == null) - throw new NullPointerException("The factory must not be null"); + throw new NullPointerException(JGitText.get().theFactoryMustNotBeNull); if (sock != null) throw new IllegalStateException( - "An SSH session has been already created"); + JGitText.get().anSSHSessionHasBeenAlreadyCreated); sch = factory; } @@ -133,7 +134,7 @@ public abstract class SshTransport extends TcpTransport { } catch (JSchException je) { final Throwable c = je.getCause(); if (c instanceof UnknownHostException) - throw new TransportException(uri, "unknown host"); + throw new TransportException(uri, JGitText.get().unknownHost); if (c instanceof ConnectException) throw new TransportException(uri, c.getMessage()); throw new TransportException(uri, je.getMessage(), je); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TagOpt.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TagOpt.java index 66f36a0d27..82a5f23b6a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TagOpt.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TagOpt.java @@ -44,6 +44,10 @@ package org.eclipse.jgit.transport; +import java.text.MessageFormat; + +import org.eclipse.jgit.JGitText; + /** Specification of annotated tag behavior during fetch. */ public enum TagOpt { /** @@ -105,6 +109,6 @@ public enum TagOpt { if (tagopt.option().equals(o)) return tagopt; } - throw new IllegalArgumentException("Invalid tag option: " + o); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().invalidTagOption, o)); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java index d6400963ac..c0b2eedc00 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java @@ -48,6 +48,7 @@ package org.eclipse.jgit.transport; import java.io.IOException; import java.net.URISyntaxException; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -56,6 +57,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.NotSupportedException; import org.eclipse.jgit.errors.TransportException; import org.eclipse.jgit.lib.Constants; @@ -240,9 +242,8 @@ public abstract class Transport { throws NotSupportedException { final List<URIish> uris = getURIs(cfg, op); if (uris.isEmpty()) - throw new IllegalArgumentException( - "Remote config \"" - + cfg.getName() + "\" has no URIs associated"); + throw new IllegalArgumentException(MessageFormat.format( + JGitText.get().remoteConfigHasNoURIAssociated, cfg.getName())); final Transport tn = open(local, uris.get(0)); tn.applyConfig(cfg); return tn; @@ -351,7 +352,7 @@ public abstract class Transport { else if (TransportLocal.canHandle(remote)) return new TransportLocal(local, remote); - throw new NotSupportedException("URI not supported: " + remote); + throw new NotSupportedException(MessageFormat.format(JGitText.get().URINotSupported, remote)); } /** @@ -787,7 +788,7 @@ public abstract class Transport { // If the caller did not ask for anything use the defaults. // if (fetch.isEmpty()) - throw new TransportException("Nothing to fetch."); + throw new TransportException(JGitText.get().nothingToFetch); toFetch = fetch; } else if (!fetch.isEmpty()) { // If the caller asked for something specific without giving @@ -862,12 +863,11 @@ public abstract class Transport { try { toPush = findRemoteRefUpdatesFor(push); } catch (final IOException e) { - throw new TransportException( - "Problem with resolving push ref specs locally: " - + e.getMessage(), e); + throw new TransportException(MessageFormat.format( + JGitText.get().problemWithResolvingPushRefSpecsLocally, e.getMessage()), e); } if (toPush.isEmpty()) - throw new TransportException("Nothing to push."); + throw new TransportException(JGitText.get().nothingToPush); } final PushProcess pushProcess = new PushProcess(this, toPush); return pushProcess.execute(monitor); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportAmazonS3.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportAmazonS3.java index a3fd1ceae5..bcf6e873fe 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportAmazonS3.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportAmazonS3.java @@ -50,6 +50,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URLConnection; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -57,6 +58,7 @@ import java.util.Map; import java.util.Properties; import java.util.TreeMap; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.NotSupportedException; import org.eclipse.jgit.errors.TransportException; import org.eclipse.jgit.lib.Constants; @@ -133,7 +135,7 @@ public class TransportAmazonS3 extends HttpTransport implements WalkTransport { try { props = AmazonS3.properties(propsFile); } catch (IOException e) { - throw new NotSupportedException("cannot read " + propsFile, e); + throw new NotSupportedException(MessageFormat.format(JGitText.get().cannotReadFile, propsFile), e); } } else { props = new Properties(); @@ -277,7 +279,7 @@ public class TransportAmazonS3 extends HttpTransport implements WalkTransport { + "refs"))) readRef(avail, "refs/" + n); } catch (IOException e) { - throw new TransportException(getURI(), "cannot list refs", e); + throw new TransportException(getURI(), JGitText.get().cannotListRefs, e); } } @@ -295,11 +297,12 @@ public class TransportAmazonS3 extends HttpTransport implements WalkTransport { } catch (FileNotFoundException noRef) { return null; } catch (IOException err) { - throw new TransportException(getURI(), "read " + ref, err); + throw new TransportException(getURI(), MessageFormat.format( + JGitText.get().transportExceptionReadRef, ref), err); } if (s == null) - throw new TransportException(getURI(), "Empty ref: " + rn); + throw new TransportException(getURI(), MessageFormat.format(JGitText.get().transportExceptionEmptyRef, rn)); if (s.startsWith("ref: ")) { final String target = s.substring("ref: ".length()); @@ -320,7 +323,7 @@ public class TransportAmazonS3 extends HttpTransport implements WalkTransport { return r; } - throw new TransportException(getURI(), "Bad ref: " + rn + ": " + s); + throw new TransportException(getURI(), MessageFormat.format(JGitText.get().transportExceptionBadRef, rn, s)); } private Storage loose(final Ref r) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportBundleFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportBundleFile.java index 17e3bdd229..0245818fe3 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportBundleFile.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportBundleFile.java @@ -51,6 +51,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.NotSupportedException; import org.eclipse.jgit.errors.TransportException; import org.eclipse.jgit.lib.Repository; @@ -84,7 +85,7 @@ class TransportBundleFile extends Transport implements TransportBundle { try { src = new FileInputStream(bundle); } catch (FileNotFoundException err) { - throw new TransportException(uri, "not found"); + throw new TransportException(uri, JGitText.get().notFound); } return new BundleFetchConnection(this, src); } @@ -92,7 +93,7 @@ class TransportBundleFile extends Transport implements TransportBundle { @Override public PushConnection openPush() throws NotSupportedException { throw new NotSupportedException( - "Push is not supported for bundle transport"); + JGitText.get().pushIsNotSupportedForBundleTransport); } @Override diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportBundleStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportBundleStream.java index e5188bb236..defc8c2bb6 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportBundleStream.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportBundleStream.java @@ -49,6 +49,7 @@ package org.eclipse.jgit.transport; import java.io.IOException; import java.io.InputStream; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.NotSupportedException; import org.eclipse.jgit.errors.TransportException; import org.eclipse.jgit.lib.Repository; @@ -92,7 +93,7 @@ public class TransportBundleStream extends Transport implements TransportBundle @Override public FetchConnection openFetch() throws TransportException { if (src == null) - throw new TransportException(uri, "Only one fetch supported"); + throw new TransportException(uri, JGitText.get().onlyOneFetchSupported); try { return new BundleFetchConnection(this, src); } finally { @@ -103,7 +104,7 @@ public class TransportBundleStream extends Transport implements TransportBundle @Override public PushConnection openPush() throws NotSupportedException { throw new NotSupportedException( - "Push is not supported for bundle transport"); + JGitText.get().pushIsNotSupportedForBundleTransport); } @Override diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitAnon.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitAnon.java index 8a0b4357cd..5ad57768fe 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitAnon.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitAnon.java @@ -56,6 +56,7 @@ import java.net.InetSocketAddress; import java.net.Socket; import java.net.UnknownHostException; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.TransportException; import org.eclipse.jgit.lib.Repository; @@ -107,7 +108,7 @@ class TransportGitAnon extends TcpTransport implements PackTransport { // ignore a failure during close, we're already failing } if (c instanceof UnknownHostException) - throw new TransportException(uri, "unknown host"); + throw new TransportException(uri, JGitText.get().unknownHost); if (c instanceof ConnectException) throw new TransportException(uri, c.getMessage()); throw new TransportException(uri, c.getMessage(), c); @@ -151,7 +152,7 @@ class TransportGitAnon extends TcpTransport implements PackTransport { } catch (IOException err) { close(); throw new TransportException(uri, - "remote hung up unexpectedly", err); + JGitText.get().remoteHungUpUnexpectedly, err); } readAdvertisedRefs(); } @@ -190,7 +191,7 @@ class TransportGitAnon extends TcpTransport implements PackTransport { } catch (IOException err) { close(); throw new TransportException(uri, - "remote hung up unexpectedly", err); + JGitText.get().remoteHungUpUnexpectedly, err); } readAdvertisedRefs(); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java index 8df3ea5b2b..34b13b2d1d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java @@ -51,7 +51,9 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.PipedInputStream; import java.io.PipedOutputStream; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.NoRemoteRepositoryException; import org.eclipse.jgit.errors.TransportException; import org.eclipse.jgit.lib.Repository; @@ -172,8 +174,8 @@ public class TransportGitSsh extends SshTransport implements PackTransport { IOException cause = null; if (why != null && why.length() > 0) cause = new IOException(why); - throw new TransportException(uri, "cannot execute: " - + commandFor(exe), cause); + throw new TransportException(uri, MessageFormat.format( + JGitText.get().cannotExecute, commandFor(exe)), cause); } } @@ -257,7 +259,7 @@ public class TransportGitSsh extends SshTransport implements PackTransport { } catch (IOException err) { close(); throw new TransportException(uri, - "remote hung up unexpectedly", err); + JGitText.get().remoteHungUpUnexpectedly, err); } try { @@ -325,7 +327,7 @@ public class TransportGitSsh extends SshTransport implements PackTransport { } catch (IOException err) { close(); throw new TransportException(uri, - "remote hung up unexpectedly", err); + JGitText.get().remoteHungUpUnexpectedly, err); } try { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java index f49828bf2d..71e7bf285e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java @@ -65,6 +65,7 @@ import java.net.MalformedURLException; import java.net.Proxy; import java.net.ProxySelector; import java.net.URL; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Map; @@ -73,6 +74,7 @@ import java.util.TreeMap; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.NoRemoteRepositoryException; import org.eclipse.jgit.errors.NotSupportedException; import org.eclipse.jgit.errors.PackProtocolException; @@ -170,7 +172,7 @@ public class TransportHttp extends HttpTransport implements WalkTransport, baseUrl = new URL(uriString); objectsUrl = new URL(baseUrl, "objects/"); } catch (MalformedURLException e) { - throw new NotSupportedException("Invalid URL " + uri, e); + throw new NotSupportedException(MessageFormat.format(JGitText.get().invalidURL, uri), e); } http = local.getConfig().get(HTTP_KEY); proxySelector = ProxySelector.getDefault(); @@ -216,7 +218,7 @@ public class TransportHttp extends HttpTransport implements WalkTransport, } catch (TransportException err) { throw err; } catch (IOException err) { - throw new TransportException(uri, "error reading info/refs", err); + throw new TransportException(uri, JGitText.get().errorReadingInfoRefs, err); } } @@ -265,8 +267,8 @@ public class TransportHttp extends HttpTransport implements WalkTransport, break; default: - throw new TransportException(uri, "cannot read HEAD: " + status - + " " + conn.getResponseMessage()); + throw new TransportException(uri, MessageFormat.format( + JGitText.get().cannotReadHEAD, status, conn.getResponseMessage())); } } @@ -292,11 +294,11 @@ public class TransportHttp extends HttpTransport implements WalkTransport, return new SmartHttpPushConnection(in); } else if (!useSmartHttp) { - final String msg = "smart HTTP push disabled"; + final String msg = JGitText.get().smartHTTPPushDisabled; throw new NotSupportedException(msg); } else { - final String msg = "remote does not support smart HTTP push"; + final String msg = JGitText.get().remoteDoesNotSupportSmartHTTPPush; throw new NotSupportedException(msg); } } finally { @@ -307,7 +309,7 @@ public class TransportHttp extends HttpTransport implements WalkTransport, } catch (TransportException err) { throw err; } catch (IOException err) { - throw new TransportException(uri, "error reading info/refs", err); + throw new TransportException(uri, JGitText.get().errorReadingInfoRefs, err); } } @@ -335,7 +337,7 @@ public class TransportHttp extends HttpTransport implements WalkTransport, u = new URL(b.toString()); } catch (MalformedURLException e) { - throw new NotSupportedException("Invalid URL " + uri, e); + throw new NotSupportedException(MessageFormat.format(JGitText.get().invalidURL, uri), e); } try { @@ -352,10 +354,10 @@ public class TransportHttp extends HttpTransport implements WalkTransport, return conn; case HttpURLConnection.HTTP_NOT_FOUND: - throw new NoRemoteRepositoryException(uri, u + " not found"); + throw new NoRemoteRepositoryException(uri, MessageFormat.format(JGitText.get().URLNotFound, u)); case HttpURLConnection.HTTP_FORBIDDEN: - throw new TransportException(uri, service + " not permitted"); + throw new TransportException(uri, MessageFormat.format(JGitText.get().serviceNotPermitted, service)); default: String err = status + " " + conn.getResponseMessage(); @@ -366,7 +368,7 @@ public class TransportHttp extends HttpTransport implements WalkTransport, } catch (TransportException e) { throw e; } catch (IOException e) { - throw new TransportException(uri, "cannot open " + service, e); + throw new TransportException(uri, MessageFormat.format(JGitText.get().cannotOpenService, service), e); } } @@ -389,8 +391,7 @@ public class TransportHttp extends HttpTransport implements WalkTransport, } IOException wrongContentType(String expType, String actType) { - final String why = "expected Content-Type " + expType - + "; received Content-Type " + actType; + final String why = MessageFormat.format(JGitText.get().expectedReceivedContentType, expType, actType); return new TransportException(uri, why); } @@ -410,9 +411,8 @@ public class TransportHttp extends HttpTransport implements WalkTransport, final byte[] magic = new byte[5]; IO.readFully(in, magic, 0, magic.length); if (magic[4] != '#') { - throw new TransportException(uri, "expected pkt-line with" - + " '# service=', got '" + RawParseUtils.decode(magic) - + "'"); + throw new TransportException(uri, MessageFormat.format( + JGitText.get().expectedPktLineWithService, RawParseUtils.decode(magic))); } final PacketLineIn pckIn = new PacketLineIn(new UnionInputStream( @@ -420,8 +420,8 @@ public class TransportHttp extends HttpTransport implements WalkTransport, final String exp = "# service=" + service; final String act = pckIn.readString(); if (!exp.equals(act)) { - throw new TransportException(uri, "expected '" + exp + "', got '" - + act + "'"); + throw new TransportException(uri, MessageFormat.format( + JGitText.get().expectedGot, exp, act)); } while (pckIn.readString() != PacketLineIn.END) { @@ -546,16 +546,15 @@ public class TransportHttp extends HttpTransport implements WalkTransport, } private PackProtocolException outOfOrderAdvertisement(final String n) { - return new PackProtocolException("advertisement of " + n - + "^{} came before " + n); + return new PackProtocolException(MessageFormat.format(JGitText.get().advertisementOfCameBefore, n, n)); } private PackProtocolException invalidAdvertisement(final String n) { - return new PackProtocolException("invalid advertisement of " + n); + return new PackProtocolException(MessageFormat.format(JGitText.get().invalidAdvertisementOf, n)); } private PackProtocolException duplicateAdvertisement(final String n) { - return new PackProtocolException("duplicate advertisements of " + n); + return new PackProtocolException(MessageFormat.format(JGitText.get().duplicateAdvertisementsOf, n)); } @Override @@ -667,9 +666,8 @@ public class TransportHttp extends HttpTransport implements WalkTransport, // our request buffer. Send with a Content-Length header. // if (out.length() == 0) { - throw new TransportException(uri, "Starting read stage" - + " without written request data pending" - + " is not supported"); + throw new TransportException(uri, + JGitText.get().startingReadStageWithoutWrittenRequestDataPendingIsNotSupported); } // Try to compress the content, but only if that is smaller. diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportLocal.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportLocal.java index 22c436de3a..cf4dbd5392 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportLocal.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportLocal.java @@ -56,6 +56,7 @@ import java.io.OutputStream; import java.io.PipedInputStream; import java.io.PipedOutputStream; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.NotSupportedException; import org.eclipse.jgit.errors.TransportException; import org.eclipse.jgit.lib.Constants; @@ -175,7 +176,7 @@ class TransportLocal extends Transport implements PackTransport { try { dst = new Repository(remoteGitDir); } catch (IOException err) { - throw new TransportException(uri, "not a git directory"); + throw new TransportException(uri, JGitText.get().notAGitDirectory); } final PipedInputStream in_r; @@ -199,7 +200,7 @@ class TransportLocal extends Transport implements PackTransport { out_w = new PipedOutputStream(out_r); } catch (IOException err) { dst.close(); - throw new TransportException(uri, "cannot connect pipes", err); + throw new TransportException(uri, JGitText.get().cannotConnectPipes, err); } worker = new Thread("JGit-Upload-Pack") { @@ -315,7 +316,7 @@ class TransportLocal extends Transport implements PackTransport { try { dst = new Repository(remoteGitDir); } catch (IOException err) { - throw new TransportException(uri, "not a git directory"); + throw new TransportException(uri, JGitText.get().notAGitDirectory); } final PipedInputStream in_r; @@ -331,7 +332,7 @@ class TransportLocal extends Transport implements PackTransport { out_w = new PipedOutputStream(out_r); } catch (IOException err) { dst.close(); - throw new TransportException(uri, "cannot connect pipes", err); + throw new TransportException(uri, JGitText.get().cannotConnectPipes, err); } worker = new Thread("JGit-Receive-Pack") { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java index 80b94b2324..5939bc2f28 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java @@ -50,6 +50,7 @@ import java.net.URL; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.lib.Constants; /** @@ -107,7 +108,7 @@ public class URIish { host = matcher.group(2); path = matcher.group(3); } else - throw new URISyntaxException(s, "Cannot parse Git URI-ish"); + throw new URISyntaxException(s, JGitText.get().cannotParseGitURIish); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java index 3d5abd34bd..3381c0724a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java @@ -47,6 +47,7 @@ import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; @@ -54,6 +55,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.PackProtocolException; import org.eclipse.jgit.lib.NullProgressMonitor; import org.eclipse.jgit.lib.ObjectId; @@ -371,7 +373,7 @@ public class UploadPack { if (line == PacketLineIn.END) break; if (!line.startsWith("want ") || line.length() < 45) - throw new PackProtocolException("expected want; got " + line); + throw new PackProtocolException(MessageFormat.format(JGitText.get().expectedGot, "want", line)); if (isFirst && line.length() > 45) { String opt = line.substring(45); @@ -387,10 +389,10 @@ public class UploadPack { try { o = walk.parseAny(id); } catch (IOException e) { - throw new PackProtocolException(id.name() + " not valid", e); + throw new PackProtocolException(MessageFormat.format(JGitText.get().notValid, id.name()), e); } if (!o.has(ADVERTISED)) - throw new PackProtocolException(id.name() + " not valid"); + throw new PackProtocolException(MessageFormat.format(JGitText.get().notValid, id.name())); want(o); } } @@ -473,7 +475,7 @@ public class UploadPack { return true; } else { - throw new PackProtocolException("expected have; got " + line); + throw new PackProtocolException(MessageFormat.format(JGitText.get().expectedGot, "have", line)); } } } @@ -521,7 +523,7 @@ public class UploadPack { i.remove(); } } catch (IOException e) { - throw new PackProtocolException("internal revision error", e); + throw new PackProtocolException(JGitText.get().internalRevisionError, e); } return wantCommits.isEmpty(); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkEncryption.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkEncryption.java index d368fb2cd7..b55de9265a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkEncryption.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkEncryption.java @@ -51,6 +51,7 @@ import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.spec.InvalidKeySpecException; +import java.text.MessageFormat; import javax.crypto.Cipher; import javax.crypto.CipherInputStream; @@ -61,6 +62,8 @@ import javax.crypto.SecretKeyFactory; import javax.crypto.spec.PBEKeySpec; import javax.crypto.spec.PBEParameterSpec; +import org.eclipse.jgit.JGitText; + abstract class WalkEncryption { static final WalkEncryption NONE = new NoEncryption(); @@ -84,18 +87,18 @@ abstract class WalkEncryption { if (v == null) v = ""; if (!version.equals(v)) - throw new IOException("Unsupported encryption version: " + v); + throw new IOException(MessageFormat.format(JGitText.get().unsupportedEncryptionVersion, v)); v = u.getHeaderField(p + JETS3T_CRYPTO_ALG); if (v == null) v = ""; if (!name.equals(v)) - throw new IOException("Unsupported encryption algorithm: " + v); + throw new IOException(JGitText.get().unsupportedEncryptionAlgorithm + v); } IOException error(final Throwable why) { final IOException e; - e = new IOException("Encryption error: " + why.getMessage()); + e = new IOException(MessageFormat.format(JGitText.get().encryptionError, why.getMessage())); e.initCause(why); return e; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkFetchConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkFetchConnection.java index ba4486144d..6254745476 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkFetchConnection.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkFetchConnection.java @@ -49,6 +49,7 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.security.MessageDigest; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -58,6 +59,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.CompoundException; import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.errors.MissingObjectException; @@ -261,7 +263,7 @@ class WalkFetchConnection extends BaseFetchConnection { if (inWorkQueue.add(id)) workQueue.add(id); } catch (IOException e) { - throw new TransportException("Cannot read " + id.name(), e); + throw new TransportException(MessageFormat.format(JGitText.get().cannotRead, id.name()), e); } } } @@ -280,7 +282,7 @@ class WalkFetchConnection extends BaseFetchConnection { return; } } catch (IOException e) { - throw new TransportException("Cannot read " + id.name(), e); + throw new TransportException(MessageFormat.format(JGitText.get().cannotRead, id.name()), e); } switch (obj.getType()) { @@ -297,7 +299,7 @@ class WalkFetchConnection extends BaseFetchConnection { processTag(obj); break; default: - throw new TransportException("Unknown object type " + id.name()); + throw new TransportException(MessageFormat.format(JGitText.get().unknownObjectType, id.name())); } // If we had any prior errors fetching this object they are @@ -308,7 +310,7 @@ class WalkFetchConnection extends BaseFetchConnection { private void processBlob(final RevObject obj) throws TransportException { if (!local.hasObject(obj)) - throw new TransportException("Cannot read blob " + obj.name(), + throw new TransportException(MessageFormat.format(JGitText.get().cannotReadBlob, obj.name()), new MissingObjectException(obj, Constants.TYPE_BLOB)); obj.add(COMPLETE); } @@ -331,14 +333,12 @@ class WalkFetchConnection extends BaseFetchConnection { if (FileMode.GITLINK.equals(mode)) continue; treeWalk.getObjectId(idBuffer, 0); - throw new CorruptObjectException("Invalid mode " + mode - + " for " + idBuffer.name() + " " - + treeWalk.getPathString() + " in " - + obj.getId().name() + "."); + throw new CorruptObjectException(MessageFormat.format(JGitText.get().invalidModeFor + , mode, idBuffer.name(), treeWalk.getPathString(), obj.getId().name())); } } } catch (IOException ioe) { - throw new TransportException("Cannot read tree " + obj.name(), ioe); + throw new TransportException(MessageFormat.format(JGitText.get().cannotReadTree, obj.name()), ioe); } obj.add(COMPLETE); } @@ -445,7 +445,7 @@ class WalkFetchConnection extends BaseFetchConnection { List<Throwable> failures = fetchErrors.get(id.copy()); final TransportException te; - te = new TransportException("Cannot get " + id.name() + "."); + te = new TransportException(MessageFormat.format(JGitText.get().cannotGet, id.name())); if (failures != null && !failures.isEmpty()) { if (failures.size() == 1) te.initCause(failures.get(0)); @@ -521,8 +521,8 @@ class WalkFetchConnection extends BaseFetchConnection { // the object, but after indexing we didn't // actually find it in the pack. // - recordError(id, new FileNotFoundException("Object " + id.name() - + " not found in " + pack.packName + ".")); + recordError(id, new FileNotFoundException(MessageFormat.format( + JGitText.get().objectNotFoundIn, id.name(), pack.packName))); continue; } @@ -565,7 +565,7 @@ class WalkFetchConnection extends BaseFetchConnection { recordError(id, e); return false; } catch (IOException e) { - throw new TransportException("Cannot download " + id.name(), e); + throw new TransportException(MessageFormat.format(JGitText.get().cannotDownload, id.name()), e); } } @@ -601,18 +601,15 @@ class WalkFetchConnection extends BaseFetchConnection { idBuffer.fromRaw(objectDigest.digest(), 0); if (!AnyObjectId.equals(id, idBuffer)) { - throw new TransportException("Incorrect hash for " + id.name() - + "; computed " + idBuffer.name() + " as a " - + Constants.typeString(uol.getType()) + " from " - + compressed.length + " bytes."); + throw new TransportException(MessageFormat.format(JGitText.get().incorrectHashFor + , id.name(), idBuffer.name(), Constants.typeString(uol.getType()), compressed.length)); } if (objCheck != null) { try { objCheck.check(uol.getType(), uol.getCachedBytes()); } catch (CorruptObjectException e) { - throw new TransportException("Invalid " - + Constants.typeString(uol.getType()) + " " - + id.name() + ":" + e.getMessage()); + throw new TransportException(MessageFormat.format(JGitText.get().transportExceptionInvalid + , Constants.typeString(uol.getType()), id.name(), e.getMessage())); } } } @@ -650,7 +647,7 @@ class WalkFetchConnection extends BaseFetchConnection { tmp.delete(); if (local.hasObject(id)) return; - throw new ObjectWritingException("Unable to store " + id.name() + "."); + throw new ObjectWritingException(MessageFormat.format(JGitText.get().unableToStore, id.name())); } private Collection<WalkRemoteObjectDatabase> expandOneAlternate( @@ -658,7 +655,7 @@ class WalkFetchConnection extends BaseFetchConnection { while (!noAlternatesYet.isEmpty()) { final WalkRemoteObjectDatabase wrr = noAlternatesYet.removeFirst(); try { - pm.beginTask("Listing alternates", ProgressMonitor.UNKNOWN); + pm.beginTask(JGitText.get().listingAlternates, ProgressMonitor.UNKNOWN); Collection<WalkRemoteObjectDatabase> altList = wrr .getAlternates(); if (altList != null && !altList.isEmpty()) @@ -679,15 +676,14 @@ class WalkFetchConnection extends BaseFetchConnection { try { markLocalObjComplete(revWalk.parseAny(r.getObjectId())); } catch (IOException readError) { - throw new TransportException("Local ref " + r.getName() - + " is missing object(s).", readError); + throw new TransportException(MessageFormat.format(JGitText.get().localRefIsMissingObjects, r.getName()), readError); } } for (final ObjectId id : have) { try { markLocalObjComplete(revWalk.parseAny(id)); } catch (IOException readError) { - throw new TransportException("Missing assumed "+id.name(), readError); + throw new TransportException(MessageFormat.format(JGitText.get().transportExceptionMissingAssumed, id.name()), readError); } } } @@ -726,7 +722,7 @@ class WalkFetchConnection extends BaseFetchConnection { pushLocalCommit(p); } } catch (IOException err) { - throw new TransportException("Local objects incomplete.", err); + throw new TransportException(JGitText.get().localObjectsIncomplete, err); } } @@ -769,9 +765,8 @@ class WalkFetchConnection extends BaseFetchConnection { if (FileMode.GITLINK.equals(mode)) continue; treeWalk.getObjectId(idBuffer, 0); - throw new CorruptObjectException("Invalid mode " + mode - + " for " + idBuffer.name() + " " - + treeWalk.getPathString() + " in " + tree.name() + "."); + throw new CorruptObjectException(MessageFormat.format(JGitText.get().corruptObjectInvalidMode3 + , mode, idBuffer.name(), treeWalk.getPathString(), tree.name())); } } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkPushConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkPushConnection.java index f977915bb3..0edf9678e4 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkPushConnection.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkPushConnection.java @@ -55,6 +55,7 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.TransportException; import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.Constants; @@ -145,7 +146,7 @@ class WalkPushConnection extends BaseConnection implements PushConnection { final String n = u.getRemoteName(); if (!n.startsWith("refs/") || !Repository.isValidRefName(n)) { u.setStatus(Status.REJECTED_OTHER_REASON); - u.setMessage("funny refname"); + u.setMessage(JGitText.get().funnyRefname); continue; } @@ -187,14 +188,14 @@ class WalkPushConnection extends BaseConnection implements PushConnection { u.setStatus(Status.REJECTED_OTHER_REASON); u.setMessage(err.getMessage()); } - throw new TransportException(uri, "failed updating refs", err); + throw new TransportException(uri, JGitText.get().failedUpdatingRefs, err); } } try { refWriter.writeInfoRefs(); } catch (IOException err) { - throw new TransportException(uri, "failed updating refs", err); + throw new TransportException(uri, JGitText.get().failedUpdatingRefs, err); } } @@ -279,7 +280,7 @@ class WalkPushConnection extends BaseConnection implements PushConnection { safeDelete(pathIdx); safeDelete(pathPack); - throw new TransportException(uri, "cannot store objects", err); + throw new TransportException(uri, JGitText.get().cannotStoreObjects, err); } } @@ -349,7 +350,7 @@ class WalkPushConnection extends BaseConnection implements PushConnection { final byte[] bytes = Constants.encode(ref); dest.writeFile(ROOT_DIR + Constants.HEAD, bytes); } catch (IOException e) { - throw new TransportException(uri, "cannot create HEAD", e); + throw new TransportException(uri, JGitText.get().cannotCreateHEAD, e); } try { @@ -358,7 +359,7 @@ class WalkPushConnection extends BaseConnection implements PushConnection { final byte[] bytes = Constants.encode(config); dest.writeFile(ROOT_DIR + "config", bytes); } catch (IOException e) { - throw new TransportException(uri, "cannot create config", e); + throw new TransportException(uri, JGitText.get().cannotCreateConfig, e); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkRemoteObjectDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkRemoteObjectDatabase.java index 2aa644ce8b..f1743b378d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkRemoteObjectDatabase.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkRemoteObjectDatabase.java @@ -50,10 +50,12 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Map; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.TransportException; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; @@ -198,7 +200,7 @@ abstract class WalkRemoteObjectDatabase { * deletion is not supported, or deletion failed. */ void deleteFile(final String path) throws IOException { - throw new IOException("Deleting '" + path + "' not supported."); + throw new IOException(MessageFormat.format(JGitText.get().deletingNotSupported, path)); } /** @@ -230,7 +232,7 @@ abstract class WalkRemoteObjectDatabase { */ OutputStream writeFile(final String path, final ProgressMonitor monitor, final String monitorTask) throws IOException { - throw new IOException("Writing of '" + path + "' not supported."); + throw new IOException(MessageFormat.format(JGitText.get().writingNotSupported, path)); } /** @@ -428,7 +430,7 @@ abstract class WalkRemoteObjectDatabase { } catch (FileNotFoundException notPacked) { // Perhaps it wasn't worthwhile, or is just an older repository. } catch (IOException e) { - throw new TransportException(getURI(), "error in packed-refs", e); + throw new TransportException(getURI(), JGitText.get().errorInPackedRefs, e); } } @@ -449,7 +451,7 @@ abstract class WalkRemoteObjectDatabase { } if (line.charAt(0) == '^') { if (last == null) - throw new TransportException("Peeled line before ref."); + throw new TransportException(JGitText.get().peeledLineBeforeRef); final ObjectId id = ObjectId.fromString(line.substring(1)); last = new ObjectIdRef.PeeledTag(Ref.Storage.PACKED, last .getName(), last.getObjectId(), id); @@ -459,7 +461,7 @@ abstract class WalkRemoteObjectDatabase { final int sp = line.indexOf(' '); if (sp < 0) - throw new TransportException("Unrecognized ref: " + line); + throw new TransportException(MessageFormat.format(JGitText.get().unrecognizedRef, line)); final ObjectId id = ObjectId.fromString(line.substring(0, sp)); final String name = line.substring(sp + 1); if (peeled) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java index 6b8a6cea4b..013e0edb35 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java @@ -50,9 +50,11 @@ import java.nio.CharBuffer; import java.nio.charset.CharacterCodingException; import java.nio.charset.CharsetEncoder; import java.security.MessageDigest; +import java.text.MessageFormat; import java.util.Arrays; import java.util.Comparator; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.FileMode; @@ -373,7 +375,7 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator { b = enc.encode(CharBuffer.wrap(getName())); } catch (CharacterCodingException e) { // This should so never happen. - throw new RuntimeException("Unencodeable file: " + getName()); + throw new RuntimeException(MessageFormat.format(JGitText.get().unencodeableFile, getName())); } encodedNameLen = b.limit(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/AndTreeFilter.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/AndTreeFilter.java index 9a6156f082..12964bbe64 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/AndTreeFilter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/AndTreeFilter.java @@ -47,6 +47,7 @@ package org.eclipse.jgit.treewalk.filter; import java.io.IOException; import java.util.Collection; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.treewalk.TreeWalk; @@ -89,7 +90,7 @@ public abstract class AndTreeFilter extends TreeFilter { if (list.length == 2) return create(list[0], list[1]); if (list.length < 2) - throw new IllegalArgumentException("At least two filters needed."); + throw new IllegalArgumentException(JGitText.get().atLeastTwoFiltersNeeded); final TreeFilter[] subfilters = new TreeFilter[list.length]; System.arraycopy(list, 0, subfilters, 0, list.length); return new List(subfilters); @@ -105,7 +106,7 @@ public abstract class AndTreeFilter extends TreeFilter { */ public static TreeFilter create(final Collection<TreeFilter> list) { if (list.size() < 2) - throw new IllegalArgumentException("At least two filters needed."); + throw new IllegalArgumentException(JGitText.get().atLeastTwoFiltersNeeded); final TreeFilter[] subfilters = new TreeFilter[list.size()]; list.toArray(subfilters); if (subfilters.length == 2) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/OrTreeFilter.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/OrTreeFilter.java index f14ceeab32..de5aa421a0 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/OrTreeFilter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/OrTreeFilter.java @@ -47,6 +47,7 @@ package org.eclipse.jgit.treewalk.filter; import java.io.IOException; import java.util.Collection; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.treewalk.TreeWalk; @@ -87,7 +88,7 @@ public abstract class OrTreeFilter extends TreeFilter { if (list.length == 2) return create(list[0], list[1]); if (list.length < 2) - throw new IllegalArgumentException("At least two filters needed."); + throw new IllegalArgumentException(JGitText.get().atLeastTwoFiltersNeeded); final TreeFilter[] subfilters = new TreeFilter[list.length]; System.arraycopy(list, 0, subfilters, 0, list.length); return new List(subfilters); @@ -103,7 +104,7 @@ public abstract class OrTreeFilter extends TreeFilter { */ public static TreeFilter create(final Collection<TreeFilter> list) { if (list.size() < 2) - throw new IllegalArgumentException("At least two filters needed."); + throw new IllegalArgumentException(JGitText.get().atLeastTwoFiltersNeeded); final TreeFilter[] subfilters = new TreeFilter[list.size()]; list.toArray(subfilters); if (subfilters.length == 2) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathFilter.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathFilter.java index 65451da8e6..e317789840 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathFilter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathFilter.java @@ -44,6 +44,7 @@ package org.eclipse.jgit.treewalk.filter; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.treewalk.TreeWalk; @@ -76,7 +77,7 @@ public class PathFilter extends TreeFilter { while (path.endsWith("/")) path = path.substring(0, path.length() - 1); if (path.length() == 0) - throw new IllegalArgumentException("Empty path not permitted."); + throw new IllegalArgumentException(JGitText.get().emptyPathNotPermitted); return new PathFilter(path); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathFilterGroup.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathFilterGroup.java index e58512da35..756b000684 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathFilterGroup.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathFilterGroup.java @@ -48,6 +48,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Comparator; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.StopWalkException; import org.eclipse.jgit.treewalk.TreeWalk; @@ -82,7 +83,7 @@ public class PathFilterGroup { */ public static TreeFilter createFromStrings(final Collection<String> paths) { if (paths.isEmpty()) - throw new IllegalArgumentException("At least one path is required."); + throw new IllegalArgumentException(JGitText.get().atLeastOnePathIsRequired); final PathFilter[] p = new PathFilter[paths.size()]; int i = 0; for (final String s : paths) @@ -103,7 +104,7 @@ public class PathFilterGroup { */ public static TreeFilter create(final Collection<PathFilter> paths) { if (paths.isEmpty()) - throw new IllegalArgumentException("At least one path is required."); + throw new IllegalArgumentException(JGitText.get().atLeastOnePathIsRequired); final PathFilter[] p = new PathFilter[paths.size()]; paths.toArray(p); return create(p); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathSuffixFilter.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathSuffixFilter.java index 3721ec646f..c4561c4d39 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathSuffixFilter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathSuffixFilter.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.treewalk.filter; import java.io.IOException; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.lib.Constants; @@ -68,7 +69,7 @@ public class PathSuffixFilter extends TreeFilter { */ public static PathSuffixFilter create(String path) { if (path.length() == 0) - throw new IllegalArgumentException("Empty path not permitted."); + throw new IllegalArgumentException(JGitText.get().emptyPathNotPermitted); return new PathSuffixFilter(path); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java index 53c7beced8..1c7d397e9c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java @@ -9,6 +9,9 @@ package org.eclipse.jgit.util; import java.io.Closeable; import java.io.IOException; +import java.text.MessageFormat; + +import org.eclipse.jgit.JGitText; /** @@ -702,7 +705,7 @@ public class Base64 } // end if: white space, equals sign or better else { - System.err.println( "Bad Base64 input character at " + i + ": " + source[i] + "(decimal)" ); + System.err.println(MessageFormat.format(JGitText.get().badBase64InputCharacterAt, i+ source[i])); return null; } // end else: } // each input character @@ -925,7 +928,7 @@ public class Base64 // Check for size of file if( file.length() > Integer.MAX_VALUE ) { - System.err.println( "File is too big for this convenience method (" + file.length() + " bytes)." ); + System.err.println(MessageFormat.format(JGitText.get().fileIsTooBigForThisConvenienceMethod, file.length())); return null; } // end if: file too big for int index buffer = new byte[ (int)file.length() ]; @@ -946,7 +949,7 @@ public class Base64 } // end try catch( java.io.IOException e ) { - System.err.println( "Error decoding from file " + filename ); + System.err.println(MessageFormat.format(JGitText.get().errorDecodingFromFile, filename)); } // end catch: IOException finally { @@ -994,7 +997,7 @@ public class Base64 } // end try catch( java.io.IOException e ) { - System.err.println( "Error encoding from file " + filename ); + System.err.println(MessageFormat.format(JGitText.get().errorEncodingFromFile, filename)); } // end catch: IOException finally { @@ -1154,7 +1157,7 @@ public class Base64 else { // Must have broken out from above. - throw new java.io.IOException( "Improperly padded Base64 input." ); + throw new java.io.IOException(JGitText.get().improperlyPaddedBase64Input); } // end } // end else: decode @@ -1192,7 +1195,7 @@ public class Base64 else { // When JDK1.4 is more accepted, use an assertion here. - throw new java.io.IOException( "Error in Base64 code reading stream." ); + throw new java.io.IOException(JGitText.get().errorInBase64CodeReadingStream); } // end else } // end read @@ -1363,7 +1366,7 @@ public class Base64 } // end if: meaningful base64 character else if( DECODABET[ theByte & 0x7f ] != WHITE_SPACE_ENC ) { - throw new java.io.IOException( "Invalid character in Base64 data." ); + throw new java.io.IOException(JGitText.get().invalidCharacterInBase64Data); } // end else: not white space either } // end else: decoding } // end write @@ -1413,7 +1416,7 @@ public class Base64 } // end if: encoding else { - throw new java.io.IOException( "Base64 input not properly padded." ); + throw new java.io.IOException(JGitText.get().base64InputNotProperlyPadded); } // end else: decoding } // end if: buffer partially full diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java index 2532593ec5..d3e1f60035 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java @@ -53,6 +53,9 @@ import java.net.ProxySelector; import java.net.URISyntaxException; import java.net.URL; import java.net.URLEncoder; +import java.text.MessageFormat; + +import org.eclipse.jgit.JGitText; /** Extra utilities to support usage of HTTP. */ public class HttpSupport { @@ -133,7 +136,7 @@ public class HttpSupport { try { urlstr.append(URLEncoder.encode(key, "UTF-8")); } catch (UnsupportedEncodingException e) { - throw new RuntimeException("Could not URL encode to UTF-8", e); + throw new RuntimeException(JGitText.get().couldNotURLEncodeToUTF8, e); } } @@ -158,7 +161,7 @@ public class HttpSupport { // The standard J2SE error message is not very useful. // if ("Connection timed out: connect".equals(ce.getMessage())) - throw new ConnectException("Connection time out: " + host); + throw new ConnectException(MessageFormat.format(JGitText.get().connectionTimeOut, host)); throw new ConnectException(ce.getMessage() + " " + host); } } @@ -181,7 +184,7 @@ public class HttpSupport { return proxySelector.select(u.toURI()).get(0); } catch (URISyntaxException e) { final ConnectException err; - err = new ConnectException("Cannot determine proxy for " + u); + err = new ConnectException(MessageFormat.format(JGitText.get().cannotDetermineProxyFor, u)); err.initCause(e); throw err; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java index 566b857460..1778654203 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java @@ -53,6 +53,9 @@ import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; +import java.text.MessageFormat; + +import org.eclipse.jgit.JGitText; /** * Input/Output utilities @@ -95,7 +98,7 @@ public class IO { try { final long sz = in.getChannel().size(); if (sz > max) - throw new IOException("File is too large: " + path); + throw new IOException(MessageFormat.format(JGitText.get().fileIsTooLarge, path)); final byte[] buf = new byte[(int) sz]; IO.readFully(in, buf, 0, buf.length); return buf; @@ -129,7 +132,7 @@ public class IO { while (len > 0) { final int r = fd.read(dst, off, len); if (r <= 0) - throw new EOFException("Short read of block."); + throw new EOFException(JGitText.get().shortReadOfBlock); off += r; len -= r; } @@ -158,7 +161,7 @@ public class IO { while (len > 0) { final int r = fd.read(ByteBuffer.wrap(dst, off, len), pos); if (r <= 0) - throw new EOFException("Short read of block."); + throw new EOFException(JGitText.get().shortReadOfBlock); pos += r; off += r; len -= r; @@ -187,7 +190,7 @@ public class IO { while (toSkip > 0) { final long r = fd.skip(toSkip); if (r <= 0) - throw new EOFException("Short skip of block"); + throw new EOFException(JGitText.get().shortSkipOfBlock); toSkip -= r; } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/RawSubStringPattern.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/RawSubStringPattern.java index 67d67b90c4..f45bf2796b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/RawSubStringPattern.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/RawSubStringPattern.java @@ -44,6 +44,7 @@ package org.eclipse.jgit.util; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.lib.Constants; /** @@ -67,7 +68,7 @@ public class RawSubStringPattern { */ public RawSubStringPattern(final String patternText) { if (patternText.length() == 0) - throw new IllegalArgumentException("Cannot match on empty string."); + throw new IllegalArgumentException(JGitText.get().cannotMatchOnEmptyString); needleString = patternText; final byte[] b = Constants.encode(patternText); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/StringUtils.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/StringUtils.java index 582dce8aff..119c041570 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/StringUtils.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/StringUtils.java @@ -43,6 +43,10 @@ package org.eclipse.jgit.util; +import java.text.MessageFormat; + +import org.eclipse.jgit.JGitText; + /** Miscellaneous string comparison utility methods. */ public final class StringUtils { private static final char[] LC; @@ -135,7 +139,7 @@ public final class StringUtils { */ public static boolean toBoolean(final String stringValue) { if (stringValue == null) - throw new NullPointerException("Expected boolean string value"); + throw new NullPointerException(JGitText.get().expectedBooleanStringValue); if (equalsIgnoreCase("yes", stringValue) || equalsIgnoreCase("true", stringValue) @@ -150,7 +154,7 @@ public final class StringUtils { return false; } else { - throw new IllegalArgumentException("Not a boolean: " + stringValue); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().notABoolean, stringValue)); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java index 95b3fa090b..6c421c5f50 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java @@ -53,6 +53,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.lib.NullProgressMonitor; import org.eclipse.jgit.lib.ProgressMonitor; @@ -196,7 +197,7 @@ public abstract class TemporaryBuffer extends OutputStream { public byte[] toByteArray() throws IOException { final long len = length(); if (Integer.MAX_VALUE < len) - throw new OutOfMemoryError("Length exceeds maximum array size"); + throw new OutOfMemoryError(JGitText.get().lengthExceedsMaximumArraySize); final byte[] out = new byte[(int) len]; int outPtr = 0; for (final Block b : blocks) { @@ -351,7 +352,7 @@ public abstract class TemporaryBuffer extends OutputStream { final long len = length(); if (Integer.MAX_VALUE < len) - throw new OutOfMemoryError("Length exceeds maximum array size"); + throw new OutOfMemoryError(JGitText.get().lengthExceedsMaximumArraySize); final byte[] out = new byte[(int) len]; final FileInputStream in = new FileInputStream(onDiskFile); try { @@ -419,7 +420,7 @@ public abstract class TemporaryBuffer extends OutputStream { @Override protected OutputStream overflow() throws IOException { - throw new IOException("In-memory buffer limit exceeded"); + throw new IOException(JGitText.get().inMemoryBufferLimitExceeded); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/DisabledOutputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/DisabledOutputStream.java index e38660d632..d95849a76b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/DisabledOutputStream.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/DisabledOutputStream.java @@ -46,6 +46,8 @@ package org.eclipse.jgit.util.io; import java.io.IOException; import java.io.OutputStream; +import org.eclipse.jgit.JGitText; + /** An OutputStream which always throws IllegalStateExeption during write. */ public final class DisabledOutputStream extends OutputStream { /** The canonical instance which always throws IllegalStateException. */ @@ -61,6 +63,6 @@ public final class DisabledOutputStream extends OutputStream { // We shouldn't be writing output at this stage, there // is nobody listening to us. // - throw new IllegalStateException("Writing not permitted"); + throw new IllegalStateException(JGitText.get().writingNotPermitted); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/InterruptTimer.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/InterruptTimer.java index 91aa1cb6d2..575fa3ef0c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/InterruptTimer.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/InterruptTimer.java @@ -43,6 +43,10 @@ package org.eclipse.jgit.util.io; +import java.text.MessageFormat; + +import org.eclipse.jgit.JGitText; + /** * Triggers an interrupt on the calling thread if it doesn't complete a block. * <p> @@ -113,7 +117,7 @@ public final class InterruptTimer { */ public void begin(final int timeout) { if (timeout <= 0) - throw new IllegalArgumentException("Invalid timeout: " + timeout); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().invalidTimeout, timeout)); Thread.interrupted(); state.begin(timeout); } @@ -193,7 +197,7 @@ public final class InterruptTimer { synchronized void begin(final int timeout) { if (terminated) - throw new IllegalStateException("Timer already terminated"); + throw new IllegalStateException(JGitText.get().timerAlreadyTerminated); callingThread = Thread.currentThread(); deadline = now() + timeout; notifyAll(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutInputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutInputStream.java index 19d7933e1b..3670639c1d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutInputStream.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutInputStream.java @@ -47,6 +47,9 @@ import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InterruptedIOException; +import java.text.MessageFormat; + +import org.eclipse.jgit.JGitText; /** InputStream with a configurable timeout. */ public class TimeoutInputStream extends FilterInputStream { @@ -80,7 +83,7 @@ public class TimeoutInputStream extends FilterInputStream { */ public void setTimeout(final int millis) { if (millis < 0) - throw new IllegalArgumentException("Invalid timeout: " + millis); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().invalidTimeout, millis)); timeout = millis; } @@ -134,6 +137,6 @@ public class TimeoutInputStream extends FilterInputStream { } private static InterruptedIOException readTimedOut() { - return new InterruptedIOException("Read timed out"); + return new InterruptedIOException(JGitText.get().readTimedOut); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutOutputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutOutputStream.java index a826086cd1..59ac7b21e5 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutOutputStream.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutOutputStream.java @@ -46,6 +46,9 @@ package org.eclipse.jgit.util.io; import java.io.IOException; import java.io.InterruptedIOException; import java.io.OutputStream; +import java.text.MessageFormat; + +import org.eclipse.jgit.JGitText; /** OutputStream with a configurable timeout. */ public class TimeoutOutputStream extends OutputStream { @@ -81,7 +84,7 @@ public class TimeoutOutputStream extends OutputStream { */ public void setTimeout(final int millis) { if (millis < 0) - throw new IllegalArgumentException("Invalid timeout: " + millis); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().invalidTimeout, millis)); timeout = millis; } @@ -147,6 +150,6 @@ public class TimeoutOutputStream extends OutputStream { } private static InterruptedIOException writeTimedOut() { - return new InterruptedIOException("Write timed out"); + return new InterruptedIOException(JGitText.get().writeTimedOut); } } |