You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by vm...@apache.org on 2012/05/29 04:51:13 UTC
svn commit: r1343452 - in
/subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl:
CommonContext.java SVNClient.java
Author: vmpn
Date: Tue May 29 02:51:12 2012
New Revision: 1343452
URL: http://svn.apache.org/viewvc?rev=1343452&view=rev
Log:
On the javahl-ra branch:
JavaHL: Factored out common context for later use by the SVNRa class
[ in subversion/bindings/javahl/src/org/tigris/subversion/javahl/ ]
* CommonContext.java,
SVNClient.java
(ClientContext): Move the progress listener into CommonContext for later
sharing with the new SVNRa class
Added:
subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/CommonContext.java
- copied, changed from r1343447, subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java
Modified:
subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java
Copied: subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/CommonContext.java (from r1343447, subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java)
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/CommonContext.java?p2=subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/CommonContext.java&p1=subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java&r1=1343447&r2=1343452&rev=1343452&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java (original)
+++ subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/CommonContext.java Tue May 29 02:51:12 2012
@@ -23,513 +23,30 @@
package org.apache.subversion.javahl;
-import org.apache.subversion.javahl.callback.*;
-import org.apache.subversion.javahl.types.*;
-
-import java.io.OutputStream;
-import java.io.FileOutputStream;
-import java.io.FileNotFoundException;
-import java.io.ByteArrayOutputStream;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.List;
-import java.util.Map;
+import org.apache.subversion.javahl.callback.ProgressCallback;
/**
- * This is the main client class. All Subversion client APIs are
- * implemented in this class. This class is not threadsafe; if you
- * need threadsafe access, use ClientSynchronized.
+ * A private class to hold the contextual information required to
+ * persist in this object, such as notification handlers.
*/
-public class SVNClient implements ISVNClient
+public class CommonContext
+ implements ProgressCallback
{
- /**
- * Load the required native library.
- */
- static
- {
- NativeResources.loadNativeLibrary();
- }
-
- /**
- * Standard empty contructor, builds just the native peer.
- */
- public SVNClient()
- {
- cppAddr = ctNative();
-
- // Ensure that Subversion's config file area and templates exist.
- try
- {
- setConfigDirectory(null);
- }
- catch (ClientException suppressed)
- {
- // Not an exception-worthy problem, continue on.
- }
- }
+ private ProgressCallback listener = null;
- private long getCppAddr()
+ public void onProgress(ProgressEvent event)
{
- return cppAddr;
+ if (listener != null)
+ listener.onProgress(event);
}
- /**
- * Build the native peer
- * @return the adress of the peer
- */
- private native long ctNative();
-
- /**
- * release the native peer (should not depend on finalize)
- */
- public native void dispose();
-
- /**
- * release the native peer (should use dispose instead)
- */
- public native void finalize();
-
- /**
- * slot for the adress of the native peer. The JNI code is the only user
- * of this member
- */
- protected long cppAddr;
-
- private ClientContext clientContext = new ClientContext();
-
- public Version getVersion()
- {
- return NativeResources.getVersion();
- }
-
- public native String getAdminDirectoryName();
-
- public native boolean isAdminDirectory(String name);
-
- /**
- * @deprecated
- */
- public native String getLastPath();
-
- public native void status(String path, Depth depth, boolean onServer,
- boolean getAll, boolean noIgnore,
- boolean ignoreExternals,
- Collection<String> changelists,
- StatusCallback callback)
- throws ClientException;
-
- public native void list(String url, Revision revision,
- Revision pegRevision, Depth depth, int direntFields,
- boolean fetchLocks, ListCallback callback)
- throws ClientException;
-
- public native void username(String username);
-
- public native void password(String password);
-
- public native void setPrompt(UserPasswordCallback prompt);
-
- public native void logMessages(String path, Revision pegRevision,
- List<RevisionRange> revisionRanges,
- boolean stopOnCopy, boolean discoverPath,
- boolean includeMergedRevisions,
- Set<String> revProps, long limit,
- LogMessageCallback callback)
- throws ClientException;
-
- public native long checkout(String moduleName, String destPath,
- Revision revision, Revision pegRevision,
- Depth depth, boolean ignoreExternals,
- boolean allowUnverObstructions)
- throws ClientException;
-
- public void notification2(ClientNotifyCallback notify)
- {
- clientContext.notify = notify;
- }
-
- public void setConflictResolver(ConflictResolverCallback listener)
- {
- clientContext.resolver = listener;
- }
-
- public void setProgressCallback(ProgressCallback listener)
- {
- clientContext.listener = listener;
- }
-
- public native void remove(Set<String> paths, boolean force,
- boolean keepLocal,
- Map<String, String> revpropTable,
- CommitMessageCallback handler, CommitCallback callback)
- throws ClientException;
-
- public native void revert(String path, Depth depth,
- Collection<String> changelists)
- throws ClientException;
-
- public native void add(String path, Depth depth, boolean force,
- boolean noIgnores, boolean addParents)
- throws ClientException;
-
- public native long[] update(Set<String> paths, Revision revision,
- Depth depth, boolean depthIsSticky,
- boolean makeParents,
- boolean ignoreExternals,
- boolean allowUnverObstructions)
- throws ClientException;
-
- public native void commit(Set<String> paths, Depth depth, boolean noUnlock,
- boolean keepChangelist,
- Collection<String> changelists,
- Map<String, String> revpropTable,
- CommitMessageCallback handler, CommitCallback callback)
- throws ClientException;
-
- public native void copy(List<CopySource> sources, String destPath,
- boolean copyAsChild, boolean makeParents,
- boolean ignoreExternals,
- Map<String, String> revpropTable,
- CommitMessageCallback handler, CommitCallback callback)
- throws ClientException;
-
- public native void move(Set<String> srcPaths, String destPath,
- boolean force, boolean moveAsChild,
- boolean makeParents,
- Map<String, String> revpropTable,
- CommitMessageCallback handler, CommitCallback callback)
- throws ClientException;
-
- public native void mkdir(Set<String> paths, boolean makeParents,
- Map<String, String> revpropTable,
- CommitMessageCallback handler, CommitCallback callback)
- throws ClientException;
-
- public native void cleanup(String path)
- throws ClientException;
-
- public native void resolve(String path, Depth depth,
- ConflictResult.Choice conflictResult)
- throws SubversionException;
-
- public native long doExport(String srcPath, String destPath,
- Revision revision, Revision pegRevision,
- boolean force, boolean ignoreExternals,
- Depth depth, String nativeEOL)
- throws ClientException;
-
- public native long doSwitch(String path, String url, Revision revision,
- Revision pegRevision, Depth depth,
- boolean depthIsSticky, boolean ignoreExternals,
- boolean allowUnverObstructions,
- boolean ignoreAncestry)
- throws ClientException;
-
- public native void doImport(String path, String url, Depth depth,
- boolean noIgnore,
- boolean ignoreUnknownNodeTypes,
- Map<String, String> revpropTable,
- CommitMessageCallback handler, CommitCallback callback)
- throws ClientException;
-
- public native Set<String> suggestMergeSources(String path,
- Revision pegRevision)
- throws SubversionException;
-
- public native void merge(String path1, Revision revision1, String path2,
- Revision revision2, String localPath,
- boolean force, Depth depth,
- boolean ignoreAncestry, boolean dryRun,
- boolean recordOnly)
- throws ClientException;
-
- public native void merge(String path, Revision pegRevision,
- List<RevisionRange> revisions, String localPath,
- boolean force, Depth depth, boolean ignoreAncestry,
- boolean dryRun, boolean recordOnly)
- throws ClientException;
-
- public native void mergeReintegrate(String path, Revision pegRevision,
- String localPath, boolean dryRun)
- throws ClientException;
-
- public native Mergeinfo getMergeinfo(String path, Revision pegRevision)
- throws SubversionException;
-
- public native void getMergeinfoLog(Mergeinfo.LogKind kind, String pathOrUrl,
- Revision pegRevision,
- String mergeSourceUrl,
- Revision srcPegRevision,
- boolean discoverChangedPaths, Depth depth,
- Set<String> revProps,
- LogMessageCallback callback)
- throws ClientException;
+ public ProgressCallback getListener()
+ {
+ return listener;
+ }
- public void diff(String target1, Revision revision1, String target2,
- Revision revision2, String relativeToDir,
- String outFileName, Depth depth,
- Collection<String> changelists,
- boolean ignoreAncestry, boolean noDiffDeleted,
- boolean force, boolean copiesAsAdds)
- throws ClientException
- {
- try {
- OutputStream stream = new FileOutputStream(outFileName);
- diff(target1, revision1, target2, revision2, relativeToDir,
- stream, depth, changelists, ignoreAncestry, noDiffDeleted,
- force, copiesAsAdds, false, false);
- } catch (FileNotFoundException ex) {
- throw ClientException.fromException(ex);
- }
- }
-
- public native void diff(String target1, Revision revision1, String target2,
- Revision revision2, String relativeToDir,
- OutputStream stream, Depth depth,
- Collection<String> changelists,
- boolean ignoreAncestry, boolean noDiffDeleted,
- boolean force, boolean copiesAsAdds,
- boolean ignoreProps, boolean propsOnly)
- throws ClientException;
-
- public void diff(String target, Revision pegRevision,
- Revision startRevision, Revision endRevision,
- String relativeToDir, String outFileName,
- Depth depth, Collection<String> changelists,
- boolean ignoreAncestry, boolean noDiffDeleted,
- boolean force, boolean copiesAsAdds)
- throws ClientException
- {
- try {
- OutputStream stream = new FileOutputStream(outFileName);
- diff(target, pegRevision, startRevision, endRevision,
- relativeToDir, stream, depth, changelists, ignoreAncestry,
- noDiffDeleted, force, copiesAsAdds, false, false);
- } catch (FileNotFoundException ex) {
- throw ClientException.fromException(ex);
- }
- }
-
- public native void diff(String target, Revision pegRevision,
- Revision startRevision, Revision endRevision,
- String relativeToDir, OutputStream stream,
- Depth depth, Collection<String> changelists,
- boolean ignoreAncestry, boolean noDiffDeleted,
- boolean force, boolean copiesAsAdds,
- boolean ignoreProps, boolean propsOnly)
- throws ClientException;
-
- public native void diffSummarize(String target1, Revision revision1,
- String target2, Revision revision2,
- Depth depth, Collection<String> changelists,
- boolean ignoreAncestry,
- DiffSummaryCallback receiver)
- throws ClientException;
-
- public native void diffSummarize(String target, Revision pegRevision,
- Revision startRevision,
- Revision endRevision, Depth depth,
- Collection<String> changelists,
- boolean ignoreAncestry,
- DiffSummaryCallback receiver)
- throws ClientException;
-
- public native void properties(String path, Revision revision,
- Revision pegRevision, Depth depth,
- Collection<String> changelists,
- ProplistCallback callback)
- throws ClientException;
-
- public native void propertySetLocal(Set<String> paths, String name,
- byte[] value, Depth depth,
- Collection<String> changelists,
- boolean force)
- throws ClientException;
-
- public native void propertySetRemote(String path, long baseRev,
- String name, byte[] value,
- CommitMessageCallback handler,
- boolean force,
- Map<String, String> revpropTable,
- CommitCallback callback)
- throws ClientException;
-
- public native byte[] revProperty(String path, String name, Revision rev)
- throws ClientException;
-
- public native Map<String, byte[]> revProperties(String path, Revision rev)
- throws ClientException;
-
- public native void setRevProperty(String path, String name, Revision rev,
- String value, String originalValue,
- boolean force)
- throws ClientException;
-
- public native byte[] propertyGet(String path, String name,
- Revision revision, Revision pegRevision)
- throws ClientException;
-
- public byte[] fileContent(String path, Revision revision,
- Revision pegRevision)
- throws ClientException
- {
- ByteArrayOutputStream stream = new ByteArrayOutputStream();
-
- streamFileContent(path, revision, pegRevision, stream);
- return stream.toByteArray();
- }
-
- public native void streamFileContent(String path, Revision revision,
- Revision pegRevision,
- OutputStream stream)
- throws ClientException;
-
- public native void relocate(String from, String to, String path,
- boolean ignoreExternals)
- throws ClientException;
-
- public native void blame(String path, Revision pegRevision,
- Revision revisionStart,
- Revision revisionEnd, boolean ignoreMimeType,
- boolean includeMergedRevisions,
- BlameCallback callback)
- throws ClientException;
-
- public native void setConfigDirectory(String configDir)
- throws ClientException;
-
- public native String getConfigDirectory()
- throws ClientException;
-
- public native void cancelOperation()
- throws ClientException;
-
- public native void addToChangelist(Set<String> paths, String changelist,
- Depth depth,
- Collection<String> changelists)
- throws ClientException;
-
- public native void removeFromChangelists(Set<String> paths, Depth depth,
- Collection<String> changelists)
- throws ClientException;
-
- public native void getChangelists(String rootPath,
- Collection<String> changelists,
- Depth depth, ChangelistCallback callback)
- throws ClientException;
-
- public native String getVersionInfo(String path, String trailUrl,
- boolean lastChanged)
- throws ClientException;
-
- public native void upgrade(String path)
- throws ClientException;
-
- /**
- * Enable logging in the JNI-code
- * @param logLevel the level of information to log (See
- * ClientLogLevel)
- * @param logFilePath path of the log file
- */
- public static native void enableLogging(ClientLogLevel logLevel,
- String logFilePath);
-
- /**
- * enum for the constants of the logging levels.
- */
- public enum ClientLogLevel
- {
- /** Log nothing */
- NoLog,
-
- /** Log fatal error */
- ErrorLog,
-
- /** Log exceptions thrown */
- ExceptionLog,
-
- /** Log the entry and exits of the JNI code */
- EntryLog;
- }
-
- /**
- * Returns version information of subversion and the javahl binding
- * @return version information
- */
- public static native String version();
-
- /**
- * Returns the major version of the javahl binding. Same version of the
- * javahl support the same interfaces
- * @return major version number
- */
- public static native int versionMajor();
-
- /**
- * Returns the minor version of the javahl binding. Same version of the
- * javahl support the same interfaces
- * @return minor version number
- */
- public static native int versionMinor();
-
- /**
- * Returns the micro (patch) version of the javahl binding. Same version of
- * the javahl support the same interfaces
- * @return micro version number
- */
- public static native int versionMicro();
-
- public native void lock(Set<String> paths, String comment, boolean force)
- throws ClientException;
-
- public native void unlock(Set<String> paths, boolean force)
- throws ClientException;
-
- public native void info2(String pathOrUrl, Revision revision,
- Revision pegRevision, Depth depth,
- Collection<String> changelists,
- InfoCallback callback)
- throws ClientException;
-
- public native void patch(String patchPath, String targetPath,
- boolean dryRun, int stripCount, boolean reverse,
- boolean ignoreWhitespace, boolean removeTempfiles,
- PatchCallback callback)
- throws ClientException;
-
- /**
- * A private class to hold the contextual information required to
- * persist in this object, such as notification handlers.
- */
- private class ClientContext
- implements ClientNotifyCallback, ProgressCallback,
- ConflictResolverCallback
- {
- public ClientNotifyCallback notify = null;
- public ProgressCallback listener = null;
- public ConflictResolverCallback resolver = null;
-
- public void onNotify(ClientNotifyInformation notifyInfo)
- {
- if (notify != null)
- notify.onNotify(notifyInfo);
- }
-
- public void onProgress(ProgressEvent event)
- {
- if (listener != null)
- listener.onProgress(event);
- }
-
- public ConflictResult resolve(ConflictDescriptor conflict)
- throws SubversionException
- {
- if (resolver != null)
- return resolver.resolve(conflict);
- else
- return new ConflictResult(ConflictResult.Choice.postpone,
- null);
- }
- }
-}
+ public void setListener(ProgressCallback listener)
+ {
+ this.listener = listener;
+ }
+}
\ No newline at end of file
Modified: subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java?rev=1343452&r1=1343451&r2=1343452&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java (original)
+++ subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java Tue May 29 02:51:12 2012
@@ -156,7 +156,7 @@ public class SVNClient implements ISVNCl
public void setProgressCallback(ProgressCallback listener)
{
- clientContext.listener = listener;
+ clientContext.setListener(listener);
}
public native void remove(Set<String> paths, boolean force,
@@ -502,12 +502,11 @@ public class SVNClient implements ISVNCl
* A private class to hold the contextual information required to
* persist in this object, such as notification handlers.
*/
- private class ClientContext
+ private class ClientContext extends CommonContext
implements ClientNotifyCallback, ProgressCallback,
ConflictResolverCallback
{
public ClientNotifyCallback notify = null;
- public ProgressCallback listener = null;
public ConflictResolverCallback resolver = null;
public void onNotify(ClientNotifyInformation notifyInfo)
@@ -516,12 +515,6 @@ public class SVNClient implements ISVNCl
notify.onNotify(notifyInfo);
}
- public void onProgress(ProgressEvent event)
- {
- if (listener != null)
- listener.onProgress(event);
- }
-
public ConflictResult resolve(ConflictDescriptor conflict)
throws SubversionException
{