The strings are externalized into the root resource bundles. The resource bundles are stored under the new "resources" source folder to get proper maven build. Strings from tests are, in general, not externalized. Only in cases where it was necessary to make the test pass the strings were externalized. This was typically necessary in cases where e.getMessage() was used in assert and the exception message was slightly changed due to reuse of the externalized strings. Change-Id: Ic0f29c80b9a54fcec8320d8539a3e112852a1f7b Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>tags/v0.8.1
@@ -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> |
@@ -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)" |
@@ -84,6 +84,9 @@ | |||
<include>plugin.properties</include> | |||
</includes> | |||
</resource> | |||
<resource> | |||
<directory>resources/</directory> | |||
</resource> | |||
</resources> | |||
<plugins> |
@@ -0,0 +1,5 @@ | |||
answerNo=n | |||
answerYes=y | |||
noSystemConsoleAvailable=No System.console available | |||
password=Password: | |||
usernameFor=Username for {0}: |
@@ -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]; | |||
} |
@@ -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) { |
@@ -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; | |||
} |
@@ -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"/> |
@@ -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)", |
@@ -90,6 +90,9 @@ | |||
<include>plugin.properties</include> | |||
</includes> | |||
</resource> | |||
<resource> | |||
<directory>resources/</directory> | |||
</resource> | |||
</resources> | |||
<plugins> |
@@ -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} |
@@ -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; |
@@ -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; |
@@ -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; | |||
} |
@@ -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; | |||
} |
@@ -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; | |||
} |
@@ -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; | |||
} | |||
@@ -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; |
@@ -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); |
@@ -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) { |
@@ -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; | |||
} | |||
@@ -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); | |||
} | |||
} |
@@ -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); | |||
} | |||
} |
@@ -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"/> |
@@ -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)", |
@@ -83,6 +83,9 @@ | |||
<include>plugin.properties</include> | |||
</includes> | |||
</resource> | |||
<resource> | |||
<directory>resources/</directory> | |||
</resource> | |||
</resources> | |||
<plugins> |
@@ -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 |
@@ -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()); | |||
} | |||
} |
@@ -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) | |||
@@ -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. */ |
@@ -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()); | |||
} | |||
} |
@@ -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; | |||
} |
@@ -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; | |||
} |
@@ -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(); | |||
} |
@@ -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; | |||
} |
@@ -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()); | |||
} | |||
} |
@@ -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"/> |
@@ -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 |
@@ -111,6 +111,9 @@ | |||
<include>META-INF/services/org.eclipse.jgit.pgm.TextBuiltin</include> | |||
</includes> | |||
</resource> | |||
<resource> | |||
<directory>resources/</directory> | |||
</resource> | |||
</resources> | |||
<plugins> |
@@ -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} |
@@ -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) { |
@@ -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); | |||
} | |||
} | |||
} |
@@ -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)); | |||
} | |||
} | |||
} |
@@ -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; | |||
} |
@@ -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(); | |||
} | |||
} | |||
} |
@@ -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; |
@@ -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; | |||
} | |||
} | |||
} |
@@ -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(); |
@@ -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 |
@@ -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 |
@@ -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; |
@@ -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 |
@@ -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())); | |||
} | |||
} |
@@ -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"); |
@@ -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 |
@@ -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 |
@@ -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(); |
@@ -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 |
@@ -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; | |||
@@ -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); | |||
} |
@@ -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)); | |||
} | |||
} | |||
@@ -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; | |||
@@ -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); |
@@ -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,19 +183,29 @@ 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> | |||
@@ -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; | |||
} | |||
@@ -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); |
@@ -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())); | |||
} | |||
} |
@@ -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)); |
@@ -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)); | |||
} | |||
} |
@@ -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); |
@@ -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)); |
@@ -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; | |||
} | |||
@@ -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); | |||
} | |||
} |
@@ -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(); | |||
} |
@@ -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); |
@@ -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; | |||
} | |||
} |
@@ -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; | |||
} | |||
@@ -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; | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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)", |
@@ -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); | |||
} | |||
} | |||
@@ -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()); | |||
} | |||
} |
@@ -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); | |||
} | |||
@@ -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( |
@@ -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()); | |||
} | |||
} | |||
@@ -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> |
@@ -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)", |
@@ -84,6 +84,9 @@ | |||
<include>plugin.properties</include> | |||
</includes> | |||
</resource> | |||
<resource> | |||
<directory>resources/</directory> | |||
</resource> | |||
</resources> | |||
<plugins> |
@@ -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 |
@@ -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()); |
@@ -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; | |||
} | |||
@@ -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()); |
@@ -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; | |||
} |
@@ -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"/> |
@@ -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", |
@@ -84,6 +84,9 @@ | |||
<include>plugin.properties</include> | |||
</includes> | |||
</resource> | |||
<resource> | |||
<directory>resources/</directory> | |||
</resource> | |||
</resources> | |||
<plugins> |