Skip to content

Commit

Permalink
[#129] Implement conflict resolver accessors
Browse files Browse the repository at this point in the history
Fixes #129
  • Loading branch information
ruspl-afed committed Jan 9, 2025
1 parent 57a2137 commit 33d7c2e
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -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<SVNConflictResolution, ConflictResult> {

public ConflictResolutionAdapter(SVNConflictResolution source) {
super(source);
}

@Override
protected ConflictResult adapt(SVNConflictResolution source) {
return new ConflictResult(new ChoiceAdapter(source.choice).adapt(), source.mergedPath);
}

}
Original file line number Diff line number Diff line change
@@ -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<ISVNConflictResolutionCallback, ConflictResolverCallback> {

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);
}
}

};
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -101,6 +101,7 @@ final class SvnKit1_10Connector implements ISVNConnector {
private final List<ISVNNotificationCallback> notifications = new ArrayList<>();
//FIXME: AF: not sure why do we need this
private final List<ISVNConfigurationEventHandler> handlers = new ArrayList<>();
private final List<ISVNConflictResolutionCallback> resolvers = new ArrayList<>();

SvnKit1_10Connector(String name) {
SVNFileUtil.setSleepForTimestamp(false);// not time to relax
Expand Down Expand Up @@ -198,15 +199,19 @@ public ISVNNotificationCallback getNotificationCallback() {

@Override
public void setConflictResolver(ISVNConflictResolutionCallback listener) {
System.out.println("SvnKit1_10Connector.setConflictResolver()");
//TODO
Map<String, Object> parameters = new HashMap<>();
parameters.put("listener", listener);
resolvers.add(listener);
final ISVNConflictResolutionCallback callback = listener;
watch.commandSafe(ISVNCallListener.SET_CONFLICT_RESOLVER, parameters,
p -> client.setConflictResolver(new ConflictResolutionCallbackAdapter(callback).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
Expand Down

0 comments on commit 33d7c2e

Please sign in to comment.