diff --git a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/adapt/svjhl/AdaptClientNotifyCallback.java b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/adapt/svjhl/AdaptClientNotifyCallback.java index 46f4826..b6fe7e2 100644 --- a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/adapt/svjhl/AdaptClientNotifyCallback.java +++ b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/adapt/svjhl/AdaptClientNotifyCallback.java @@ -35,10 +35,6 @@ public AdaptClientNotifyCallback(ISVNNotificationCallback notify) { callback = Objects.requireNonNull(notify); } - public ISVNNotificationCallback callback() { - return callback; - } - @Override public void onNotify(org.apache.subversion.javahl.ClientNotifyInformation info) { callback.notify(new ClientNotifyInformationAdapter(info).adapt()); diff --git a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/adapt/svjhl/AdaptMessageReceiver.java b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/adapt/svjhl/AdaptMessageReceiver.java new file mode 100644 index 0000000..70fb628 --- /dev/null +++ b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/adapt/svjhl/AdaptMessageReceiver.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023, 2024 ArSysOp + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + */ + +package ru.arsysop.svn.connector.internal.adapt.svjhl; + +import java.util.Objects; + +import org.apache.subversion.javahl.ISVNRepos.MessageReceiver; +import org.eclipse.team.svn.core.connector.ISVNRepositoryMessageCallback; + +public final class AdaptMessageReceiver implements MessageReceiver { + + private final ISVNRepositoryMessageCallback callback; + + public AdaptMessageReceiver(ISVNRepositoryMessageCallback notify) { + callback = Objects.requireNonNull(notify); + } + + @Override + public void receiveMessageLine(String message) { + callback.nextMessage(message); + + } +} \ No newline at end of file diff --git a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/adapt/svjhl/AdaptReposNotifyCallback.java b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/adapt/svjhl/AdaptReposNotifyCallback.java index 7c11f0c..40b60fc 100644 --- a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/adapt/svjhl/AdaptReposNotifyCallback.java +++ b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/adapt/svjhl/AdaptReposNotifyCallback.java @@ -36,10 +36,6 @@ public AdaptReposNotifyCallback(ISVNRepositoryNotificationCallback notify) { callback = Objects.requireNonNull(notify); } - public ISVNRepositoryNotificationCallback callback() { - return callback; - } - @Override public void onNotify(ReposNotifyInformation info) { callback.notify(new ReposNotifyInformationAdapter(info).adapt()); diff --git a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/CallWatch.java b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/CallWatch.java index cefdabc..b8f5d17 100644 --- a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/CallWatch.java +++ b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/CallWatch.java @@ -72,10 +72,25 @@ V queryFast(String method, Map parameters, QueryFast quer } } - void commandSafe(String method, Map parameters, CommandSafe command) { + V queryLong(String method, Map parameters, ProgressCallback progress, QueryLong query) + throws SVNConnectorException { asked(method, parameters); - command.command(parameters); - succeeded(method, parameters, null);//oh, no! we need to change this interface + try { + notifications.add(progress); + progress.start(); + watchdog.add(progress); + V value = query.query(parameters); + succeeded(method, parameters, null);//oh, no! we need to change this interface + return value; + } catch (ClientException ex) { + SVNConnectorException wrap = wrap(ex); + failed(method, parameters, wrap); + throw wrap; + } finally { + progress.finish(); + watchdog.remove(progress); + notifications.remove(progress); + } } void commandFast(String method, Map parameters, CommandFast command) throws SVNConnectorException { @@ -90,14 +105,14 @@ void commandFast(String method, Map parameters, CommandFast comm } } - void operation(String method, Map parameters, ProgressCallback progress, Operation operation) + void commandLong(String method, Map parameters, ProgressCallback progress, CommandLong command) throws SVNConnectorException { asked(method, parameters); try { notifications.add(progress); progress.start(); watchdog.add(progress); - operation.operation(parameters); + command.command(parameters); succeeded(method, parameters, null);//oh, no! we need to change this interface } catch (ClientException ex) { SVNConnectorException wrap = wrap(ex); @@ -110,6 +125,12 @@ void operation(String method, Map parameters, ProgressCallback p } } + void commandSafe(String method, Map parameters, CommandSafe command) { + asked(method, parameters); + command.command(parameters); + succeeded(method, parameters, null);//oh, no! we need to change this interface + } + private void asked(String method, Map parameters) { for (ISVNCallListener listener : listeners) { listener.asked(method, parameters); diff --git a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/Operation.java b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/CommandLong.java similarity index 90% rename from bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/Operation.java rename to bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/CommandLong.java index 084fcad..3ee2813 100644 --- a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/Operation.java +++ b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/CommandLong.java @@ -26,8 +26,8 @@ import org.apache.subversion.javahl.ClientException; @FunctionalInterface -interface Operation { +interface CommandLong { - void operation(Map parameters) throws ClientException; + void command(Map parameters) throws ClientException; } diff --git a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/QueryLong.java b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/QueryLong.java new file mode 100644 index 0000000..a015755 --- /dev/null +++ b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/QueryLong.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023, 2024 ArSysOp + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + */ + +package ru.arsysop.svn.connector.internal.svnkit1_10; + +import java.util.Map; + +import org.apache.subversion.javahl.ClientException; + +@FunctionalInterface +public interface QueryLong { + + V query(Map parameters) throws ClientException; + +} diff --git a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/SvnKit1_10Connector.java b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/SvnKit1_10Connector.java index 9273ee0..cc8c73e 100644 --- a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/SvnKit1_10Connector.java +++ b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/SvnKit1_10Connector.java @@ -410,7 +410,7 @@ public void getInfo(SVNEntryRevisionReference reference, SVNDepth depth, long op parameters.put("changeLists", changeLists); //$NON-NLS-1$ parameters.put("cb", cb); //$NON-NLS-1$ parameters.put("monitor", monitor); //$NON-NLS-1$ - watch.operation(ISVNCallListener.GET_INFO, parameters, callback(monitor), + watch.commandLong(ISVNCallListener.GET_INFO, parameters, callback(monitor), p -> client.info2(// reference.path, // new RevisionAdapter(reference.revision).adapt(), // @@ -507,7 +507,7 @@ public void listEntries(SVNEntryRevisionReference reference, SVNDepth depth, int parameters.put("options", Long.valueOf(options)); //$NON-NLS-1$ parameters.put("cb", cb); //$NON-NLS-1$ parameters.put("monitor", monitor); //$NON-NLS-1$ - watch.operation(ISVNCallListener.LIST, parameters, callback(monitor), + watch.commandLong(ISVNCallListener.LIST, parameters, callback(monitor), p -> listEntries(reference, depth, fields, options, cb)); } @@ -552,7 +552,7 @@ public void listProperties(SVNEntryRevisionReference reference, SVNDepth depth, parameters.put("changeLists", changeLists); //$NON-NLS-1$ parameters.put("callback", callback); //$NON-NLS-1$ parameters.put("monitor", monitor); //$NON-NLS-1$ - watch.operation(ISVNCallListener.GET_PROPERTIES, parameters, callback(monitor), + watch.commandLong(ISVNCallListener.GET_PROPERTIES, parameters, callback(monitor), p -> listProperties(reference, depth, changeLists, options, callback)); } diff --git a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/SvnKit1_10Manager.java b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/SvnKit1_10Manager.java index b761aec..4a29a85 100644 --- a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/SvnKit1_10Manager.java +++ b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/svnkit1_10/SvnKit1_10Manager.java @@ -28,6 +28,7 @@ import java.util.Map; import java.util.Optional; +import org.apache.subversion.javahl.ClientException; import org.apache.subversion.javahl.ISVNRepos; import org.apache.subversion.javahl.SVNRepos; import org.eclipse.team.svn.core.connector.ISVNCallListener; @@ -44,6 +45,7 @@ import org.eclipse.team.svn.core.connector.SVNRevisionRange; import org.eclipse.team.svn.core.utility.SVNRepositoryNotificationComposite; +import ru.arsysop.svn.connector.internal.adapt.svjhl.AdaptMessageReceiver; import ru.arsysop.svn.connector.internal.adapt.svjhl.AdaptReposNotifyCallback; import ru.arsysop.svn.connector.internal.adapt.svjhl.RevisionAdapter; @@ -67,13 +69,12 @@ public void create(String repositoryPath, RepositoryKind repositoryType, String parameters.put("configPath", configPath); //$NON-NLS-1$ parameters.put("options", options); //$NON-NLS-1$ parameters.put("monitor", monitor); //$NON-NLS-1$ - watch.operation(ISVNCallListener.CREATE, parameters, callback(monitor), - p -> admin.create(// - new File(repositoryPath), // - (options & Options.DISABLE_FSYNC_COMMIT) != 0, // - (options & Options.KEEP_LOG) != 0, // - Optional.ofNullable(configPath).map(File::new).orElse(null), - Optional.ofNullable(repositoryType).orElse(ISVNManager.RepositoryKind.FSFS).id)); + watch.commandLong(ISVNCallListener.CREATE, parameters, callback(monitor), p -> admin.create(// + new File(repositoryPath), // + (options & Options.DISABLE_FSYNC_COMMIT) != 0, // + (options & Options.KEEP_LOG) != 0, // + Optional.ofNullable(configPath).map(File::new).orElse(null), + Optional.ofNullable(repositoryType).orElse(ISVNManager.RepositoryKind.FSFS).id)); } @Override @@ -82,7 +83,7 @@ public void deltify(String path, SVNRevisionRange range, ISVNProgressMonitor mon parameters.put("path", path); //$NON-NLS-1$ parameters.put("range", range); //$NON-NLS-1$ parameters.put("monitor", monitor); //$NON-NLS-1$ - watch.operation(ISVNCallListener.DELTIFY, parameters, callback(monitor), p -> admin.deltify(// + watch.commandLong(ISVNCallListener.DELTIFY, parameters, callback(monitor), p -> admin.deltify(// new File(path), // new RevisionAdapter(range.from).adapt(), // new RevisionAdapter(range.to).adapt())); @@ -96,11 +97,10 @@ public void hotCopy(String path, String targetPath, long options, ISVNProgressMo parameters.put("targetPath", targetPath); //$NON-NLS-1$ parameters.put("options", options); //$NON-NLS-1$ parameters.put("monitor", monitor); //$NON-NLS-1$ - watch.operation(ISVNCallListener.HOT_COPY, parameters, callback(monitor), - p -> admin.hotcopy(// - new File(path), // - new File(targetPath), // - (options & Options.CLEAN_LOGS) != 0)); + watch.commandLong(ISVNCallListener.HOT_COPY, parameters, callback(monitor), p -> admin.hotcopy(// + new File(path), // + new File(targetPath), // + (options & Options.CLEAN_LOGS) != 0)); } @Override @@ -114,41 +114,83 @@ public void dump(String path, OutputStream dataOut, SVNRevisionRange range, parameters.put("callback", callback); //$NON-NLS-1$ parameters.put("options", options); //$NON-NLS-1$ parameters.put("monitor", monitor); //$NON-NLS-1$ - watch.operation(ISVNCallListener.DUMP, parameters, callback(monitor), - p -> admin.dump(// - new File(path), // - dataOut, // - new RevisionAdapter(range.from).adapt(), // - new RevisionAdapter(range.to).adapt(), // - (options & Options.INCREMENTAL) != 0, // - (options & Options.USE_DELTAS) != 0, // - new AdaptReposNotifyCallback(composite))); + watch.commandLong(ISVNCallListener.DUMP, parameters, callback(monitor), p -> admin.dump(// + new File(path), // + dataOut, // + new RevisionAdapter(range.from).adapt(), // + new RevisionAdapter(range.to).adapt(), // + (options & Options.INCREMENTAL) != 0, // + (options & Options.USE_DELTAS) != 0, // + new AdaptReposNotifyCallback(composite)// + )); } @Override public void listDBLogs(String path, ISVNRepositoryMessageCallback receiver, long options, ISVNProgressMonitor monitor) throws SVNConnectorException { - //TODO + Map parameters = new HashMap<>(); + parameters.put("path", path); //$NON-NLS-1$ + parameters.put("receiver", receiver); //$NON-NLS-1$ + parameters.put("options", options); //$NON-NLS-1$ + parameters.put("monitor", monitor); //$NON-NLS-1$ + watch.commandLong(ISVNCallListener.LIST_DB_LOGS, parameters, callback(monitor), + p -> listBDLogs(path, receiver, options)); + } + + private void listBDLogs(String path, ISVNRepositoryMessageCallback receiver, long options) throws ClientException { + if ((options & Options.UNUSED_ONLY) != 0) { + admin.listUnusedDBLogs(new File(path), new AdaptMessageReceiver(receiver)); + } else { + admin.listDBLogs(new File(path), new AdaptMessageReceiver(receiver)); + } } @Override public void load(String path, InputStream dataInput, SVNRevisionRange range, String relativePath, ISVNRepositoryNotificationCallback callback, long options, ISVNProgressMonitor monitor) throws SVNConnectorException { - //TODO + Map parameters = new HashMap<>(); + parameters.put("path", path); //$NON-NLS-1$ + parameters.put("dataInput", dataInput); //$NON-NLS-1$ + parameters.put("range", range); //$NON-NLS-1$ + parameters.put("relativePath", relativePath); //$NON-NLS-1$ + parameters.put("callback", callback); //$NON-NLS-1$ + parameters.put("options", options); //$NON-NLS-1$ + parameters.put("monitor", monitor); //$NON-NLS-1$ + watch.commandLong(ISVNCallListener.LOAD, parameters, callback(monitor), p -> admin.load(// + new File(path), // + dataInput, // + new RevisionAdapter(range.from).adapt(), // + new RevisionAdapter(range.to).adapt(), // + (options & Options.IGNORE_UUID) != 0, // + (options & Options.FORCE_UUID) != 0, // + (options & Options.USE_PRECOMMIT_HOOK) != 0, // + (options & Options.USE_POSTCOMMIT_HOOK) != 0, // + relativePath, // + new AdaptReposNotifyCallback(composite)// + )); } @Override public void listTransactions(String path, ISVNRepositoryMessageCallback receiver, ISVNProgressMonitor monitor) throws SVNConnectorException { - //TODO + Map parameters = new HashMap<>(); + parameters.put("path", path); //$NON-NLS-1$ + parameters.put("receiver", receiver); //$NON-NLS-1$ + parameters.put("monitor", monitor); //$NON-NLS-1$ + watch.commandLong(ISVNCallListener.LIST_TRANSACTIONS, parameters, callback(monitor), + p -> admin.lstxns(new File(path), new AdaptMessageReceiver(receiver))); } @Override public long recover(String path, ISVNRepositoryNotificationCallback callback, ISVNProgressMonitor monitor) throws SVNConnectorException { - //TODO - return 0; + Map parameters = new HashMap<>(); + parameters.put("path", path); //$NON-NLS-1$ + parameters.put("callback", callback); //$NON-NLS-1$ + parameters.put("monitor", monitor); //$NON-NLS-1$ + return watch.queryLong(ISVNCallListener.RECOVER, parameters, callback(monitor), + p -> admin.recover(new File(path), new AdaptReposNotifyCallback(composite))); } @Override