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
<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.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="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||||
<classpathentry kind="src" path="src"/> | <classpathentry kind="src" path="src"/> | ||||
<classpathentry kind="src" path="resources"/> | |||||
<classpathentry kind="output" path="bin"/> | <classpathentry kind="output" path="bin"/> | ||||
</classpath> | </classpath> |
Bundle-Vendor: %provider_name | Bundle-Vendor: %provider_name | ||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 | Bundle-RequiredExecutionEnvironment: JavaSE-1.6 | ||||
Export-Package: org.eclipse.jgit.console;version="0.8.0" | 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)" | org.eclipse.jgit.util;version="[0.8.0,0.9.0)" | ||||
Require-Bundle: com.jcraft.jsch;bundle-version="[0.1.37,0.2.0)" | Require-Bundle: com.jcraft.jsch;bundle-version="[0.1.37,0.2.0)" |
<include>plugin.properties</include> | <include>plugin.properties</include> | ||||
</includes> | </includes> | ||||
</resource> | </resource> | ||||
<resource> | |||||
<directory>resources/</directory> | |||||
</resource> | |||||
</resources> | </resources> | ||||
<plugins> | <plugins> |
answerNo=n | |||||
answerYes=y | |||||
noSystemConsoleAvailable=No System.console available | |||||
password=Password: | |||||
usernameFor=Username for {0}: |
import java.io.Console; | import java.io.Console; | ||||
import java.net.Authenticator; | import java.net.Authenticator; | ||||
import java.net.PasswordAuthentication; | import java.net.PasswordAuthentication; | ||||
import java.text.MessageFormat; | |||||
import org.eclipse.jgit.util.CachedAuthenticator; | import org.eclipse.jgit.util.CachedAuthenticator; | ||||
public static void install() { | public static void install() { | ||||
final ConsoleAuthenticator c = new ConsoleAuthenticator(); | final ConsoleAuthenticator c = new ConsoleAuthenticator(); | ||||
if (c.cons == null) | if (c.cons == null) | ||||
throw new NoClassDefFoundError("No System.console available"); | |||||
throw new NoClassDefFoundError(ConsoleText.get().noSystemConsoleAvailable); | |||||
Authenticator.setDefault(c); | Authenticator.setDefault(c); | ||||
} | } | ||||
@Override | @Override | ||||
protected PasswordAuthentication promptPasswordAuthentication() { | protected PasswordAuthentication promptPasswordAuthentication() { | ||||
final String realm = formatRealm(); | 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()) { | if (username == null || username.isEmpty()) { | ||||
return null; | return null; | ||||
} | } | ||||
char[] password = cons.readPassword("Password: "); | |||||
char[] password = cons.readPassword(ConsoleText.get().password + " "); | |||||
if (password == null) { | if (password == null) { | ||||
password = new char[0]; | password = new char[0]; | ||||
} | } |
public static void install() { | public static void install() { | ||||
final ConsoleSshSessionFactory c = new ConsoleSshSessionFactory(); | final ConsoleSshSessionFactory c = new ConsoleSshSessionFactory(); | ||||
if (c.cons == null) | if (c.cons == null) | ||||
throw new NoClassDefFoundError("No System.console available"); | |||||
throw new NoClassDefFoundError(ConsoleText.get().noSystemConsoleAvailable); | |||||
SshSessionFactory.setInstance(c); | SshSessionFactory.setInstance(c); | ||||
} | } | ||||
} | } | ||||
public boolean promptYesNo(final String msg) { | 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) { | public boolean promptPassword(final String msg) { |
/* | |||||
* 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; | |||||
} |
<?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||
<classpath> | <classpath> | ||||
<classpathentry kind="src" path="src"/> | <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.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="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||||
<classpathentry kind="output" path="bin"/> | <classpathentry kind="output" path="bin"/> |
javax.servlet.http;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.errors;version="[0.8.0,0.9.0)", | ||||
org.eclipse.jgit.lib;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.revwalk;version="[0.8.0,0.9.0)", | ||||
org.eclipse.jgit.transport;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)", | org.eclipse.jgit.util;version="[0.8.0,0.9.0)", |
<include>plugin.properties</include> | <include>plugin.properties</include> | ||||
</includes> | </includes> | ||||
</resource> | </resource> | ||||
<resource> | |||||
<directory>resources/</directory> | |||||
</resource> | |||||
</resources> | </resources> | ||||
<plugins> | <plugins> |
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} |
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.OutputStream; | import java.io.OutputStream; | ||||
import java.io.RandomAccessFile; | import java.io.RandomAccessFile; | ||||
import java.text.MessageFormat; | |||||
import java.util.Enumeration; | import java.util.Enumeration; | ||||
import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
} | } | ||||
final FileNotFoundException r; | final FileNotFoundException r; | ||||
r = new FileNotFoundException("Cannot get length of " + path); | |||||
r = new FileNotFoundException(MessageFormat.format(HttpServerText.get().cannotGetLengthOf, path)); | |||||
r.initCause(e); | r.initCause(e); | ||||
throw r; | throw r; | ||||
} | } | ||||
final int r = (int) Math.min(buf.length, end - pos); | final int r = (int) Math.min(buf.length, end - pos); | ||||
final int n = source.read(buf, 0, r); | final int n = source.read(buf, 0, r); | ||||
if (n < 0) { | if (n < 0) { | ||||
throw new EOFException("Unexpected EOF on " + path); | |||||
throw new EOFException(MessageFormat.format(HttpServerText.get().unexpectedeOFOn, path)); | |||||
} | } | ||||
out.write(buf, 0, n); | out.write(buf, 0, n); | ||||
pos += n; | pos += n; |
package org.eclipse.jgit.http.server; | package org.eclipse.jgit.http.server; | ||||
import java.io.File; | import java.io.File; | ||||
import java.text.MessageFormat; | |||||
import javax.servlet.ServletConfig; | import javax.servlet.ServletConfig; | ||||
import javax.servlet.ServletException; | import javax.servlet.ServletException; | ||||
private void assertNotInitialized() { | private void assertNotInitialized() { | ||||
if (initialized) | if (initialized) | ||||
throw new IllegalStateException("Already initialized by container"); | |||||
throw new IllegalStateException(HttpServerText.get().alreadyInitializedByContainer); | |||||
} | } | ||||
@Override | @Override | ||||
private File getFile(final String param) throws ServletException { | private File getFile(final String param) throws ServletException { | ||||
String n = getInitParameter(param); | String n = getInitParameter(param); | ||||
if (n == null || "".equals(n)) | 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); | File path = new File(n); | ||||
if (!path.exists()) | if (!path.exists()) | ||||
throw new ServletException(path + " (for " + param + ") not found"); | |||||
throw new ServletException(MessageFormat.format(HttpServerText.get().pathForParamNotFound, path, param)); | |||||
return path; | return path; | ||||
} | } | ||||
try { | try { | ||||
return StringUtils.toBoolean(n); | return StringUtils.toBoolean(n); | ||||
} catch (IllegalArgumentException err) { | } catch (IllegalArgumentException err) { | ||||
throw new ServletException("Invalid boolean " + param + " = " + n); | |||||
throw new ServletException(MessageFormat.format(HttpServerText.get().invalidBoolean, param, n)); | |||||
} | } | ||||
} | } | ||||
@Override | @Override | ||||
protected ServletBinder register(ServletBinder binder) { | protected ServletBinder register(ServletBinder binder) { | ||||
if (resolver == null) | if (resolver == null) | ||||
throw new IllegalStateException("No resolver available"); | |||||
throw new IllegalStateException(HttpServerText.get().noResolverAvailable); | |||||
binder = binder.through(new NoCacheFilter()); | binder = binder.through(new NoCacheFilter()); | ||||
binder = binder.through(new RepositoryFilter(resolver)); | binder = binder.through(new RepositoryFilter(resolver)); | ||||
return binder; | return binder; |
/* | |||||
* 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; | |||||
} |
return; | return; | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
getServletContext().log("Internal error during receive-pack", e); | |||||
getServletContext().log(HttpServerText.get().internalErrorDuringReceivePack, e); | |||||
rsp.sendError(SC_INTERNAL_SERVER_ERROR); | rsp.sendError(SC_INTERNAL_SERVER_ERROR); | ||||
return; | return; | ||||
} | } |
import static org.eclipse.jgit.http.server.ServletUtils.ATTRIBUTE_REPOSITORY; | import static org.eclipse.jgit.http.server.ServletUtils.ATTRIBUTE_REPOSITORY; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.text.MessageFormat; | |||||
import javax.servlet.Filter; | import javax.servlet.Filter; | ||||
import javax.servlet.FilterChain; | import javax.servlet.FilterChain; | ||||
final ServletResponse rsp, final FilterChain chain) | final ServletResponse rsp, final FilterChain chain) | ||||
throws IOException, ServletException { | throws IOException, ServletException { | ||||
if (request.getAttribute(ATTRIBUTE_REPOSITORY) != null) { | 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); | ((HttpServletResponse) rsp).sendError(SC_INTERNAL_SERVER_ERROR); | ||||
return; | return; | ||||
} | } |
import java.io.InputStream; | import java.io.InputStream; | ||||
import java.io.OutputStream; | import java.io.OutputStream; | ||||
import java.security.MessageDigest; | import java.security.MessageDigest; | ||||
import java.text.MessageFormat; | |||||
import java.util.zip.GZIPInputStream; | import java.util.zip.GZIPInputStream; | ||||
import java.util.zip.GZIPOutputStream; | import java.util.zip.GZIPOutputStream; | ||||
public static Repository getRepository(final ServletRequest req) { | public static Repository getRepository(final ServletRequest req) { | ||||
Repository db = (Repository) req.getAttribute(ATTRIBUTE_REPOSITORY); | Repository db = (Repository) req.getAttribute(ATTRIBUTE_REPOSITORY); | ||||
if (db == null) | if (db == null) | ||||
throw new IllegalStateException("Expected Repository attribute"); | |||||
throw new IllegalStateException(HttpServerText.get().expectedRepositoryAttribute); | |||||
return db; | return db; | ||||
} | } | ||||
if (ENCODING_GZIP.equals(enc) || "x-gzip".equals(enc)) //$NON-NLS-1$ | if (ENCODING_GZIP.equals(enc) || "x-gzip".equals(enc)) //$NON-NLS-1$ | ||||
in = new GZIPInputStream(in); | in = new GZIPInputStream(in); | ||||
else if (enc != null) | 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; | return in; | ||||
} | } | ||||
return; | return; | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
getServletContext().log("Internal error during upload-pack", e); | |||||
getServletContext().log(HttpServerText.get().internalErrorDuringUploadPack, e); | |||||
rsp.reset(); | rsp.reset(); | ||||
rsp.sendError(SC_INTERNAL_SERVER_ERROR); | rsp.sendError(SC_INTERNAL_SERVER_ERROR); | ||||
return; | return; |
import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND; | import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.text.MessageFormat; | |||||
import java.util.AbstractSet; | import java.util.AbstractSet; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.IdentityHashMap; | import java.util.IdentityHashMap; | ||||
import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
import org.eclipse.jgit.http.server.HttpServerText; | |||||
/** | /** | ||||
* Generic container servlet to manage routing to different pipelines. | * Generic container servlet to manage routing to different pipelines. | ||||
* <p> | * <p> | ||||
public ServletBinder serve(String path) { | public ServletBinder serve(String path) { | ||||
if (path.startsWith("*")) | if (path.startsWith("*")) | ||||
return register(new SuffixPipeline.Binder(path.substring(1))); | return register(new SuffixPipeline.Binder(path.substring(1))); | ||||
throw new IllegalArgumentException("\"" + path + "\" not supported"); | |||||
throw new IllegalArgumentException(MessageFormat.format(HttpServerText.get().pathNotSupported, path)); | |||||
} | } | ||||
/** | /** | ||||
private ServletBinder register(ServletBinderImpl b) { | private ServletBinder register(ServletBinderImpl b) { | ||||
synchronized (bindings) { | synchronized (bindings) { | ||||
if (pipelines != null) | if (pipelines != null) | ||||
throw new IllegalStateException("Servlet already initialized"); | |||||
throw new IllegalStateException(HttpServerText.get().servletAlreadyInitialized); | |||||
bindings.add(b); | bindings.add(b); | ||||
} | } | ||||
return register((ServletBinder) b); | return register((ServletBinder) b); |
package org.eclipse.jgit.http.server.glue; | package org.eclipse.jgit.http.server.glue; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.text.MessageFormat; | |||||
import javax.servlet.Filter; | import javax.servlet.Filter; | ||||
import javax.servlet.FilterChain; | import javax.servlet.FilterChain; | ||||
import javax.servlet.ServletRequest; | import javax.servlet.ServletRequest; | ||||
import javax.servlet.ServletResponse; | import javax.servlet.ServletResponse; | ||||
import org.eclipse.jgit.http.server.HttpServerText; | |||||
/** | /** | ||||
* Switch servlet path and path info to use another regex match group. | * Switch servlet path and path info to use another regex match group. | ||||
* <p> | * <p> | ||||
*/ | */ | ||||
public RegexGroupFilter(final int groupIdx) { | public RegexGroupFilter(final int groupIdx) { | ||||
if (groupIdx < 1) | if (groupIdx < 1) | ||||
throw new IllegalArgumentException("Invalid index: " + groupIdx); | |||||
throw new IllegalArgumentException(MessageFormat.format(HttpServerText.get().invalidIndex, groupIdx)); | |||||
this.groupIdx = groupIdx - 1; | this.groupIdx = groupIdx - 1; | ||||
} | } | ||||
if (groupIdx < g.length) | if (groupIdx < g.length) | ||||
chain.doFilter(g[groupIdx], rsp); | chain.doFilter(g[groupIdx], rsp); | ||||
else | 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) { | private static WrappedRequest[] groupsFor(final ServletRequest r) { |
import javax.servlet.http.HttpServlet; | import javax.servlet.http.HttpServlet; | ||||
import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
import org.eclipse.jgit.http.server.HttpServerText; | |||||
abstract class ServletBinderImpl implements ServletBinder { | abstract class ServletBinderImpl implements ServletBinder { | ||||
private final List<Filter> filters; | private final List<Filter> filters; | ||||
public ServletBinder through(Filter filter) { | public ServletBinder through(Filter filter) { | ||||
if (filter == null) | if (filter == null) | ||||
throw new NullPointerException("filter must not be null"); | |||||
throw new NullPointerException(HttpServerText.get().filterMustNotBeNull); | |||||
filters.add(filter); | filters.add(filter); | ||||
return this; | return this; | ||||
} | } | ||||
public void with(HttpServlet servlet) { | public void with(HttpServlet servlet) { | ||||
if (servlet == null) | if (servlet == null) | ||||
throw new NullPointerException("servlet must not be null"); | |||||
throw new NullPointerException(HttpServerText.get().servletMustNotBeNull); | |||||
if (httpServlet != null) | if (httpServlet != null) | ||||
throw new IllegalStateException("servlet was already bound"); | |||||
throw new IllegalStateException(HttpServerText.get().servletWasAlreadyBound); | |||||
httpServlet = servlet; | httpServlet = servlet; | ||||
} | } | ||||
package org.eclipse.jgit.http.server.resolver; | package org.eclipse.jgit.http.server.resolver; | ||||
import org.eclipse.jgit.http.server.HttpServerText; | |||||
/** Indicates the request service is not authorized for current user. */ | /** Indicates the request service is not authorized for current user. */ | ||||
public class ServiceNotAuthorizedException extends Exception { | public class ServiceNotAuthorizedException extends Exception { | ||||
private static final long serialVersionUID = 1L; | private static final long serialVersionUID = 1L; | ||||
/** Indicates the request service is not available. */ | /** Indicates the request service is not available. */ | ||||
public ServiceNotAuthorizedException() { | public ServiceNotAuthorizedException() { | ||||
super("Service not permitted"); | |||||
super(HttpServerText.get().serviceNotPermitted); | |||||
} | } | ||||
} | } |
package org.eclipse.jgit.http.server.resolver; | package org.eclipse.jgit.http.server.resolver; | ||||
import org.eclipse.jgit.http.server.HttpServerText; | |||||
/** Indicates the request service is not enabled on a repository. */ | /** Indicates the request service is not enabled on a repository. */ | ||||
public class ServiceNotEnabledException extends Exception { | public class ServiceNotEnabledException extends Exception { | ||||
private static final long serialVersionUID = 1L; | private static final long serialVersionUID = 1L; | ||||
/** Indicates the request service is not available. */ | /** Indicates the request service is not available. */ | ||||
public ServiceNotEnabledException() { | public ServiceNotEnabledException() { | ||||
super("Service not enabled"); | |||||
super(HttpServerText.get().serviceNotEnabled); | |||||
} | } | ||||
} | } |
<?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||
<classpath> | <classpath> | ||||
<classpathentry kind="src" path="src"/> | <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.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="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||||
<classpathentry kind="output" path="bin"/> | <classpathentry kind="output" path="bin"/> |
org.eclipse.jgit.dircache;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.errors;version="[0.8.0,0.9.0)", | ||||
org.eclipse.jgit.lib;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.revplot;version="[0.8.0,0.9.0)", | ||||
org.eclipse.jgit.revwalk;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)", | org.eclipse.jgit.revwalk.filter;version="[0.8.0,0.9.0)", |
<include>plugin.properties</include> | <include>plugin.properties</include> | ||||
</includes> | </includes> | ||||
</resource> | </resource> | ||||
<resource> | |||||
<directory>resources/</directory> | |||||
</resource> | |||||
</resources> | </resources> | ||||
<plugins> | <plugins> |
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 |
package org.eclipse.jgit.iplog; | package org.eclipse.jgit.iplog; | ||||
import java.text.MessageFormat; | |||||
import java.util.Comparator; | import java.util.Comparator; | ||||
/** | /** | ||||
@Override | @Override | ||||
public String toString() { | public String toString() { | ||||
return "CQ " + getID(); | |||||
return MessageFormat.format(IpLogText.get().CQString, getID()); | |||||
} | } | ||||
} | } |
import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.text.MessageFormat; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.LinkedHashMap; | import java.util.LinkedHashMap; | ||||
import java.util.List; | import java.util.List; | ||||
} | } | ||||
} | } | ||||
if (p < line.length() && line.charAt(p) != ',') | 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()); | row.add(b.toString()); | ||||
p++; // skip the trailing comma (if present) | p++; // skip the trailing comma (if present) | ||||
package org.eclipse.jgit.iplog; | package org.eclipse.jgit.iplog; | ||||
import java.text.MessageFormat; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Collections; | import java.util.Collections; | ||||
import java.util.Comparator; | import java.util.Comparator; | ||||
@Override | @Override | ||||
public String toString() { | public String toString() { | ||||
return "Committer " + getFirstName() + " " + getLastName(); | |||||
return MessageFormat.format(IpLogText.get().committerString, getFirstName(), getLastName()); | |||||
} | } | ||||
/** Date period during which the committer was active. */ | /** Date period during which the committer was active. */ |
package org.eclipse.jgit.iplog; | package org.eclipse.jgit.iplog; | ||||
import java.text.MessageFormat; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Collection; | import java.util.Collection; | ||||
import java.util.Collections; | import java.util.Collections; | ||||
@Override | @Override | ||||
public String toString() { | public String toString() { | ||||
return "Contributor " + getName(); | |||||
return MessageFormat.format(IpLogText.get().contributorString, getName()); | |||||
} | } | ||||
} | } |
import java.net.URISyntaxException; | import java.net.URISyntaxException; | ||||
import java.net.URL; | import java.net.URL; | ||||
import java.net.URLEncoder; | import java.net.URLEncoder; | ||||
import java.text.MessageFormat; | |||||
import java.util.Collection; | import java.util.Collection; | ||||
import java.util.Collections; | import java.util.Collections; | ||||
import java.util.HashMap; | import java.util.HashMap; | ||||
HttpURLConnection conn = open(csv); | HttpURLConnection conn = open(csv); | ||||
if (HttpSupport.response(conn) != HttpURLConnection.HTTP_OK) { | 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); | BufferedReader br = reader(conn); | ||||
out.close(); | out.close(); | ||||
if (HttpSupport.response(c) != HttpURLConnection.HTTP_OK) { | 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); | String content = readFully(c); | ||||
Matcher matcher = Pattern.compile("<title>(.*)</title>", | Matcher matcher = Pattern.compile("<title>(.*)</title>", | ||||
Pattern.CASE_INSENSITIVE).matcher(content); | Pattern.CASE_INSENSITIVE).matcher(content); | ||||
if (!matcher.find()) { | 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); | String title = matcher.group(1); | ||||
if (!"IPZilla Main Page".equals(title)) { | 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))); | |||||
} | } | ||||
} | } | ||||
try { | try { | ||||
CookieHandler.getDefault().put(url.toURI(), cols); | CookieHandler.getDefault().put(url.toURI(), cols); | ||||
} catch (URISyntaxException e) { | } catch (URISyntaxException e) { | ||||
IOException err = new IOException("Invalid URI format:" + url); | |||||
IOException err = new IOException(MessageFormat.format(IpLogText.get().invalidURIFormat, url)); | |||||
err.initCause(e); | err.initCause(e); | ||||
throw err; | throw err; | ||||
} | } |
import java.io.FileReader; | import java.io.FileReader; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.OutputStream; | import java.io.OutputStream; | ||||
import java.text.MessageFormat; | |||||
import java.text.ParseException; | import java.text.ParseException; | ||||
import java.text.SimpleDateFormat; | import java.text.SimpleDateFormat; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
try { | try { | ||||
meta.loadFrom(new BlobBasedConfig(null, db, log.getObjectId(0))); | meta.loadFrom(new BlobBasedConfig(null, db, log.getObjectId(0))); | ||||
} catch (ConfigInvalidException e) { | } 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()) { | 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()) { | for (Project p : meta.getProjects()) { | ||||
try { | try { | ||||
return dt.parse(value); | return dt.parse(value); | ||||
} catch (ParseException e) { | } catch (ParseException e) { | ||||
IOException err = new IOException("Invalid date: " + value); | |||||
IOException err = new IOException(MessageFormat.format(IpLogText.get().invalidDate, value)); | |||||
err.initCause(e); | err.initCause(e); | ||||
throw err; | throw err; | ||||
} | } | ||||
} | } | ||||
if (addedLines < 0) | if (addedLines < 0) | ||||
throw new IOException("Incorrectly scanned " + commit.name()); | |||||
throw new IOException(MessageFormat.format(IpLogText.get().incorrectlyScanned, commit.name())); | |||||
if (1 == addedLines) | if (1 == addedLines) | ||||
item.setSize("+1 line"); | item.setSize("+1 line"); | ||||
else | else | ||||
s.setOutputProperty(INDENT, "2"); | s.setOutputProperty(INDENT, "2"); | ||||
s.transform(new DOMSource(toXML()), new StreamResult(out)); | s.transform(new DOMSource(toXML()), new StreamResult(out)); | ||||
} catch (ParserConfigurationException e) { | } catch (ParserConfigurationException e) { | ||||
IOException err = new IOException("Cannot serialize XML"); | |||||
IOException err = new IOException(IpLogText.get().cannotSerializeXML); | |||||
err.initCause(e); | err.initCause(e); | ||||
throw err; | throw err; | ||||
} catch (TransformerConfigurationException e) { | } catch (TransformerConfigurationException e) { | ||||
IOException err = new IOException("Cannot serialize XML"); | |||||
IOException err = new IOException(IpLogText.get().cannotSerializeXML); | |||||
err.initCause(e); | err.initCause(e); | ||||
throw err; | throw err; | ||||
} catch (TransformerException e) { | } catch (TransformerException e) { | ||||
IOException err = new IOException("Cannot serialize XML"); | |||||
IOException err = new IOException(IpLogText.get().cannotSerializeXML); | |||||
err.initCause(e); | err.initCause(e); | ||||
throw err; | throw err; | ||||
} | } |
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.net.URL; | import java.net.URL; | ||||
import java.text.MessageFormat; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Collection; | import java.util.Collection; | ||||
import java.util.Collections; | import java.util.Collections; | ||||
LockFile lf = new LockFile(file); | LockFile lf = new LockFile(file); | ||||
if (!lf.lock()) | if (!lf.lock()) | ||||
throw new IOException("Cannot lock " + file); | |||||
throw new IOException(MessageFormat.format(IpLogText.get().cannotLock, file)); | |||||
try { | try { | ||||
FileBasedConfig cfg = new FileBasedConfig(file); | FileBasedConfig cfg = new FileBasedConfig(file); | ||||
cfg.load(); | cfg.load(); | ||||
lf.write(Constants.encode(cfg.toText())); | lf.write(Constants.encode(cfg.toText())); | ||||
if (!lf.commit()) | if (!lf.commit()) | ||||
throw new IOException("Cannot write " + file); | |||||
throw new IOException(MessageFormat.format(IpLogText.get().cannotWrite, file)); | |||||
} finally { | } finally { | ||||
lf.unlock(); | lf.unlock(); | ||||
} | } |
/* | |||||
* 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; | |||||
} |
package org.eclipse.jgit.iplog; | package org.eclipse.jgit.iplog; | ||||
import java.text.MessageFormat; | |||||
import java.util.Collections; | import java.util.Collections; | ||||
import java.util.Comparator; | import java.util.Comparator; | ||||
import java.util.Set; | import java.util.Set; | ||||
@Override | @Override | ||||
public String toString() { | public String toString() { | ||||
return "Project " + getID() + " (" + getName() + ")"; | |||||
return MessageFormat.format(IpLogText.get().projectString, getID(), getName()); | |||||
} | } | ||||
} | } |
<?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||
<classpath> | <classpath> | ||||
<classpathentry kind="src" path="src"/> | <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.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="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||||
<classpathentry kind="output" path="bin"/> | <classpathentry kind="output" path="bin"/> |
org.eclipse.jgit.diff;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.dircache;version="[0.8.0,0.9.0)", | ||||
org.eclipse.jgit.errors;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.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.revplot;version="[0.8.0,0.9.0)", | ||||
org.eclipse.jgit.revwalk;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)", | org.eclipse.jgit.revwalk.filter;version="[0.8.0,0.9.0)", | ||||
org.eclipse.jgit.treewalk;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.treewalk.filter;version="[0.8.0,0.9.0)", | ||||
org.eclipse.jgit.util;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;version="[2.0.12,2.1.0)", | ||||
org.kohsuke.args4j.spi;version="[2.0.12,2.1.0)" | org.kohsuke.args4j.spi;version="[2.0.12,2.1.0)" | ||||
Bundle-ActivationPolicy: lazy | 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 | Main-Class: org.eclipse.jgit.pgm.Main | ||||
Implementation-Title: JGit Command Line Interface | Implementation-Title: JGit Command Line Interface |
<include>META-INF/services/org.eclipse.jgit.pgm.TextBuiltin</include> | <include>META-INF/services/org.eclipse.jgit.pgm.TextBuiltin</include> | ||||
</includes> | </includes> | ||||
</resource> | </resource> | ||||
<resource> | |||||
<directory>resources/</directory> | |||||
</resource> | |||||
</resources> | </resources> | ||||
<plugins> | <plugins> |
# 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} |
* Copyright (C) 2008-2010, Google Inc. | * Copyright (C) 2008-2010, Google Inc. | ||||
* Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com> | * Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com> | ||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> | * 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. | * and other copyright owners as documented in the project's IP log. | ||||
* | * | ||||
* This program and the accompanying materials are made available | * This program and the accompanying materials are made available | ||||
package org.eclipse.jgit.pgm; | package org.eclipse.jgit.pgm; | ||||
import java.io.PrintWriter; | |||||
import org.kohsuke.args4j.Option; | import org.kohsuke.args4j.Option; | ||||
import org.eclipse.jgit.lib.Constants; | import org.eclipse.jgit.lib.Constants; | ||||
import org.eclipse.jgit.lib.ObjectId; | import org.eclipse.jgit.lib.ObjectId; | ||||
import org.eclipse.jgit.transport.Transport; | import org.eclipse.jgit.transport.Transport; | ||||
abstract class AbstractFetchCommand extends TextBuiltin { | 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; | private boolean verbose; | ||||
protected void showFetchResult(final Transport tn, final FetchResult r) { | protected void showFetchResult(final Transport tn, final FetchResult r) { | ||||
final String dst = abbreviateRef(u.getLocalName(), true); | final String dst = abbreviateRef(u.getLocalName(), true); | ||||
if (!shownURI) { | if (!shownURI) { | ||||
out.print("From "); | |||||
out.print(tn.getURI()); | |||||
out.format(CLIText.get().fromURI, tn.getURI()); | |||||
out.println(); | out.println(); | ||||
shownURI = true; | shownURI = true; | ||||
} | } | ||||
} | } | ||||
static void showRemoteMessages(String pkt) { | static void showRemoteMessages(String pkt) { | ||||
PrintWriter writer = new PrintWriter(System.err); | |||||
while (0 < pkt.length()) { | while (0 < pkt.length()) { | ||||
final int lf = pkt.indexOf('\n'); | final int lf = pkt.indexOf('\n'); | ||||
final int cr = pkt.indexOf('\r'); | final int cr = pkt.indexOf('\r'); | ||||
else if (0 <= cr) | else if (0 <= cr) | ||||
s = cr; | s = cr; | ||||
else { | else { | ||||
System.err.println("remote: " + pkt); | |||||
writer.format(CLIText.get().remoteMessage, pkt); | |||||
writer.println(); | |||||
break; | 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); | pkt = pkt.substring(s + 1); | ||||
} | } | ||||
System.err.flush(); | |||||
writer.flush(); | |||||
} | } | ||||
private String longTypeOf(final TrackingRefUpdate u) { | private String longTypeOf(final TrackingRefUpdate u) { |
import java.io.InputStream; | import java.io.InputStream; | ||||
import java.io.OutputStream; | import java.io.OutputStream; | ||||
import java.net.URLConnection; | import java.net.URLConnection; | ||||
import java.text.MessageFormat; | |||||
import java.util.Properties; | import java.util.Properties; | ||||
import org.eclipse.jgit.transport.AmazonS3; | import org.eclipse.jgit.transport.AmazonS3; | ||||
import org.kohsuke.args4j.Argument; | 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 { | class AmazonS3Client extends TextBuiltin { | ||||
@Argument(index = 0, metaVar = "conn.prop", required = true) | |||||
@Argument(index = 0, metaVar = "metaVar_connProp", required = true) | |||||
private File propertyFile; | private File propertyFile; | ||||
@Argument(index = 1, metaVar = "OP", required = true) | |||||
@Argument(index = 1, metaVar = "metaVar_op", required = true) | |||||
private String op; | private String op; | ||||
@Argument(index = 2, metaVar = "BUCKET", required = true) | |||||
@Argument(index = 2, metaVar = "metaVar_bucket", required = true) | |||||
private String bucket; | private String bucket; | ||||
@Argument(index = 3, metaVar = "KEY", required = true) | |||||
@Argument(index = 3, metaVar = "metaVar_KEY", required = true) | |||||
private String key; | private String key; | ||||
@Override | @Override | ||||
while (len > 0) { | while (len > 0) { | ||||
final int n = in.read(tmp); | final int n = in.read(tmp); | ||||
if (n < 0) | if (n < 0) | ||||
throw new EOFException("Expected " + len + " bytes."); | |||||
throw new EOFException(MessageFormat.format(CLIText.get().expectedNumberOfbytes, len)); | |||||
System.out.write(tmp, 0, n); | System.out.write(tmp, 0, n); | ||||
len -= n; | len -= n; | ||||
} | } | ||||
os.close(); | os.close(); | ||||
} else { | } else { | ||||
throw die("Unsupported operation: " + op); | |||||
throw die(MessageFormat.format(CLIText.get().unsupportedOperation, op)); | |||||
} | } | ||||
} | } | ||||
in.close(); | in.close(); | ||||
} | } | ||||
} catch (FileNotFoundException e) { | } catch (FileNotFoundException e) { | ||||
throw die("no such file: " + propertyFile, e); | |||||
throw die(MessageFormat.format(CLIText.get().noSuchFile, propertyFile), e); | |||||
} catch (IOException e) { | } catch (IOException e) { | ||||
throw die("cannot read " + propertyFile, e); | |||||
throw die(MessageFormat.format(CLIText.get().cannotReadBecause, propertyFile, e.getMessage()), e); | |||||
} | } | ||||
} | } | ||||
} | } |
package org.eclipse.jgit.pgm; | package org.eclipse.jgit.pgm; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.text.MessageFormat; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.LinkedHashMap; | import java.util.LinkedHashMap; | ||||
import java.util.List; | import java.util.List; | ||||
import org.kohsuke.args4j.ExampleMode; | import org.kohsuke.args4j.ExampleMode; | ||||
import org.kohsuke.args4j.Option; | import org.kohsuke.args4j.Option; | ||||
@Command(common = true, usage = "List, create, or delete branches") | |||||
@Command(common = true, usage = "usage_listCreateOrDeleteBranches") | |||||
class Branch extends TextBuiltin { | 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; | 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; | 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; | 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; | 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; | private boolean createForce = false; | ||||
@Option(name = "-m", usage = "move/rename a branch") | |||||
@Option(name = "-m", usage = "usage_moveRenameABranch") | |||||
private boolean rename = false; | private boolean rename = false; | ||||
@Option(name = "--verbose", aliases = { "-v" }, usage = "be verbose") | |||||
@Option(name = "--verbose", aliases = { "-v" }, usage = "usage_beVerbose") | |||||
private boolean verbose = false; | private boolean verbose = false; | ||||
@Argument | @Argument | ||||
delete(deleteForce); | delete(deleteForce); | ||||
else { | else { | ||||
if (branches.size() > 2) | 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) { | if (rename) { | ||||
String src, dst; | String src, dst; | ||||
if (head != null && head.isSymbolic()) | if (head != null && head.isSymbolic()) | ||||
src = head.getLeaf().getName(); | src = head.getLeaf().getName(); | ||||
else | else | ||||
throw die("Cannot rename detached HEAD"); | |||||
throw die(CLIText.get().cannotRenameDetachedHEAD); | |||||
dst = branches.get(0); | dst = branches.get(0); | ||||
} else { | } else { | ||||
src = branches.get(0); | src = branches.get(0); | ||||
final Ref old = db.getRef(src); | final Ref old = db.getRef(src); | ||||
if (old == null) | 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)) | 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(); | src = old.getName(); | ||||
dst = branches.get(1); | dst = branches.get(1); | ||||
} | } | ||||
if (!dst.startsWith(Constants.R_HEADS)) | if (!dst.startsWith(Constants.R_HEADS)) | ||||
dst = Constants.R_HEADS + dst; | dst = Constants.R_HEADS + dst; | ||||
if (!Repository.isValidRefName(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); | RefRename r = db.renameRef(src, dst); | ||||
if (r.rename() != Result.RENAMED) | 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) { | } else if (branches.size() > 0) { | ||||
String newHead = branches.get(0); | String newHead = branches.get(0); | ||||
if (!newRefName.startsWith(Constants.R_HEADS)) | if (!newRefName.startsWith(Constants.R_HEADS)) | ||||
newRefName = Constants.R_HEADS + newRefName; | newRefName = Constants.R_HEADS + newRefName; | ||||
if (!Repository.isValidRefName(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) | 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); | RefUpdate updateRef = db.updateRef(newRefName); | ||||
updateRef.setNewObjectId(startAt); | updateRef.setNewObjectId(startAt); | ||||
updateRef.setForceUpdate(createForce); | updateRef.setForceUpdate(createForce); | ||||
updateRef.setRefLogMessage("branch: Created from " + startBranch, false); | |||||
updateRef.setRefLogMessage(MessageFormat.format(CLIText.get().branchCreatedFrom, startBranch), false); | |||||
Result update = updateRef.update(); | Result update = updateRef.update(); | ||||
if (update == Result.REJECTED) | 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 { | } else { | ||||
if (verbose) | if (verbose) | ||||
rw = new RevWalk(db); | rw = new RevWalk(db); | ||||
out.print(ref); | out.print(ref); | ||||
if (verbose) { | if (verbose) { | ||||
final int spaces = maxNameLength - ref.length() + 1; | final int spaces = maxNameLength - ref.length() + 1; | ||||
out.print(String.format("%" + spaces + "s", "")); | |||||
out.format("%" + spaces + "s", ""); | |||||
final ObjectId objectId = refObj.getObjectId(); | final ObjectId objectId = refObj.getObjectId(); | ||||
out.print(objectId.abbreviate(db).name()); | out.print(objectId.abbreviate(db).name()); | ||||
out.print(' '); | out.print(' '); | ||||
ObjectId head = db.resolve(Constants.HEAD); | ObjectId head = db.resolve(Constants.HEAD); | ||||
for (String branch : branches) { | for (String branch : branches) { | ||||
if (current.equals(branch)) { | 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 | RefUpdate update = db.updateRef((remote ? Constants.R_REMOTES | ||||
: Constants.R_HEADS) | : Constants.R_HEADS) | ||||
update.setForceUpdate(force || remote); | update.setForceUpdate(force || remote); | ||||
Result result = update.delete(); | Result result = update.delete(); | ||||
if (result == Result.REJECTED) { | 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) | } else if (result == Result.NEW) | ||||
throw die(String.format("branch '%s' not found.", branch)); | |||||
throw die(MessageFormat.format(CLIText.get().branchNotFound, branch)); | |||||
if (remote) | if (remote) | ||||
out.println(String.format("Deleted remote branch %s", branch)); | |||||
out.println(MessageFormat.format(CLIText.get().deletedRemoteBranch, branch)); | |||||
else if (verbose) | else if (verbose) | ||||
out.println(String.format("Deleted branch %s", branch)); | |||||
out.println(MessageFormat.format(CLIText.get().deletedBranch, branch)); | |||||
} | } | ||||
} | } | ||||
} | } |
/* | |||||
* 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; | |||||
} |
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.net.URISyntaxException; | import java.net.URISyntaxException; | ||||
import java.text.MessageFormat; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Collections; | import java.util.Collections; | ||||
import java.util.List; | import java.util.List; | ||||
import org.eclipse.jgit.transport.Transport; | import org.eclipse.jgit.transport.Transport; | ||||
import org.eclipse.jgit.transport.URIish; | 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 { | 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; | 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; | private String sourceUri; | ||||
@Argument(index = 1, metaVar = "directory") | |||||
@Argument(index = 1, metaVar = "metaVar_directory") | |||||
private String localName; | private String localName; | ||||
@Override | @Override | ||||
@Override | @Override | ||||
protected void run() throws Exception { | protected void run() throws Exception { | ||||
if (localName != null && gitdir != null) | 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); | final URIish uri = new URIish(sourceUri); | ||||
if (localName == null) { | if (localName == null) { | ||||
try { | try { | ||||
localName = uri.getHumanishName(); | localName = uri.getHumanishName(); | ||||
} catch (IllegalArgumentException e) { | } catch (IllegalArgumentException e) { | ||||
throw die("cannot guess local name from " + sourceUri); | |||||
throw die(MessageFormat.format(CLIText.get().cannotGuessLocalNameFrom, sourceUri)); | |||||
} | } | ||||
} | } | ||||
if (gitdir == null) | if (gitdir == null) | ||||
db.getConfig().setBoolean("core", null, "bare", false); | db.getConfig().setBoolean("core", null, "bare", false); | ||||
db.getConfig().save(); | db.getConfig().save(); | ||||
out.println("Initialized empty Git repository in " | |||||
+ gitdir.getAbsolutePath()); | |||||
out.format(CLIText.get().initializedEmptyGitRepositoryIn, gitdir.getAbsolutePath()); | |||||
out.println(); | |||||
out.flush(); | out.flush(); | ||||
saveRemote(uri); | saveRemote(uri); | ||||
private void doCheckout(final Ref branch) throws IOException { | private void doCheckout(final Ref branch) throws IOException { | ||||
if (branch == null) | if (branch == null) | ||||
throw die("cannot checkout; no HEAD advertised by remote"); | |||||
throw die(CLIText.get().cannotChekoutNoHeadsAdvertisedByRemote); | |||||
if (!Constants.HEAD.equals(branch.getName())) { | if (!Constants.HEAD.equals(branch.getName())) { | ||||
RefUpdate u = db.updateRef(Constants.HEAD); | RefUpdate u = db.updateRef(Constants.HEAD); | ||||
u.disableRefLog(); | u.disableRefLog(); | ||||
co.checkout(); | co.checkout(); | ||||
index.write(); | index.write(); | ||||
} | } | ||||
} | |||||
} |
import java.lang.reflect.Constructor; | import java.lang.reflect.Constructor; | ||||
import java.lang.reflect.InvocationTargetException; | import java.lang.reflect.InvocationTargetException; | ||||
import java.text.MessageFormat; | |||||
/** | /** | ||||
* Description of a command (a {@link TextBuiltin} subclass. | * Description of a command (a {@link TextBuiltin} subclass. | ||||
try { | try { | ||||
c = impl.getDeclaredConstructor(); | c = impl.getDeclaredConstructor(); | ||||
} catch (SecurityException e) { | } catch (SecurityException e) { | ||||
throw new RuntimeException("Cannot create command " + getName(), e); | |||||
throw new RuntimeException(MessageFormat.format(CLIText.get().cannotCreateCommand, getName(), e)); | |||||
} catch (NoSuchMethodException 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); | c.setAccessible(true); | ||||
try { | try { | ||||
r = c.newInstance(); | r = c.newInstance(); | ||||
} catch (InstantiationException e) { | } catch (InstantiationException e) { | ||||
throw new RuntimeException("Cannot create command " + getName(), e); | |||||
throw new RuntimeException(MessageFormat.format(CLIText.get().cannotCreateCommand, getName(), e)); | |||||
} catch (IllegalAccessException 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) { | } catch (IllegalArgumentException e) { | ||||
throw new RuntimeException("Cannot create command " + getName(), e); | |||||
throw new RuntimeException(MessageFormat.format(CLIText.get().cannotCreateCommand, getName(), e)); | |||||
} catch (InvocationTargetException 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()); | r.setCommandName(getName()); | ||||
return r; | return r; |
import java.io.File; | import java.io.File; | ||||
import java.net.InetSocketAddress; | import java.net.InetSocketAddress; | ||||
import java.text.MessageFormat; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
import org.kohsuke.args4j.Option; | import org.kohsuke.args4j.Option; | ||||
import org.eclipse.jgit.transport.DaemonService; | import org.eclipse.jgit.transport.DaemonService; | ||||
@Command(common = true, usage = "Export repositories over git://") | |||||
@Command(common = true, usage = "usage_exportRepositoriesOverGit") | |||||
class Daemon extends TextBuiltin { | 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; | 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; | 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; | 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>(); | 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>(); | 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>(); | 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>(); | 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; | 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>(); | final List<File> directory = new ArrayList<File>(); | ||||
@Override | @Override | ||||
service(d, n).setOverridable(false); | service(d, n).setOverridable(false); | ||||
for (final File f : directory) { | for (final File f : directory) { | ||||
out.println("Exporting " + f.getAbsolutePath()); | |||||
out.println(MessageFormat.format(CLIText.get().exporting, f.getAbsolutePath())); | |||||
d.exportDirectory(f); | d.exportDirectory(f); | ||||
} | } | ||||
d.start(); | 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, | private DaemonService service(final org.eclipse.jgit.transport.Daemon d, | ||||
final String n) { | final String n) { | ||||
final DaemonService svc = d.getService(n); | final DaemonService svc = d.getService(n); | ||||
if (svc == null) | if (svc == null) | ||||
throw die("Service '" + n + "' not supported"); | |||||
throw die(MessageFormat.format(CLIText.get().serviceNotSupported, n)); | |||||
return svc; | return svc; | ||||
} | } | ||||
} | |||||
} |
import org.eclipse.jgit.treewalk.filter.AndTreeFilter; | import org.eclipse.jgit.treewalk.filter.AndTreeFilter; | ||||
import org.eclipse.jgit.treewalk.filter.TreeFilter; | import org.eclipse.jgit.treewalk.filter.TreeFilter; | ||||
@Command(common = true, usage = "Show diffs") | |||||
@Command(common = true, usage = "usage_ShowDiffs") | |||||
class Diff extends TextBuiltin { | 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) { | void tree_0(final AbstractTreeIterator c) { | ||||
trees.add(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>(); | 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 TreeFilter pathFilter = TreeFilter.ALL; | ||||
private DiffFormatter fmt = new DiffFormatter(); | private DiffFormatter fmt = new DiffFormatter(); |
import org.eclipse.jgit.treewalk.filter.TreeFilter; | import org.eclipse.jgit.treewalk.filter.TreeFilter; | ||||
class DiffTree extends TextBuiltin { | class DiffTree extends TextBuiltin { | ||||
@Option(name = "--recursive", usage = "recurse into subtrees", aliases = { "-r" }) | |||||
@Option(name = "--recursive", usage = "usage_recurseIntoSubtrees", aliases = { "-r" }) | |||||
private boolean recursive; | 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) { | void tree_0(final AbstractTreeIterator c) { | ||||
trees.add(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>(); | 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; | private TreeFilter pathFilter = TreeFilter.ALL; | ||||
@Override | @Override |
import org.eclipse.jgit.transport.RefSpec; | import org.eclipse.jgit.transport.RefSpec; | ||||
import org.eclipse.jgit.transport.Transport; | 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 { | 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; | int timeout = -1; | ||||
@Option(name = "--fsck", usage = "perform fsck style checks on receive") | |||||
@Option(name = "--fsck", usage = "usage_performFsckStyleChecksOnReceive") | |||||
private Boolean fsck; | private Boolean fsck; | ||||
@Option(name = "--no-fsck") | @Option(name = "--no-fsck") | ||||
fsck = Boolean.FALSE; | fsck = Boolean.FALSE; | ||||
} | } | ||||
@Option(name = "--prune", usage = "prune stale tracking refs") | |||||
@Option(name = "--prune", usage = "usage_pruneStaleTrackingRefs") | |||||
private Boolean prune; | private Boolean prune; | ||||
@Option(name = "--dry-run") | @Option(name = "--dry-run") | ||||
private boolean dryRun; | private boolean dryRun; | ||||
@Option(name = "--thin", usage = "fetch thin pack") | |||||
@Option(name = "--thin", usage = "usage_fetchThinPack") | |||||
private Boolean thin; | private Boolean thin; | ||||
@Option(name = "--no-thin") | @Option(name = "--no-thin") | ||||
thin = Boolean.FALSE; | thin = Boolean.FALSE; | ||||
} | } | ||||
@Argument(index = 0, metaVar = "uri-ish") | |||||
@Argument(index = 0, metaVar = "metaVar_uriish") | |||||
private String remote = Constants.DEFAULT_REMOTE_NAME; | private String remote = Constants.DEFAULT_REMOTE_NAME; | ||||
@Argument(index = 1, metaVar = "refspec") | |||||
@Argument(index = 1, metaVar = "metaVar_refspec") | |||||
private List<RefSpec> toget; | private List<RefSpec> toget; | ||||
@Override | @Override |
final JPanel buttons = new JPanel(new FlowLayout()); | final JPanel buttons = new JPanel(new FlowLayout()); | ||||
final JButton repaint = new JButton(); | final JButton repaint = new JButton(); | ||||
repaint.setText("Repaint"); | |||||
repaint.setText(CLIText.get().repaint); | |||||
repaint.addActionListener(new ActionListener() { | repaint.addActionListener(new ActionListener() { | ||||
public void actionPerformed(ActionEvent e) { | public void actionPerformed(ActionEvent e) { | ||||
graphPane.repaint(); | graphPane.repaint(); | ||||
@Override | @Override | ||||
protected RevWalk createWalk() { | protected RevWalk createWalk() { | ||||
if (objects) | if (objects) | ||||
throw die("Cannot use --objects with glog"); | |||||
throw die(CLIText.get().cannotUseObjectsWithGlog); | |||||
final PlotWalk w = new PlotWalk(db); | final PlotWalk w = new PlotWalk(db); | ||||
w.sort(RevSort.BOUNDARY, true); | w.sort(RevSort.BOUNDARY, true); | ||||
return w; | return w; |
import org.eclipse.jgit.lib.TextProgressMonitor; | import org.eclipse.jgit.lib.TextProgressMonitor; | ||||
class IndexPack extends TextBuiltin { | 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; | private boolean fixThin; | ||||
@Option(name = "--index-version", usage = "index file format to create") | |||||
@Option(name = "--index-version", usage = "usage_indexFileFormatToCreate") | |||||
private int indexVersion = -1; | private int indexVersion = -1; | ||||
@Argument(index = 0, required = true, metaVar = "base") | |||||
@Argument(index = 0, required = true, metaVar = "metaVar_base") | |||||
private File base; | private File base; | ||||
@Override | @Override |
package org.eclipse.jgit.pgm; | package org.eclipse.jgit.pgm; | ||||
import java.io.File; | import java.io.File; | ||||
import java.text.MessageFormat; | |||||
import org.kohsuke.args4j.Option; | import org.kohsuke.args4j.Option; | ||||
import org.eclipse.jgit.lib.Constants; | import org.eclipse.jgit.lib.Constants; | ||||
import org.eclipse.jgit.lib.Repository; | 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 { | class Init extends TextBuiltin { | ||||
@Option(name = "--bare", usage = "Create a bare repository") | |||||
@Option(name = "--bare", usage = "usage_CreateABareRepository") | |||||
private boolean bare; | private boolean bare; | ||||
@Override | @Override | ||||
gitdir = new File(bare ? "." : Constants.DOT_GIT); | gitdir = new File(bare ? "." : Constants.DOT_GIT); | ||||
db = new Repository(gitdir); | db = new Repository(gitdir); | ||||
db.create(bare); | db.create(bare); | ||||
out.println("Initialized empty Git repository in " | |||||
+ gitdir.getAbsolutePath()); | |||||
out.println(MessageFormat.format(CLIText.get().initializedEmptyGitRepositoryIn, gitdir.getAbsolutePath())); | |||||
} | } | ||||
} | } |
package org.eclipse.jgit.pgm; | package org.eclipse.jgit.pgm; | ||||
import java.text.DateFormat; | import java.text.DateFormat; | ||||
import java.text.MessageFormat; | |||||
import java.text.SimpleDateFormat; | import java.text.SimpleDateFormat; | ||||
import java.util.Collection; | import java.util.Collection; | ||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import org.eclipse.jgit.revwalk.RevCommit; | import org.eclipse.jgit.revwalk.RevCommit; | ||||
import org.eclipse.jgit.revwalk.RevWalk; | import org.eclipse.jgit.revwalk.RevWalk; | ||||
@Command(common = true, usage = "View commit history") | |||||
@Command(common = true, usage = "usage_viewCommitHistory") | |||||
class Log extends RevWalkTextBuiltin { | class Log extends RevWalkTextBuiltin { | ||||
private final TimeZone myTZ = TimeZone.getDefault(); | private final TimeZone myTZ = TimeZone.getDefault(); | ||||
private Map<AnyObjectId, Set<Ref>> allRefsByPeeledObjectId; | private Map<AnyObjectId, Set<Ref>> allRefsByPeeledObjectId; | ||||
@Option(name="--decorate", usage="Show ref names matching commits") | |||||
@Option(name="--decorate", usage="usage_showRefNamesMatchingCommits") | |||||
private boolean decorate; | private boolean decorate; | ||||
Log() { | Log() { | ||||
@Override | @Override | ||||
protected void show(final RevCommit c) throws Exception { | protected void show(final RevCommit c) throws Exception { | ||||
out.print("commit "); | |||||
out.print(CLIText.get().commitLabel); | |||||
out.print(" "); | |||||
c.getId().copyTo(outbuffer, out); | c.getId().copyTo(outbuffer, out); | ||||
if (decorate) { | if (decorate) { | ||||
Collection<Ref> list = allRefsByPeeledObjectId.get(c.copy()); | Collection<Ref> list = allRefsByPeeledObjectId.get(c.copy()); | ||||
out.println(); | out.println(); | ||||
final PersonIdent author = c.getAuthorIdent(); | 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(); | final TimeZone authorTZ = author.getTimeZone(); | ||||
fmt.setTimeZone(authorTZ != null ? authorTZ : myTZ); | 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(); | out.println(); | ||||
final String[] lines = c.getFullMessage().split("\n"); | final String[] lines = c.getFullMessage().split("\n"); |
import org.eclipse.jgit.transport.Transport; | import org.eclipse.jgit.transport.Transport; | ||||
class LsRemote extends TextBuiltin { | 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; | int timeout = -1; | ||||
@Argument(index = 0, metaVar = "uri-ish", required = true) | |||||
@Argument(index = 0, metaVar = "metaVar_uriish", required = true) | |||||
private String remote; | private String remote; | ||||
@Override | @Override |
import org.eclipse.jgit.treewalk.TreeWalk; | import org.eclipse.jgit.treewalk.TreeWalk; | ||||
class LsTree extends TextBuiltin { | class LsTree extends TextBuiltin { | ||||
@Option(name = "--recursive", usage = "recurse into subtrees", aliases = { "-r" }) | |||||
@Option(name = "--recursive", usage = "usage_recurseIntoSubtrees", aliases = { "-r" }) | |||||
private boolean recursive; | private boolean recursive; | ||||
@Argument(index = 0, required = true, metaVar = "tree-ish") | |||||
@Argument(index = 0, required = true, metaVar = "metaVar_treeish") | |||||
private AbstractTreeIterator tree; | private AbstractTreeIterator tree; | ||||
@Override | @Override |
package org.eclipse.jgit.pgm; | package org.eclipse.jgit.pgm; | ||||
import java.io.File; | import java.io.File; | ||||
import java.io.PrintWriter; | |||||
import java.lang.reflect.InvocationTargetException; | import java.lang.reflect.InvocationTargetException; | ||||
import java.net.MalformedURLException; | import java.net.MalformedURLException; | ||||
import java.net.URL; | import java.net.URL; | ||||
import java.text.MessageFormat; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Arrays; | import java.util.Arrays; | ||||
import java.util.HashSet; | import java.util.HashSet; | ||||
/** Command line entry point. */ | /** Command line entry point. */ | ||||
public class Main { | public class Main { | ||||
@Option(name = "--help", usage = "display this help text", aliases = { "-h" }) | |||||
@Option(name = "--help", usage = "usage_displayThisHelpText", aliases = { "-h" }) | |||||
private boolean help; | 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; | 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; | 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; | private TextBuiltin subcommand; | ||||
@Argument(index = 1, metaVar = "ARG") | |||||
@Argument(index = 1, metaVar = "metaVar_arg") | |||||
private List<String> arguments = new ArrayList<String>(); | private List<String> arguments = new ArrayList<String>(); | ||||
/** | /** | ||||
configureHttpProxy(); | configureHttpProxy(); | ||||
me.execute(argv); | me.execute(argv); | ||||
} catch (Die err) { | } catch (Die err) { | ||||
System.err.println("fatal: " + err.getMessage()); | |||||
System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage())); | |||||
if (me.showStackTrace) | if (me.showStackTrace) | ||||
err.printStackTrace(); | err.printStackTrace(); | ||||
System.exit(128); | System.exit(128); | ||||
} catch (Exception err) { | } catch (Exception err) { | ||||
if (!me.showStackTrace && err.getCause() != null | if (!me.showStackTrace && err.getCause() != null | ||||
&& err instanceof TransportException) | && 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.")) { | 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) | if (me.showStackTrace) | ||||
err.printStackTrace(); | err.printStackTrace(); | ||||
System.exit(128); | System.exit(128); | ||||
private void execute(final String[] argv) throws Exception { | private void execute(final String[] argv) throws Exception { | ||||
final CmdLineParser clp = new CmdLineParser(this); | final CmdLineParser clp = new CmdLineParser(this); | ||||
PrintWriter writer = new PrintWriter(System.err); | |||||
try { | try { | ||||
clp.parseArgument(argv); | clp.parseArgument(argv); | ||||
} catch (CmdLineException err) { | } catch (CmdLineException err) { | ||||
if (argv.length > 0 && !help) { | 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); | System.exit(1); | ||||
} | } | ||||
} | } | ||||
if (argv.length == 0 || help) { | 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) { | 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) { | } 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(); | final CommandRef[] common = CommandCatalog.common(); | ||||
int width = 0; | int width = 0; | ||||
for (final CommandRef c : common) | for (final CommandRef c : common) | ||||
width += 2; | width += 2; | ||||
for (final CommandRef c : common) { | 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++) | 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); | System.exit(1); | ||||
} | } | ||||
altobjectdirs = null; | altobjectdirs = null; | ||||
if (gitdir == null || !gitdir.isDirectory()) { | if (gitdir == null || !gitdir.isDirectory()) { | ||||
System.err.println("error: can't find git directory"); | |||||
writer.println(CLIText.get().cantFindGitDirectory); | |||||
writer.flush(); | |||||
System.exit(1); | System.exit(1); | ||||
} | } | ||||
cmd.init(new Repository(gitdir, gitworktree, objectdir, altobjectdirs, indexfile), gitdir); | cmd.init(new Repository(gitdir, gitworktree, objectdir, altobjectdirs, indexfile), gitdir); | ||||
return false; | return false; | ||||
} catch (IllegalArgumentException e) { | } catch (IllegalArgumentException e) { | ||||
throw new RuntimeException("Cannot setup console", e); | |||||
throw new RuntimeException(CLIText.get().cannotSetupConsole, e); | |||||
} catch (SecurityException e) { | } catch (SecurityException e) { | ||||
throw new RuntimeException("Cannot setup console", e); | |||||
throw new RuntimeException(CLIText.get().cannotSetupConsole, e); | |||||
} catch (IllegalAccessException e) { | } catch (IllegalAccessException e) { | ||||
throw new RuntimeException("Cannot setup console", e); | |||||
throw new RuntimeException(CLIText.get().cannotSetupConsole, e); | |||||
} catch (InvocationTargetException e) { | } catch (InvocationTargetException e) { | ||||
throw new RuntimeException("Cannot setup console", e); | |||||
throw new RuntimeException(CLIText.get().cannotSetupConsole, e); | |||||
} catch (NoSuchMethodException e) { | } catch (NoSuchMethodException e) { | ||||
throw new RuntimeException("Cannot setup console", e); | |||||
throw new RuntimeException(CLIText.get().cannotSetupConsole, e); | |||||
} | } | ||||
} | } | ||||
final URL u = new URL((s.indexOf("://") == -1) ? "http://" + s : s); | final URL u = new URL((s.indexOf("://") == -1) ? "http://" + s : s); | ||||
if (!"http".equals(u.getProtocol())) | 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 String proxyHost = u.getHost(); | ||||
final int proxyPort = u.getPort(); | final int proxyPort = u.getPort(); |
import org.eclipse.jgit.revwalk.filter.RevFilter; | import org.eclipse.jgit.revwalk.filter.RevFilter; | ||||
class MergeBase extends TextBuiltin { | class MergeBase extends TextBuiltin { | ||||
@Option(name = "--all", usage = "display all possible merge bases") | |||||
@Option(name = "--all", usage = "usage_displayAllPossibleMergeBases") | |||||
private boolean all; | 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) { | void commit_0(final RevCommit c) { | ||||
commits.add(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>(); | private final List<RevCommit> commits = new ArrayList<RevCommit>(); | ||||
@Override | @Override |
package org.eclipse.jgit.pgm; | package org.eclipse.jgit.pgm; | ||||
import java.text.MessageFormat; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Collection; | import java.util.Collection; | ||||
import java.util.List; | import java.util.List; | ||||
import org.eclipse.jgit.transport.URIish; | import org.eclipse.jgit.transport.URIish; | ||||
import org.eclipse.jgit.transport.RemoteRefUpdate.Status; | 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 { | 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; | int timeout = -1; | ||||
@Argument(index = 0, metaVar = "uri-ish") | |||||
@Argument(index = 0, metaVar = "metaVar_uriish") | |||||
private String remote = Constants.DEFAULT_REMOTE_NAME; | 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>(); | private final List<RefSpec> refSpecs = new ArrayList<RefSpec>(); | ||||
@Option(name = "--all") | @Option(name = "--all") | ||||
@Option(name = "--force", aliases = { "-f" }) | @Option(name = "--force", aliases = { "-f" }) | ||||
private boolean force; | private boolean force; | ||||
@Option(name = "--receive-pack", metaVar = "path") | |||||
@Option(name = "--receive-pack", metaVar = "metaVar_path") | |||||
private String receivePack; | private String receivePack; | ||||
@Option(name = "--dry-run") | @Option(name = "--dry-run") | ||||
AbstractFetchCommand.showRemoteMessages(result.getMessages()); | AbstractFetchCommand.showRemoteMessages(result.getMessages()); | ||||
if (everythingUpToDate) | if (everythingUpToDate) | ||||
out.println("Everything up-to-date"); | |||||
out.println(CLIText.get().everythingUpToDate); | |||||
} | } | ||||
private void printRefUpdateResult(final URIish uri, | private void printRefUpdateResult(final URIish uri, | ||||
final PushResult result, final RemoteRefUpdate rru) { | final PushResult result, final RemoteRefUpdate rru) { | ||||
if (!shownURI) { | if (!shownURI) { | ||||
shownURI = true; | shownURI = true; | ||||
out.format("To %s\n", uri); | |||||
out.println(MessageFormat.format(CLIText.get().pushTo, uri)); | |||||
} | } | ||||
final String remoteName = rru.getRemoteName(); | final String remoteName = rru.getRemoteName(); | ||||
.name() | .name() | ||||
+ (fastForward ? ".." : "...") | + (fastForward ? ".." : "...") | ||||
+ rru.getNewObjectId().abbreviate(db).name(); | + 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); | printUpdateLine(flag, summary, srcRef, remoteName, message); | ||||
} | } | ||||
} | } | ||||
case REJECTED_NODELETE: | case REJECTED_NODELETE: | ||||
printUpdateLine('!', "[rejected]", null, remoteName, | printUpdateLine('!', "[rejected]", null, remoteName, | ||||
"remote side does not support deleting refs"); | |||||
CLIText.get().remoteSideDoesNotSupportDeletingRefs); | |||||
break; | break; | ||||
case REJECTED_NONFASTFORWARD: | case REJECTED_NONFASTFORWARD: | ||||
printUpdateLine('!', "[rejected]", srcRef, remoteName, | printUpdateLine('!', "[rejected]", srcRef, remoteName, | ||||
"non-fast forward"); | |||||
CLIText.get().nonFastForward); | |||||
break; | break; | ||||
case REJECTED_REMOTE_CHANGED: | 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); | printUpdateLine('!', "[rejected]", srcRef, remoteName, message); | ||||
break; | break; | ||||
package org.eclipse.jgit.pgm; | package org.eclipse.jgit.pgm; | ||||
import java.io.File; | import java.io.File; | ||||
import java.text.MessageFormat; | |||||
import org.kohsuke.args4j.Argument; | import org.kohsuke.args4j.Argument; | ||||
import org.eclipse.jgit.lib.Constants; | import org.eclipse.jgit.lib.Constants; | ||||
import org.eclipse.jgit.lib.Repository; | 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 { | 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; | File dstGitdir; | ||||
@Override | @Override | ||||
dstGitdir = new File(dstGitdir, Constants.DOT_GIT); | dstGitdir = new File(dstGitdir, Constants.DOT_GIT); | ||||
db = new Repository(dstGitdir); | db = new Repository(dstGitdir); | ||||
if (!db.getObjectsDirectory().isDirectory()) | 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 = new org.eclipse.jgit.transport.ReceivePack(db); | ||||
rp.receive(System.in, System.out, System.err); | rp.receive(System.in, System.out, System.err); | ||||
} | } |
package org.eclipse.jgit.pgm; | package org.eclipse.jgit.pgm; | ||||
import java.text.MessageFormat; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.EnumSet; | import java.util.EnumSet; | ||||
import java.util.List; | import java.util.List; | ||||
enableRevSort(RevSort.BOUNDARY, on); | enableRevSort(RevSort.BOUNDARY, on); | ||||
} | } | ||||
@Argument(index = 0, metaVar = "commit-ish") | |||||
@Argument(index = 0, metaVar = "metaVar_commitish") | |||||
private final List<RevCommit> commits = new ArrayList<RevCommit>(); | 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 TreeFilter pathFilter = TreeFilter.ALL; | ||||
private final List<RevFilter> revLimiter = new ArrayList<RevFilter>(); | private final List<RevFilter> revLimiter = new ArrayList<RevFilter>(); | ||||
if (commits.isEmpty()) { | if (commits.isEmpty()) { | ||||
final ObjectId head = db.resolve(Constants.HEAD); | final ObjectId head = db.resolve(Constants.HEAD); | ||||
if (head == null) | if (head == null) | ||||
throw die("Cannot resolve " + Constants.HEAD); | |||||
throw die(MessageFormat.format(CLIText.get().cannotResolve, Constants.HEAD)); | |||||
commits.add(walk.parseCommit(head)); | commits.add(walk.parseCommit(head)); | ||||
} | } | ||||
for (final RevCommit c : commits) { | for (final RevCommit c : commits) { | ||||
final long end = System.currentTimeMillis(); | final long end = System.currentTimeMillis(); | ||||
System.err.print(n); | System.err.print(n); | ||||
System.err.print(' '); | 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)); | |||||
} | } | ||||
} | } | ||||
import org.eclipse.jgit.treewalk.TreeWalk; | import org.eclipse.jgit.treewalk.TreeWalk; | ||||
import org.eclipse.jgit.treewalk.filter.TreeFilter; | 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 { | 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) | @Option(name = "--", handler = StopOptionHandler.class) | ||||
private TreeFilter paths; | private TreeFilter paths; | ||||
package org.eclipse.jgit.pgm; | package org.eclipse.jgit.pgm; | ||||
import java.text.MessageFormat; | |||||
import org.kohsuke.args4j.Argument; | import org.kohsuke.args4j.Argument; | ||||
import org.kohsuke.args4j.Option; | import org.kohsuke.args4j.Option; | ||||
import org.eclipse.jgit.errors.MissingObjectException; | import org.eclipse.jgit.errors.MissingObjectException; | ||||
import org.eclipse.jgit.lib.ObjectLoader; | import org.eclipse.jgit.lib.ObjectLoader; | ||||
import org.eclipse.jgit.lib.PersonIdent; | import org.eclipse.jgit.lib.PersonIdent; | ||||
@Command(common = true, usage = "Create a tag") | |||||
@Command(common = true, usage = "usage_CreateATag") | |||||
class Tag extends TextBuiltin { | class Tag extends TextBuiltin { | ||||
@Option(name = "-f", usage = "force replacing an existing tag") | |||||
@Option(name = "-f", usage = "usage_forceReplacingAnExistingTag") | |||||
private boolean force; | private boolean force; | ||||
@Option(name = "-m", metaVar = "message", usage = "tag message") | |||||
@Option(name = "-m", metaVar = "metaVar_message", usage = "usage_tagMessage") | |||||
private String message = ""; | private String message = ""; | ||||
@Argument(index = 0, required = true, metaVar = "name") | |||||
@Argument(index = 0, required = true, metaVar = "metaVar_name") | |||||
private String tagName; | private String tagName; | ||||
@Argument(index = 1, metaVar = "object") | |||||
@Argument(index = 1, metaVar = "metaVar_object") | |||||
private ObjectId object; | private ObjectId object; | ||||
@Override | @Override | ||||
if (object == null) { | if (object == null) { | ||||
object = db.resolve(Constants.HEAD); | object = db.resolve(Constants.HEAD); | ||||
if (object == null) | if (object == null) | ||||
throw die("Cannot resolve " + Constants.HEAD); | |||||
throw die(MessageFormat.format(CLIText.get().cannotResolve, Constants.HEAD)); | |||||
} | } | ||||
if (!tagName.startsWith(Constants.R_TAGS)) | if (!tagName.startsWith(Constants.R_TAGS)) | ||||
tagName = Constants.R_TAGS + tagName; | tagName = Constants.R_TAGS + tagName; | ||||
if (!force && db.resolve(tagName) != null) { | 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); | final ObjectLoader ldr = db.openObject(object); |
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.OutputStreamWriter; | import java.io.OutputStreamWriter; | ||||
import java.io.PrintWriter; | import java.io.PrintWriter; | ||||
import java.text.MessageFormat; | |||||
import java.util.ResourceBundle; | |||||
import org.kohsuke.args4j.CmdLineException; | import org.kohsuke.args4j.CmdLineException; | ||||
import org.kohsuke.args4j.Option; | import org.kohsuke.args4j.Option; | ||||
public abstract class TextBuiltin { | public abstract class TextBuiltin { | ||||
private String commandName; | private String commandName; | ||||
@Option(name = "--help", usage = "display this help text", aliases = { "-h" }) | |||||
@Option(name = "--help", usage = "usage_displayThisHelpText", aliases = { "-h" }) | |||||
private boolean help; | private boolean help; | ||||
/** Stream to output to, typically this is standard output. */ | /** Stream to output to, typically this is standard output. */ | ||||
out = new PrintWriter(new BufferedWriter( | out = new PrintWriter(new BufferedWriter( | ||||
new OutputStreamWriter(System.out))); | new OutputStreamWriter(System.out))); | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
throw die("cannot create output stream"); | |||||
throw die(CLIText.get().cannotCreateOutputStream); | |||||
} | } | ||||
if (repo != null) { | if (repo != null) { | ||||
clp.parseArgument(args); | clp.parseArgument(args); | ||||
} catch (CmdLineException err) { | } catch (CmdLineException err) { | ||||
if (!help) { | if (!help) { | ||||
System.err.println("fatal: " + err.getMessage()); | |||||
System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage())); | |||||
System.exit(1); | System.exit(1); | ||||
} | } | ||||
} | } | ||||
* @param clp | * @param clp | ||||
*/ | */ | ||||
public void printUsageAndExit(final String message, final CmdLineParser 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); | 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. | * Perform the actions of this command. | ||||
* <p> | * <p> | ||||
ObjectId resolve(final String s) throws IOException { | ObjectId resolve(final String s) throws IOException { | ||||
final ObjectId r = db.resolve(s); | final ObjectId r = db.resolve(s); | ||||
if (r == null) | if (r == null) | ||||
throw die("Not a revision: " + s); | |||||
throw die(MessageFormat.format(CLIText.get().notARevision, s)); | |||||
return r; | return r; | ||||
} | } | ||||
package org.eclipse.jgit.pgm; | package org.eclipse.jgit.pgm; | ||||
import java.io.File; | import java.io.File; | ||||
import java.text.MessageFormat; | |||||
import org.kohsuke.args4j.Argument; | import org.kohsuke.args4j.Argument; | ||||
import org.kohsuke.args4j.Option; | import org.kohsuke.args4j.Option; | ||||
import org.eclipse.jgit.lib.Constants; | import org.eclipse.jgit.lib.Constants; | ||||
import org.eclipse.jgit.lib.Repository; | 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 { | 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; | 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; | File srcGitdir; | ||||
@Override | @Override | ||||
srcGitdir = new File(srcGitdir, Constants.DOT_GIT); | srcGitdir = new File(srcGitdir, Constants.DOT_GIT); | ||||
db = new Repository(srcGitdir); | db = new Repository(srcGitdir); | ||||
if (!db.getObjectsDirectory().isDirectory()) | 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); | rp = new org.eclipse.jgit.transport.UploadPack(db); | ||||
if (0 <= timeout) | if (0 <= timeout) | ||||
rp.setTimeout(timeout); | rp.setTimeout(timeout); |
package org.eclipse.jgit.pgm; | 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 { | class Version extends TextBuiltin { | ||||
@Override | @Override | ||||
protected void run() throws Exception { | protected void run() throws Exception { | ||||
final Package pkg = getClass().getPackage(); | final Package pkg = getClass().getPackage(); | ||||
if (pkg == null || pkg.getImplementationVersion() == null) | 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())); | |||||
} | } | ||||
} | } |
package org.eclipse.jgit.pgm.debug; | package org.eclipse.jgit.pgm.debug; | ||||
import java.text.MessageFormat; | |||||
import org.eclipse.jgit.dircache.DirCache; | import org.eclipse.jgit.dircache.DirCache; | ||||
import org.eclipse.jgit.dircache.DirCacheTree; | import org.eclipse.jgit.dircache.DirCacheTree; | ||||
import org.eclipse.jgit.pgm.CLIText; | |||||
import org.eclipse.jgit.pgm.TextBuiltin; | import org.eclipse.jgit.pgm.TextBuiltin; | ||||
class MakeCacheTree extends TextBuiltin { | class MakeCacheTree extends TextBuiltin { | ||||
} | } | ||||
private void show(final DirCacheTree 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++) | for (int i = 0; i < tree.getChildCount(); i++) | ||||
show(tree.getChild(i)); | show(tree.getChild(i)); |
package org.eclipse.jgit.pgm.debug; | package org.eclipse.jgit.pgm.debug; | ||||
import java.text.MessageFormat; | |||||
import org.eclipse.jgit.dircache.DirCache; | import org.eclipse.jgit.dircache.DirCache; | ||||
import org.eclipse.jgit.pgm.CLIText; | |||||
import org.eclipse.jgit.pgm.TextBuiltin; | import org.eclipse.jgit.pgm.TextBuiltin; | ||||
class ReadDirCache extends TextBuiltin { | class ReadDirCache extends TextBuiltin { | ||||
for (int i = 0; i < cnt; i++) | for (int i = 0; i < cnt; i++) | ||||
DirCache.read(db); | DirCache.read(db); | ||||
final long end = System.currentTimeMillis(); | 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)); | |||||
} | } | ||||
} | } |
import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.InputStreamReader; | import java.io.InputStreamReader; | ||||
import java.text.MessageFormat; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Date; | import java.util.Date; | ||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import org.eclipse.jgit.lib.RefWriter; | import org.eclipse.jgit.lib.RefWriter; | ||||
import org.eclipse.jgit.lib.TextProgressMonitor; | import org.eclipse.jgit.lib.TextProgressMonitor; | ||||
import org.eclipse.jgit.lib.Tree; | import org.eclipse.jgit.lib.Tree; | ||||
import org.eclipse.jgit.pgm.CLIText; | |||||
import org.eclipse.jgit.pgm.TextBuiltin; | import org.eclipse.jgit.pgm.TextBuiltin; | ||||
import org.eclipse.jgit.revwalk.RevWalk; | import org.eclipse.jgit.revwalk.RevWalk; | ||||
class RebuildCommitGraph extends TextBuiltin { | class RebuildCommitGraph extends TextBuiltin { | ||||
private final String REALLY = "--destroy-this-repository"; | private final String REALLY = "--destroy-this-repository"; | ||||
@Option(name = REALLY, usage = "approve destruction of repository") | |||||
@Option(name = REALLY, usage = "usage_approveDestructionOfRepository") | |||||
boolean really; | 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; | 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; | File graph; | ||||
private final ProgressMonitor pm = new TextProgressMonitor(); | private final ProgressMonitor pm = new TextProgressMonitor(); | ||||
@Override | @Override | ||||
protected void run() throws Exception { | protected void run() throws Exception { | ||||
if (!really && !db.getAllRefs().isEmpty()) { | 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()) | if (!refList.isFile()) | ||||
throw die("no such file: " + refList.getPath()); | |||||
throw die(MessageFormat.format(CLIText.get().noSuchFile, refList.getPath())); | |||||
if (!graph.isFile()) | if (!graph.isFile()) | ||||
throw die("no such file: " + graph.getPath()); | |||||
throw die(MessageFormat.format(CLIText.get().noSuchFile, graph.getPath())); | |||||
recreateCommitGraph(); | recreateCommitGraph(); | ||||
detachHead(); | detachHead(); | ||||
final LockFile lf; | final LockFile lf; | ||||
lf = new LockFile(new File(db.getDirectory(), Constants.HEAD)); | lf = new LockFile(new File(db.getDirectory(), Constants.HEAD)); | ||||
if (!lf.lock()) | if (!lf.lock()) | ||||
throw new IOException("Cannot lock HEAD"); | |||||
throw new IOException(MessageFormat.format(CLIText.get().cannotLock, Constants.HEAD)); | |||||
lf.write(id); | lf.write(id); | ||||
if (!lf.commit()) | if (!lf.commit()) | ||||
throw new IOException("Cannot deatch HEAD"); | |||||
throw new IOException(CLIText.get().cannotDeatchHEAD); | |||||
} | } | ||||
} | } | ||||
final File file = new File(db.getDirectory(), name); | final File file = new File(db.getDirectory(), name); | ||||
final LockFile lck = new LockFile(file); | final LockFile lck = new LockFile(file); | ||||
if (!lck.lock()) | if (!lck.lock()) | ||||
throw new ObjectWritingException("Can't write " + file); | |||||
throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite, file)); | |||||
try { | try { | ||||
lck.write(content); | lck.write(content); | ||||
} catch (IOException ioe) { | } catch (IOException ioe) { | ||||
throw new ObjectWritingException("Can't write " + file); | |||||
throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite, file)); | |||||
} | } | ||||
if (!lck.commit()) | if (!lck.commit()) | ||||
throw new ObjectWritingException("Can't write " + file); | |||||
throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite, file)); | |||||
} | } | ||||
}.writePackedRefs(); | }.writePackedRefs(); | ||||
} | } | ||||
rw.parseAny(id); | rw.parseAny(id); | ||||
} catch (MissingObjectException mue) { | } catch (MissingObjectException mue) { | ||||
if (!Constants.TYPE_COMMIT.equals(type)) { | if (!Constants.TYPE_COMMIT.equals(type)) { | ||||
System.err.println("skipping " + type + " " + name); | |||||
System.err.println(MessageFormat.format(CLIText.get().skippingObject, type, name)); | |||||
continue; | continue; | ||||
} | } | ||||
throw new MissingObjectException(id, type); | throw new MissingObjectException(id, type); |
package org.eclipse.jgit.pgm.debug; | package org.eclipse.jgit.pgm.debug; | ||||
import java.text.MessageFormat; | |||||
import org.eclipse.jgit.dircache.DirCache; | import org.eclipse.jgit.dircache.DirCache; | ||||
import org.eclipse.jgit.dircache.DirCacheTree; | import org.eclipse.jgit.dircache.DirCacheTree; | ||||
import org.eclipse.jgit.pgm.CLIText; | |||||
import org.eclipse.jgit.pgm.TextBuiltin; | import org.eclipse.jgit.pgm.TextBuiltin; | ||||
class ShowCacheTree extends TextBuiltin { | class ShowCacheTree extends TextBuiltin { | ||||
final DirCache cache = DirCache.read(db); | final DirCache cache = DirCache.read(db); | ||||
final DirCacheTree tree = cache.getCacheTree(false); | final DirCacheTree tree = cache.getCacheTree(false); | ||||
if (tree == null) | if (tree == null) | ||||
throw die("no 'TREE' section in index"); | |||||
throw die(CLIText.get().noTREESectionInIndex); | |||||
show(tree); | show(tree); | ||||
} | } | ||||
private void show(final DirCacheTree 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++) | for (int i = 0; i < tree.getChildCount(); i++) | ||||
show(tree.getChild(i)); | show(tree.getChild(i)); |
import java.net.URL; | import java.net.URL; | ||||
import org.kohsuke.args4j.Option; | import org.kohsuke.args4j.Option; | ||||
import org.eclipse.jgit.pgm.CLIText; | |||||
import org.eclipse.jgit.pgm.Command; | import org.eclipse.jgit.pgm.Command; | ||||
import org.eclipse.jgit.pgm.CommandCatalog; | import org.eclipse.jgit.pgm.CommandCatalog; | ||||
import org.eclipse.jgit.pgm.CommandRef; | import org.eclipse.jgit.pgm.CommandRef; | ||||
import org.eclipse.jgit.pgm.TextBuiltin; | import org.eclipse.jgit.pgm.TextBuiltin; | ||||
@Command(usage = "Display a list of all registered jgit commands") | |||||
@Command(usage = "usage_displayAListOfAllRegisteredJgitCommands") | |||||
class ShowCommands extends TextBuiltin { | class ShowCommands extends TextBuiltin { | ||||
@Option(name = "--pretty", usage = "alter the detail shown") | |||||
@Option(name = "--pretty", usage = "usage_alterTheDetailShown") | |||||
private Format pretty = Format.USAGE; | private Format pretty = Format.USAGE; | ||||
@Override | @Override | ||||
/** */ | /** */ | ||||
USAGE { | USAGE { | ||||
void print(final CommandRef c) { | 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)); | |||||
} | } | ||||
}, | }, | ||||
final URL url = ldr.getResource(cn); | final URL url = ldr.getResource(cn); | ||||
if (url == null) { | if (url == null) { | ||||
System.err.print("!! NOT FOUND !!"); | |||||
System.err.print(CLIText.get().notFound); | |||||
return; | return; | ||||
} | } | ||||
package org.eclipse.jgit.pgm.debug; | package org.eclipse.jgit.pgm.debug; | ||||
import org.eclipse.jgit.dircache.DirCache; | import org.eclipse.jgit.dircache.DirCache; | ||||
import org.eclipse.jgit.pgm.CLIText; | |||||
import org.eclipse.jgit.pgm.TextBuiltin; | import org.eclipse.jgit.pgm.TextBuiltin; | ||||
class WriteDirCache extends TextBuiltin { | class WriteDirCache extends TextBuiltin { | ||||
protected void run() throws Exception { | protected void run() throws Exception { | ||||
final DirCache cache = DirCache.read(db); | final DirCache cache = DirCache.read(db); | ||||
if (!cache.lock()) | if (!cache.lock()) | ||||
throw die("failed to lock index"); | |||||
throw die(CLIText.get().failedToLockIndex); | |||||
cache.read(); | cache.read(); | ||||
cache.write(); | cache.write(); | ||||
if (!cache.commit()) | if (!cache.commit()) | ||||
throw die("failed to commit index"); | |||||
throw die(CLIText.get().failedToCommitIndex); | |||||
} | } | ||||
} | } |
import java.io.File; | import java.io.File; | ||||
import java.io.OutputStream; | import java.io.OutputStream; | ||||
import java.net.CookieHandler; | import java.net.CookieHandler; | ||||
import java.text.MessageFormat; | |||||
import org.eclipse.jgit.iplog.IpLogGenerator; | import org.eclipse.jgit.iplog.IpLogGenerator; | ||||
import org.eclipse.jgit.iplog.SimpleCookieManager; | import org.eclipse.jgit.iplog.SimpleCookieManager; | ||||
import org.eclipse.jgit.lib.Constants; | import org.eclipse.jgit.lib.Constants; | ||||
import org.eclipse.jgit.lib.LockFile; | import org.eclipse.jgit.lib.LockFile; | ||||
import org.eclipse.jgit.lib.ObjectId; | import org.eclipse.jgit.lib.ObjectId; | ||||
import org.eclipse.jgit.pgm.CLIText; | |||||
import org.eclipse.jgit.pgm.Command; | import org.eclipse.jgit.pgm.Command; | ||||
import org.eclipse.jgit.pgm.TextBuiltin; | import org.eclipse.jgit.pgm.TextBuiltin; | ||||
import org.eclipse.jgit.revwalk.RevObject; | import org.eclipse.jgit.revwalk.RevObject; | ||||
import org.kohsuke.args4j.Argument; | import org.kohsuke.args4j.Argument; | ||||
import org.kohsuke.args4j.Option; | 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 { | 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; | 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; | private File output; | ||||
@Argument(index = 0, metaVar = "COMMIT|TAG") | |||||
@Argument(index = 0, metaVar = "metaVar_commitOrTag") | |||||
private ObjectId commitId; | private ObjectId commitId; | ||||
@Override | @Override | ||||
final IpLogGenerator log = new IpLogGenerator(); | final IpLogGenerator log = new IpLogGenerator(); | ||||
if (commitId == null) { | 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); | commitId = db.resolve(Constants.HEAD); | ||||
} | } | ||||
if (version == null && start instanceof RevTag) | if (version == null && start instanceof RevTag) | ||||
version = ((RevTag) start).getTagName(); | version = ((RevTag) start).getTagName(); | ||||
else if (version == null) | 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); | log.scan(db, rw.parseCommit(start), version); | ||||
output.getParentFile().mkdirs(); | output.getParentFile().mkdirs(); | ||||
LockFile lf = new LockFile(output); | LockFile lf = new LockFile(output); | ||||
if (!lf.lock()) | if (!lf.lock()) | ||||
throw die("Cannot lock " + output); | |||||
throw die(MessageFormat.format(CLIText.get().cannotLock, output)); | |||||
try { | try { | ||||
OutputStream os = lf.getOutputStream(); | OutputStream os = lf.getOutputStream(); | ||||
try { | try { | ||||
os.close(); | os.close(); | ||||
} | } | ||||
if (!lf.commit()) | if (!lf.commit()) | ||||
throw die("Cannot write " + output); | |||||
throw die(MessageFormat.format(CLIText.get().cannotWrite, output)); | |||||
} finally { | } finally { | ||||
lf.unlock(); | lf.unlock(); | ||||
} | } |
import org.eclipse.jgit.iplog.IpLogMeta; | import org.eclipse.jgit.iplog.IpLogMeta; | ||||
import org.eclipse.jgit.iplog.SimpleCookieManager; | import org.eclipse.jgit.iplog.SimpleCookieManager; | ||||
import org.eclipse.jgit.pgm.CLIText; | |||||
import org.eclipse.jgit.pgm.Command; | import org.eclipse.jgit.pgm.Command; | ||||
import org.eclipse.jgit.pgm.TextBuiltin; | import org.eclipse.jgit.pgm.TextBuiltin; | ||||
import org.kohsuke.args4j.Option; | 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 { | 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/"; | 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; | private String username; | ||||
@Option(name = "--password", metaVar = "PASS", usage = "IPZilla Password") | |||||
@Option(name = "--password", metaVar = "metaVar_pass", usage = "usage_IPZillaPassword") | |||||
private String password; | 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; | private File output; | ||||
@Override | @Override | ||||
null, // | null, // | ||||
ipzilla.getPort(), // | ipzilla.getPort(), // | ||||
ipzilla.getProtocol(), // | ipzilla.getProtocol(), // | ||||
"IPZilla Password", // | |||||
CLIText.get().IPZillaPasswordPrompt, // | |||||
ipzilla.getProtocol(), // | ipzilla.getProtocol(), // | ||||
ipzilla, // | ipzilla, // | ||||
Authenticator.RequestorType.SERVER); | Authenticator.RequestorType.SERVER); |
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.text.MessageFormat; | |||||
import org.kohsuke.args4j.CmdLineException; | import org.kohsuke.args4j.CmdLineException; | ||||
import org.kohsuke.args4j.CmdLineParser; | import org.kohsuke.args4j.CmdLineParser; | ||||
import org.eclipse.jgit.errors.MissingObjectException; | import org.eclipse.jgit.errors.MissingObjectException; | ||||
import org.eclipse.jgit.lib.ObjectId; | import org.eclipse.jgit.lib.ObjectId; | ||||
import org.eclipse.jgit.lib.WindowCursor; | import org.eclipse.jgit.lib.WindowCursor; | ||||
import org.eclipse.jgit.pgm.CLIText; | |||||
import org.eclipse.jgit.treewalk.AbstractTreeIterator; | import org.eclipse.jgit.treewalk.AbstractTreeIterator; | ||||
import org.eclipse.jgit.treewalk.CanonicalTreeParser; | import org.eclipse.jgit.treewalk.CanonicalTreeParser; | ||||
import org.eclipse.jgit.treewalk.FileTreeIterator; | import org.eclipse.jgit.treewalk.FileTreeIterator; | ||||
try { | try { | ||||
dirc = DirCache.read(new File(name)); | dirc = DirCache.read(new File(name)); | ||||
} catch (IOException e) { | } 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)); | setter.addValue(new DirCacheIterator(dirc)); | ||||
return 1; | return 1; | ||||
throw new CmdLineException(e.getMessage()); | throw new CmdLineException(e.getMessage()); | ||||
} | } | ||||
if (id == null) | 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 CanonicalTreeParser p = new CanonicalTreeParser(); | ||||
final WindowCursor curs = new WindowCursor(); | final WindowCursor curs = new WindowCursor(); | ||||
try { | try { | ||||
p.reset(clp.getRepository(), clp.getRevWalk().parseTree(id), curs); | p.reset(clp.getRepository(), clp.getRevWalk().parseTree(id), curs); | ||||
} catch (MissingObjectException e) { | } catch (MissingObjectException e) { | ||||
throw new CmdLineException(name + " is not a tree"); | |||||
throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); | |||||
} catch (IncorrectObjectTypeException e) { | } catch (IncorrectObjectTypeException e) { | ||||
throw new CmdLineException(name + " is not a tree"); | |||||
throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); | |||||
} catch (IOException e) { | } catch (IOException e) { | ||||
throw new CmdLineException("cannot read " + name + ": " | |||||
+ e.getMessage()); | |||||
throw new CmdLineException(MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage())); | |||||
} finally { | } finally { | ||||
curs.release(); | curs.release(); | ||||
} | } | ||||
@Override | @Override | ||||
public String getDefaultMetaVariable() { | public String getDefaultMetaVariable() { | ||||
return "tree-ish"; | |||||
return CLIText.get().metaVar_treeish; | |||||
} | } | ||||
} | } |
import org.kohsuke.args4j.Option; | import org.kohsuke.args4j.Option; | ||||
import org.eclipse.jgit.lib.ObjectId; | import org.eclipse.jgit.lib.ObjectId; | ||||
import org.eclipse.jgit.lib.Repository; | import org.eclipse.jgit.lib.Repository; | ||||
import org.eclipse.jgit.pgm.CLIText; | |||||
import org.eclipse.jgit.pgm.TextBuiltin; | import org.eclipse.jgit.pgm.TextBuiltin; | ||||
import org.eclipse.jgit.revwalk.RevCommit; | import org.eclipse.jgit.revwalk.RevCommit; | ||||
import org.eclipse.jgit.revwalk.RevTree; | import org.eclipse.jgit.revwalk.RevTree; | ||||
*/ | */ | ||||
public Repository getRepository() { | public Repository getRepository() { | ||||
if (db == null) | if (db == null) | ||||
throw new IllegalStateException("No Git repository configured."); | |||||
throw new IllegalStateException(CLIText.get().noGitRepositoryConfigured); | |||||
return db; | return db; | ||||
} | } | ||||
package org.eclipse.jgit.pgm.opt; | package org.eclipse.jgit.pgm.opt; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.text.MessageFormat; | |||||
import org.kohsuke.args4j.CmdLineException; | import org.kohsuke.args4j.CmdLineException; | ||||
import org.kohsuke.args4j.CmdLineParser; | import org.kohsuke.args4j.CmdLineParser; | ||||
import org.kohsuke.args4j.spi.Parameters; | import org.kohsuke.args4j.spi.Parameters; | ||||
import org.kohsuke.args4j.spi.Setter; | import org.kohsuke.args4j.spi.Setter; | ||||
import org.eclipse.jgit.lib.ObjectId; | import org.eclipse.jgit.lib.ObjectId; | ||||
import org.eclipse.jgit.pgm.CLIText; | |||||
/** | /** | ||||
* Custom argument handler {@link ObjectId} from string values. | * Custom argument handler {@link ObjectId} from string values. | ||||
return 1; | return 1; | ||||
} | } | ||||
throw new CmdLineException(name + " is not an object"); | |||||
throw new CmdLineException(MessageFormat.format(CLIText.get().notAnObject, name)); | |||||
} | } | ||||
@Override | @Override | ||||
public String getDefaultMetaVariable() { | public String getDefaultMetaVariable() { | ||||
return "object"; | |||||
return CLIText.get().metaVar_object; | |||||
} | } | ||||
} | } |
import org.kohsuke.args4j.spi.OptionHandler; | import org.kohsuke.args4j.spi.OptionHandler; | ||||
import org.kohsuke.args4j.spi.Parameters; | import org.kohsuke.args4j.spi.Parameters; | ||||
import org.kohsuke.args4j.spi.Setter; | 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.PathFilter; | ||||
import org.eclipse.jgit.treewalk.filter.PathFilterGroup; | import org.eclipse.jgit.treewalk.filter.PathFilterGroup; | ||||
import org.eclipse.jgit.treewalk.filter.TreeFilter; | import org.eclipse.jgit.treewalk.filter.TreeFilter; | ||||
@Override | @Override | ||||
public String getDefaultMetaVariable() { | public String getDefaultMetaVariable() { | ||||
return "path ..."; | |||||
return CLIText.get().metaVar_paths; | |||||
} | } | ||||
} | } |
import org.kohsuke.args4j.spi.OptionHandler; | import org.kohsuke.args4j.spi.OptionHandler; | ||||
import org.kohsuke.args4j.spi.Parameters; | import org.kohsuke.args4j.spi.Parameters; | ||||
import org.kohsuke.args4j.spi.Setter; | import org.kohsuke.args4j.spi.Setter; | ||||
import org.eclipse.jgit.pgm.CLIText; | |||||
import org.eclipse.jgit.transport.RefSpec; | import org.eclipse.jgit.transport.RefSpec; | ||||
/** | /** | ||||
@Override | @Override | ||||
public String getDefaultMetaVariable() { | public String getDefaultMetaVariable() { | ||||
return "refspec"; | |||||
return CLIText.get().metaVar_refspec; | |||||
} | } | ||||
} | } |
package org.eclipse.jgit.pgm.opt; | package org.eclipse.jgit.pgm.opt; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.text.MessageFormat; | |||||
import org.kohsuke.args4j.CmdLineException; | import org.kohsuke.args4j.CmdLineException; | ||||
import org.kohsuke.args4j.CmdLineParser; | import org.kohsuke.args4j.CmdLineParser; | ||||
import org.eclipse.jgit.errors.IncorrectObjectTypeException; | import org.eclipse.jgit.errors.IncorrectObjectTypeException; | ||||
import org.eclipse.jgit.errors.MissingObjectException; | import org.eclipse.jgit.errors.MissingObjectException; | ||||
import org.eclipse.jgit.lib.ObjectId; | import org.eclipse.jgit.lib.ObjectId; | ||||
import org.eclipse.jgit.pgm.CLIText; | |||||
import org.eclipse.jgit.revwalk.RevCommit; | import org.eclipse.jgit.revwalk.RevCommit; | ||||
import org.eclipse.jgit.revwalk.RevFlag; | import org.eclipse.jgit.revwalk.RevFlag; | ||||
final int dot2 = name.indexOf(".."); | final int dot2 = name.indexOf(".."); | ||||
if (dot2 != -1) { | if (dot2 != -1) { | ||||
if (!option.isMultiValued()) | 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 left = name.substring(0, dot2); | ||||
final String right = name.substring(dot2 + 2); | final String right = name.substring(dot2 + 2); | ||||
throw new CmdLineException(e.getMessage()); | throw new CmdLineException(e.getMessage()); | ||||
} | } | ||||
if (id == null) | if (id == null) | ||||
throw new CmdLineException(name + " is not a commit"); | |||||
throw new CmdLineException(MessageFormat.format(CLIText.get().notACommit, name)); | |||||
final RevCommit c; | final RevCommit c; | ||||
try { | try { | ||||
c = clp.getRevWalk().parseCommit(id); | c = clp.getRevWalk().parseCommit(id); | ||||
} catch (MissingObjectException e) { | } catch (MissingObjectException e) { | ||||
throw new CmdLineException(name + " is not a commit"); | |||||
throw new CmdLineException(MessageFormat.format(CLIText.get().notACommit, name)); | |||||
} catch (IncorrectObjectTypeException e) { | } catch (IncorrectObjectTypeException e) { | ||||
throw new CmdLineException(name + " is not a commit"); | |||||
throw new CmdLineException(MessageFormat.format(CLIText.get().notACommit, name)); | |||||
} catch (IOException e) { | } catch (IOException e) { | ||||
throw new CmdLineException("cannot read " + name + ": " | |||||
+ e.getMessage()); | |||||
throw new CmdLineException(MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage())); | |||||
} | } | ||||
if (interesting) | if (interesting) | ||||
@Override | @Override | ||||
public String getDefaultMetaVariable() { | public String getDefaultMetaVariable() { | ||||
return "commit-ish"; | |||||
return CLIText.get().metaVar_commitish; | |||||
} | } | ||||
} | } |
package org.eclipse.jgit.pgm.opt; | package org.eclipse.jgit.pgm.opt; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.text.MessageFormat; | |||||
import org.kohsuke.args4j.CmdLineException; | import org.kohsuke.args4j.CmdLineException; | ||||
import org.kohsuke.args4j.CmdLineParser; | import org.kohsuke.args4j.CmdLineParser; | ||||
import org.eclipse.jgit.errors.IncorrectObjectTypeException; | import org.eclipse.jgit.errors.IncorrectObjectTypeException; | ||||
import org.eclipse.jgit.errors.MissingObjectException; | import org.eclipse.jgit.errors.MissingObjectException; | ||||
import org.eclipse.jgit.lib.ObjectId; | import org.eclipse.jgit.lib.ObjectId; | ||||
import org.eclipse.jgit.pgm.CLIText; | |||||
import org.eclipse.jgit.revwalk.RevTree; | import org.eclipse.jgit.revwalk.RevTree; | ||||
/** | /** | ||||
throw new CmdLineException(e.getMessage()); | throw new CmdLineException(e.getMessage()); | ||||
} | } | ||||
if (id == null) | if (id == null) | ||||
throw new CmdLineException(name + " is not a tree"); | |||||
throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); | |||||
final RevTree c; | final RevTree c; | ||||
try { | try { | ||||
c = clp.getRevWalk().parseTree(id); | c = clp.getRevWalk().parseTree(id); | ||||
} catch (MissingObjectException e) { | } catch (MissingObjectException e) { | ||||
throw new CmdLineException(name + " is not a tree"); | |||||
throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); | |||||
} catch (IncorrectObjectTypeException e) { | } catch (IncorrectObjectTypeException e) { | ||||
throw new CmdLineException(name + " is not a tree"); | |||||
throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); | |||||
} catch (IOException e) { | } 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); | setter.addValue(c); | ||||
return 1; | return 1; | ||||
@Override | @Override | ||||
public String getDefaultMetaVariable() { | public String getDefaultMetaVariable() { | ||||
return "tree-ish"; | |||||
return CLIText.get().metaVar_treeish; | |||||
} | } | ||||
} | } |
import org.kohsuke.args4j.spi.OptionHandler; | import org.kohsuke.args4j.spi.OptionHandler; | ||||
import org.kohsuke.args4j.spi.Parameters; | import org.kohsuke.args4j.spi.Parameters; | ||||
import org.kohsuke.args4j.spi.Setter; | import org.kohsuke.args4j.spi.Setter; | ||||
import org.eclipse.jgit.pgm.CLIText; | |||||
import org.eclipse.jgit.pgm.CommandCatalog; | import org.eclipse.jgit.pgm.CommandCatalog; | ||||
import org.eclipse.jgit.pgm.CommandRef; | import org.eclipse.jgit.pgm.CommandRef; | ||||
import org.eclipse.jgit.pgm.TextBuiltin; | import org.eclipse.jgit.pgm.TextBuiltin; | ||||
final CommandRef cr = CommandCatalog.get(name); | final CommandRef cr = CommandCatalog.get(name); | ||||
if (cr == null) | if (cr == null) | ||||
throw new CmdLineException(MessageFormat.format( | 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 | // Force option parsing to stop. Everything after us should | ||||
// be arguments known only to this command and must not be | // be arguments known only to this command and must not be | ||||
@Override | @Override | ||||
public String getDefaultMetaVariable() { | public String getDefaultMetaVariable() { | ||||
return "command"; | |||||
return CLIText.get().metaVar_command; | |||||
} | } | ||||
} | } |
Import-Package: junit.framework;version="[3.8.2,4.0.0)", | Import-Package: junit.framework;version="[3.8.2,4.0.0)", | ||||
junit.textui;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.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.diff;version="[0.8.0,0.9.0)", | ||||
org.eclipse.jgit.dircache;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.errors;version="[0.8.0,0.9.0)", | ||||
org.eclipse.jgit.fnmatch;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.junit;version="[0.8.0,0.9.0)", | ||||
org.eclipse.jgit.lib;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.merge;version="[0.8.0,0.9.0)", | ||||
org.eclipse.jgit.nls;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.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.revplot;version="[0.8.0,0.9.0)", | ||||
org.eclipse.jgit.revwalk;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)", | org.eclipse.jgit.revwalk.filter;version="[0.8.0,0.9.0)", |
package org.eclipse.jgit.lib; | package org.eclipse.jgit.lib; | ||||
import java.text.MessageFormat; | |||||
import junit.framework.TestCase; | import junit.framework.TestCase; | ||||
import org.eclipse.jgit.JGitText; | |||||
import org.eclipse.jgit.errors.CorruptObjectException; | import org.eclipse.jgit.errors.CorruptObjectException; | ||||
public class ObjectCheckerTest extends TestCase { | public class ObjectCheckerTest extends TestCase { | ||||
fail("Did not throw CorruptObjectException"); | fail("Did not throw CorruptObjectException"); | ||||
} catch (CorruptObjectException e) { | } catch (CorruptObjectException e) { | ||||
final String m = e.getMessage(); | final String m = e.getMessage(); | ||||
assertEquals("Invalid object type: " + Constants.OBJ_BAD, m); | |||||
assertEquals(MessageFormat.format(JGitText.get().corruptObjectInvalidType2, Constants.OBJ_BAD), m); | |||||
} | } | ||||
} | } | ||||
public void testNLSLocale() { | public void testNLSLocale() { | ||||
NLS.setLocale(NLS.ROOT_LOCALE); | NLS.setLocale(NLS.ROOT_LOCALE); | ||||
GermanTranslatedBundle bundle = GermanTranslatedBundle.get(); | GermanTranslatedBundle bundle = GermanTranslatedBundle.get(); | ||||
assertEquals(NLS.ROOT_LOCALE, bundle.getEffectiveLocale()); | |||||
assertEquals(NLS.ROOT_LOCALE, bundle.effectiveLocale()); | |||||
NLS.setLocale(Locale.GERMAN); | NLS.setLocale(Locale.GERMAN); | ||||
bundle = GermanTranslatedBundle.get(); | bundle = GermanTranslatedBundle.get(); | ||||
assertEquals(Locale.GERMAN, bundle.getEffectiveLocale()); | |||||
assertEquals(Locale.GERMAN, bundle.effectiveLocale()); | |||||
} | } | ||||
public void testJVMDefaultLocale() { | public void testJVMDefaultLocale() { | ||||
Locale.setDefault(NLS.ROOT_LOCALE); | Locale.setDefault(NLS.ROOT_LOCALE); | ||||
NLS.useJVMDefaultLocale(); | NLS.useJVMDefaultLocale(); | ||||
GermanTranslatedBundle bundle = GermanTranslatedBundle.get(); | GermanTranslatedBundle bundle = GermanTranslatedBundle.get(); | ||||
assertEquals(NLS.ROOT_LOCALE, bundle.getEffectiveLocale()); | |||||
assertEquals(NLS.ROOT_LOCALE, bundle.effectiveLocale()); | |||||
Locale.setDefault(Locale.GERMAN); | Locale.setDefault(Locale.GERMAN); | ||||
NLS.useJVMDefaultLocale(); | NLS.useJVMDefaultLocale(); | ||||
bundle = GermanTranslatedBundle.get(); | bundle = GermanTranslatedBundle.get(); | ||||
assertEquals(Locale.GERMAN, bundle.getEffectiveLocale()); | |||||
assertEquals(Locale.GERMAN, bundle.effectiveLocale()); | |||||
} | } | ||||
public void testThreadTranslationBundleInheritance() throws InterruptedException { | public void testThreadTranslationBundleInheritance() throws InterruptedException { | ||||
assertNull("t1 was interrupted or barrier was broken", t1.e); | assertNull("t1 was interrupted or barrier was broken", t1.e); | ||||
assertNull("t2 was interrupted or barrier was broken", t2.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()); | |||||
} | } | ||||
} | } |
NonTranslatedBundle bundle = new NonTranslatedBundle(); | NonTranslatedBundle bundle = new NonTranslatedBundle(); | ||||
bundle.load(NLS.ROOT_LOCALE); | bundle.load(NLS.ROOT_LOCALE); | ||||
assertEquals(NLS.ROOT_LOCALE, bundle.getEffectiveLocale()); | |||||
assertEquals(NLS.ROOT_LOCALE, bundle.effectiveLocale()); | |||||
assertEquals("Good morning {0}", bundle.goodMorning); | assertEquals("Good morning {0}", bundle.goodMorning); | ||||
bundle.load(Locale.ENGLISH); | bundle.load(Locale.ENGLISH); | ||||
assertEquals(NLS.ROOT_LOCALE, bundle.getEffectiveLocale()); | |||||
assertEquals(NLS.ROOT_LOCALE, bundle.effectiveLocale()); | |||||
assertEquals("Good morning {0}", bundle.goodMorning); | assertEquals("Good morning {0}", bundle.goodMorning); | ||||
bundle.load(Locale.GERMAN); | bundle.load(Locale.GERMAN); | ||||
assertEquals(NLS.ROOT_LOCALE, bundle.getEffectiveLocale()); | |||||
assertEquals(NLS.ROOT_LOCALE, bundle.effectiveLocale()); | |||||
assertEquals("Good morning {0}", bundle.goodMorning); | assertEquals("Good morning {0}", bundle.goodMorning); | ||||
} | } | ||||
GermanTranslatedBundle bundle = new GermanTranslatedBundle(); | GermanTranslatedBundle bundle = new GermanTranslatedBundle(); | ||||
bundle.load(NLS.ROOT_LOCALE); | bundle.load(NLS.ROOT_LOCALE); | ||||
assertEquals(NLS.ROOT_LOCALE, bundle.getEffectiveLocale()); | |||||
assertEquals(NLS.ROOT_LOCALE, bundle.effectiveLocale()); | |||||
assertEquals("Good morning {0}", bundle.goodMorning); | assertEquals("Good morning {0}", bundle.goodMorning); | ||||
bundle.load(Locale.GERMAN); | bundle.load(Locale.GERMAN); | ||||
assertEquals(Locale.GERMAN, bundle.getEffectiveLocale()); | |||||
assertEquals(Locale.GERMAN, bundle.effectiveLocale()); | |||||
assertEquals("Guten Morgen {0}", bundle.goodMorning); | assertEquals("Guten Morgen {0}", bundle.goodMorning); | ||||
} | } | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.InputStream; | import java.io.InputStream; | ||||
import java.text.MessageFormat; | |||||
import org.eclipse.jgit.JGitText; | |||||
import junit.framework.TestCase; | import junit.framework.TestCase; | ||||
final FormatError e = p.getErrors().get(0); | final FormatError e = p.getErrors().get(0); | ||||
assertSame(FormatError.Severity.ERROR, e.getSeverity()); | assertSame(FormatError.Severity.ERROR, e.getSeverity()); | ||||
assertEquals( | assertEquals( | ||||
"Truncated hunk, at least 1 lines is missing for ancestor 1", | |||||
MessageFormat.format(JGitText.get().truncatedHunkLinesMissingForAncestor, 1, 1), | |||||
e.getMessage()); | e.getMessage()); | ||||
assertEquals(346, e.getOffset()); | assertEquals(346, e.getOffset()); | ||||
assertTrue(e.getLineText().startsWith( | assertTrue(e.getLineText().startsWith( | ||||
final FormatError e = p.getErrors().get(1); | final FormatError e = p.getErrors().get(1); | ||||
assertSame(FormatError.Severity.ERROR, e.getSeverity()); | assertSame(FormatError.Severity.ERROR, e.getSeverity()); | ||||
assertEquals( | assertEquals( | ||||
"Truncated hunk, at least 2 lines is missing for ancestor 2", | |||||
MessageFormat.format(JGitText.get().truncatedHunkLinesMissingForAncestor, 2, 2), | |||||
e.getMessage()); | e.getMessage()); | ||||
assertEquals(346, e.getOffset()); | assertEquals(346, e.getOffset()); | ||||
assertTrue(e.getLineText().startsWith( | assertTrue(e.getLineText().startsWith( |
import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.OutputStream; | import java.io.OutputStream; | ||||
import java.text.MessageFormat; | |||||
import junit.framework.TestCase; | import junit.framework.TestCase; | ||||
import org.eclipse.jgit.JGitText; | |||||
import org.eclipse.jgit.lib.Constants; | import org.eclipse.jgit.lib.Constants; | ||||
// Note, test vectors created with: | // Note, test vectors created with: | ||||
new SideBandOutputStream(CH_DATA, Integer.MAX_VALUE, rawOut); | new SideBandOutputStream(CH_DATA, Integer.MAX_VALUE, rawOut); | ||||
fail("Accepted " + Integer.MAX_VALUE + " for buffer size"); | fail("Accepted " + Integer.MAX_VALUE + " for buffer size"); | ||||
} catch (IllegalArgumentException e) { | } 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()); | |||||
} | } | ||||
} | } | ||||
<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.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="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||||
<classpathentry kind="src" path="src"/> | <classpathentry kind="src" path="src"/> | ||||
<classpathentry kind="src" path="resources"/> | |||||
<classpathentry kind="output" path="bin"/> | <classpathentry kind="output" path="bin"/> | ||||
</classpath> | </classpath> |
Bundle-RequiredExecutionEnvironment: J2SE-1.5 | Bundle-RequiredExecutionEnvironment: J2SE-1.5 | ||||
Export-Package: org.eclipse.jgit.awtui;version="0.8.0" | Export-Package: org.eclipse.jgit.awtui;version="0.8.0" | ||||
Import-Package: org.eclipse.jgit.lib;version="[0.8.0,0.9.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.revplot;version="[0.8.0,0.9.0)", | ||||
org.eclipse.jgit.revwalk;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.transport;version="[0.8.0,0.9.0)", |
<include>plugin.properties</include> | <include>plugin.properties</include> | ||||
</includes> | </includes> | ||||
</resource> | </resource> | ||||
<resource> | |||||
<directory>resources/</directory> | |||||
</resource> | |||||
</resources> | </resources> | ||||
<plugins> | <plugins> |
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 |
panel.setLayout(new GridBagLayout()); | panel.setLayout(new GridBagLayout()); | ||||
final StringBuilder instruction = new StringBuilder(); | final StringBuilder instruction = new StringBuilder(); | ||||
instruction.append("Enter username and password for "); | |||||
instruction.append(UIText.get().enterUsernameAndPasswordFor); | |||||
instruction.append(" "); | |||||
if (getRequestorType() == RequestorType.PROXY) { | if (getRequestorType() == RequestorType.PROXY) { | ||||
instruction.append(getRequestorType()); | instruction.append(getRequestorType()); | ||||
instruction.append(" "); | instruction.append(" "); | ||||
gbc.fill = GridBagConstraints.NONE; | gbc.fill = GridBagConstraints.NONE; | ||||
gbc.gridx = 0; | gbc.gridx = 0; | ||||
gbc.weightx = 1; | gbc.weightx = 1; | ||||
panel.add(new JLabel("Username:"), gbc); | |||||
panel.add(new JLabel(UIText.get().username), gbc); | |||||
gbc.gridx = 1; | gbc.gridx = 1; | ||||
gbc.fill = GridBagConstraints.HORIZONTAL; | gbc.fill = GridBagConstraints.HORIZONTAL; | ||||
gbc.fill = GridBagConstraints.NONE; | gbc.fill = GridBagConstraints.NONE; | ||||
gbc.gridx = 0; | gbc.gridx = 0; | ||||
gbc.weightx = 1; | gbc.weightx = 1; | ||||
panel.add(new JLabel("Password:"), gbc); | |||||
panel.add(new JLabel(UIText.get().password), gbc); | |||||
gbc.gridx = 1; | gbc.gridx = 1; | ||||
gbc.fill = GridBagConstraints.HORIZONTAL; | gbc.fill = GridBagConstraints.HORIZONTAL; | ||||
gbc.gridy++; | gbc.gridy++; | ||||
if (JOptionPane.showConfirmDialog(null, panel, | if (JOptionPane.showConfirmDialog(null, panel, | ||||
"Authentication Required", JOptionPane.OK_CANCEL_OPTION, | |||||
UIText.get().authenticationRequired, JOptionPane.OK_CANCEL_OPTION, | |||||
JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION) { | JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION) { | ||||
return new PasswordAuthentication(username.getText(), password | return new PasswordAuthentication(username.getText(), password | ||||
.getPassword()); | .getPassword()); |
} | } | ||||
public boolean promptYesNo(final String msg) { | 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; | JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION; | ||||
} | } | ||||
@Override | @Override | ||||
public void setModel(final TableModel dataModel) { | public void setModel(final TableModel dataModel) { | ||||
if (dataModel != null && !(dataModel instanceof CommitTableModel)) | if (dataModel != null && !(dataModel instanceof CommitTableModel)) | ||||
throw new ClassCastException("Must be special table model."); | |||||
throw new ClassCastException(UIText.get().mustBeSpecialTableModel); | |||||
super.setModel(dataModel); | super.setModel(dataModel); | ||||
} | } | ||||
final TableColumn date = cols.getColumn(2); | final TableColumn date = cols.getColumn(2); | ||||
graph.setHeaderValue(""); | graph.setHeaderValue(""); | ||||
author.setHeaderValue("Author"); | |||||
date.setHeaderValue("Date"); | |||||
author.setHeaderValue(UIText.get().author); | |||||
date.setHeaderValue(UIText.get().date); | |||||
graph.setCellRenderer(new GraphCellRender()); | graph.setCellRenderer(new GraphCellRender()); | ||||
author.setCellRenderer(new NameCellRender()); | author.setCellRenderer(new NameCellRender()); |
/* | |||||
* 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; | |||||
} |
<?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||
<classpath> | <classpath> | ||||
<classpathentry kind="src" path="src"/> | <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.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="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||||
<classpathentry kind="output" path="bin"/> | <classpathentry kind="output" path="bin"/> |
Bundle-Version: 0.8.0.qualifier | Bundle-Version: 0.8.0.qualifier | ||||
Bundle-Localization: plugin | Bundle-Localization: plugin | ||||
Bundle-Vendor: %provider_name | 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.diff;version="0.8.0", | ||||
org.eclipse.jgit.dircache;version="0.8.0", | org.eclipse.jgit.dircache;version="0.8.0", | ||||
org.eclipse.jgit.errors;version="0.8.0", | org.eclipse.jgit.errors;version="0.8.0", |
<include>plugin.properties</include> | <include>plugin.properties</include> | ||||
</includes> | </includes> | ||||
</resource> | </resource> | ||||
<resource> | |||||
<directory>resources/</directory> | |||||
</resource> | |||||
</resources> | </resources> | ||||
<plugins> | <plugins> |