From 471a8e373a462806318c59ca69fc24565bab90b8 Mon Sep 17 00:00:00 2001 From: Alexander Fedorov Date: Thu, 9 Jan 2025 11:31:36 +0300 Subject: [PATCH] [#129] Implement conflict resolver accessors Fixes #129 --- .../svjhl/ConflictResolutionAdapter.java | 40 +++++++++++++ .../ConflictResolutionCallbackAdapter.java | 58 +++++++++++++++++++ .../svnkit1_10/SvnKit1_10Connector.java | 16 +++-- 3 files changed, 108 insertions(+), 6 deletions(-) create mode 100644 bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/adapt/svjhl/ConflictResolutionAdapter.java create mode 100644 bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/adapt/svjhl/ConflictResolutionCallbackAdapter.java diff --git a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/adapt/svjhl/ConflictResolutionAdapter.java b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/adapt/svjhl/ConflictResolutionAdapter.java new file mode 100644 index 0000000..e8bbe93 --- /dev/null +++ b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/adapt/svjhl/ConflictResolutionAdapter.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023, 2025 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 org.apache.subversion.javahl.ConflictResult; +import org.eclipse.team.svn.core.connector.SVNConflictResolution; + +import ru.arsysop.svn.connector.internal.adapt.SvnNullableConstructor; + +public final class ConflictResolutionAdapter extends SvnNullableConstructor { + + public ConflictResolutionAdapter(SVNConflictResolution source) { + super(source); + } + + @Override + protected ConflictResult adapt(SVNConflictResolution source) { + return new ConflictResult(new ChoiceAdapter(source.choice).adapt(), source.mergedPath); + } + +} diff --git a/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/adapt/svjhl/ConflictResolutionCallbackAdapter.java b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/adapt/svjhl/ConflictResolutionCallbackAdapter.java new file mode 100644 index 0000000..2e08647 --- /dev/null +++ b/bundles/ru.arsysop.svn.connector.svnkit1_10/src/ru/arsysop/svn/connector/internal/adapt/svjhl/ConflictResolutionCallbackAdapter.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023, 2025 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 org.apache.subversion.javahl.ClientException; +import org.apache.subversion.javahl.ConflictDescriptor; +import org.apache.subversion.javahl.ConflictResult; +import org.apache.subversion.javahl.SubversionException; +import org.apache.subversion.javahl.callback.ConflictResolverCallback; +import org.eclipse.team.svn.core.connector.ISVNConflictResolutionCallback; +import org.eclipse.team.svn.core.connector.SVNConnectorException; + +import ru.arsysop.svn.connector.internal.adapt.SvnNullableConstructor; +import ru.arsysop.svn.connector.internal.adapt.jhlsv.ConflictDescriptorNullableAdapter; + +public final class ConflictResolutionCallbackAdapter +extends SvnNullableConstructor { + + public ConflictResolutionCallbackAdapter(ISVNConflictResolutionCallback source) { + super(source); + } + + @Override + protected ConflictResolverCallback adapt(ISVNConflictResolutionCallback source) { + return new ConflictResolverCallback() { + + public ConflictResult resolve(ConflictDescriptor descrip) throws SubversionException { + try { + return new ConflictResolutionAdapter( + source.resolve(new ConflictDescriptorNullableAdapter(descrip).adapt())).adapt(); + } catch (SVNConnectorException ex) { + throw ClientException.fromException(ex); + } + } + + }; + } + +} 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 2560fad..f5be623 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 @@ -78,6 +78,7 @@ import ru.arsysop.svn.connector.internal.adapt.svjhl.AdaptClientNotifyCallback; import ru.arsysop.svn.connector.internal.adapt.svjhl.AnnotationCallbackAdapter; import ru.arsysop.svn.connector.internal.adapt.svjhl.ChoiceAdapter; +import ru.arsysop.svn.connector.internal.adapt.svjhl.ConflictResolutionCallbackAdapter; import ru.arsysop.svn.connector.internal.adapt.svjhl.DepthAdapter; import ru.arsysop.svn.connector.internal.adapt.svjhl.DiffOptionsAdapter; import ru.arsysop.svn.connector.internal.adapt.svjhl.ImportFilerCallbackAdapter; @@ -92,7 +93,6 @@ import ru.arsysop.svn.connector.internal.adapt.svjhl.RevisionReverenceAdapter; import ru.arsysop.svn.connector.internal.adapt.svjhl.StatusCallbackAdapter; -//TODO final class SvnKit1_10Connector implements ISVNConnector { private final CallWatch watch; @@ -101,6 +101,7 @@ final class SvnKit1_10Connector implements ISVNConnector { private final List notifications = new ArrayList<>(); //FIXME: AF: not sure why do we need this private final List handlers = new ArrayList<>(); + private final List resolvers = new ArrayList<>(); SvnKit1_10Connector(String name) { SVNFileUtil.setSleepForTimestamp(false);// not time to relax @@ -198,15 +199,18 @@ public ISVNNotificationCallback getNotificationCallback() { @Override public void setConflictResolver(ISVNConflictResolutionCallback listener) { - System.out.println("SvnKit1_10Connector.setConflictResolver()"); - //TODO + Map parameters = new HashMap<>(); + parameters.put("listener", listener); + resolvers.add(listener); + watch.commandSafe(ISVNCallListener.SET_CONFLICT_RESOLVER, parameters, + p -> client.setConflictResolver(new ConflictResolutionCallbackAdapter(listener).adapt())); } @Override public ISVNConflictResolutionCallback getConflictResolver() { - System.out.println("SvnKit1_10Connector.getConflictResolver()"); - //TODO - return null; + return watch.querySafe(ISVNCallListener.GET_CONFLICT_RESOLVER, // + Collections.emptyMap(), // + p -> resolvers.stream().findAny().orElse(null)); } @Override