How to use a Conflict Handler to resolve Property conflicts

View: New views
6 Messages — Rating Filter:   Alert me  

How to use a Conflict Handler to resolve Property conflicts

by elsabio :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It seems relatively clear how a ConflictHandler callback deals with text conflicts.
However, I'm not having a great time using the same mechanism to resolve Property conflicts.
It is very easy to identify that this is a property conflict and the name of the property involved; what is not so obvious is how to obtain the (base, local, repository) values of that property at the time of the conflict and once obtained, how to resolve it with a new value for that property.

It does not seem that WCClient's doGetProperty() method delivers the goods here, and the property values don't seem to be available in the conflict description's mergeFiles (a mergeFiles.get{WC|Repository|Local|Base}PropertyValue(String propertyName) (etc.) would seem logical, but no!) or anywhere else - so I must be missing something obvious.

Could anyone give me a guide on what that embarrassing omission is please?

Thanks!

Re: How to use a Conflict Handler to resolve Property conflicts

by Alexander Sinyushkin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

The local value is provided in SVNMergeFileSet.getLocalFile() file,
the repository value is provided in SVNMergeFileSet.getRepositoryFile()
file,
and the base value can be obtained using SVNWCClient.doGetProperty()
passing SVNRevision.BASE.
If getLocalFile() returns null, it means the property is locally
deleted, if getRepositoryFile() returns null, it means
the property was deleted in the repository.

You can take a look at SVNCommandLineConflictHandler how it handles
property conflicts. Here's a prop conflicts
related snippet from its code.

            if (conflictDescription.isPropertyConflict()) {
                String message = "Conflict for property ''{0}''
discovered on ''{1}''.";
                message = MessageFormat.format(message, new Object[] {
conflictDescription.getPropertyName(),
                        path });
                mySVNEnvironment.getErr().println(message);
               
                if ((files.getLocalFile() == null &&
files.getRepositoryFile() != null) ||
                        (files.getLocalFile() != null &&
files.getRepositoryFile() == null)) {
                    if (files.getLocalFile() != null) {
                        String myVal =
SVNFileUtil.readFile(files.getLocalFile());
                        message = MessageFormat.format("They want to
delete the property, you want to change the value to ''{0}''.",
                                new Object[] { myVal });
                        mySVNEnvironment.getErr().println(message);
                    } else {
                        String reposVal =
SVNFileUtil.readFile(files.getRepositoryFile());
                        message = MessageFormat.format("They want to
change the property value to ''{0}'', you want to delete the property.",
                                new Object[] { reposVal });
                        mySVNEnvironment.getErr().println(message);
                    }
                }

----
Alexander Sinyushkin,
TMate Software,
http://svnkit.com/ - Java [Sub]Versioning Library!



elsabio wrote:

> It seems relatively clear how a ConflictHandler callback deals with text
> conflicts.
> However, I'm not having a great time using the same mechanism to resolve
> Property conflicts.
> It is very easy to identify that this is a property conflict and the name of
> the property involved; what is not so obvious is how to obtain the (base,
> local, repository) values of that property at the time of the conflict and
> once obtained, how to resolve it with a new value for that property.
>
> It does not seem that WCClient's doGetProperty() method delivers the goods
> here, and the property values don't seem to be available in the conflict
> description's mergeFiles (a
> mergeFiles.get{WC|Repository|Local|Base}PropertyValue(String propertyName)
> (etc.) would seem logical, but no!) or anywhere else - so I must be missing
> something obvious.
>
> Could anyone give me a guide on what that embarrassing omission is please?
>
> Thanks!

---------------------------------------------------------------------
To unsubscribe, e-mail: svnkit-users-unsubscribe@...
For additional commands, e-mail: svnkit-users-help@...


Re: How to use a Conflict Handler to resolve Property conflicts

by elsabio :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Alexander Sinyushkin wrote:
The local value is provided in SVNMergeFileSet.getLocalFile() file,
the repository value is provided in SVNMergeFileSet.getRepositoryFile()
file,
and the base value can be obtained using SVNWCClient.doGetProperty()
passing SVNRevision.BASE.
If getLocalFile() returns null, it means the property is locally
deleted, if getRepositoryFile() returns null, it means
the property was deleted in the repository.
Progress is now being made ... Thanks!

If I want to change the value of a property (rather than acceping one or other value, or maintaining the conflicting status quo, I notice that the getResultFile() method returns null, so is it appropriate to change the local or repository files and give a ConflictResult accordingly, or is there a specific mechanism for this?

Re: How to use a Conflict Handler to resolve Property conflicts

by Alexander Sinyushkin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Changing local or repository files will not make any affect
as those are temporary files just to provide values to the conflict
handler. You may only return appropriate SVNConflictChoice
from your handler.

----
Alexander Sinyushkin,
TMate Software,
http://svnkit.com/ - Java [Sub]Versioning Library!



elsabio wrote:

>
> Alexander Sinyushkin wrote:
>> The local value is provided in SVNMergeFileSet.getLocalFile() file,
>> the repository value is provided in SVNMergeFileSet.getRepositoryFile()
>> file,
>> and the base value can be obtained using SVNWCClient.doGetProperty()
>> passing SVNRevision.BASE.
>> If getLocalFile() returns null, it means the property is locally
>> deleted, if getRepositoryFile() returns null, it means
>> the property was deleted in the repository.
>>
>
> Progress is now being made ... Thanks!
>
> If I want to change the value of a property (rather than acceping one or
> other value, or maintaining the conflicting status quo, I notice that the
> getResultFile() method returns null, so is it appropriate to change the
> local or repository files and give a ConflictResult accordingly, or is there
> a specific mechanism for this?
>

---------------------------------------------------------------------
To unsubscribe, e-mail: svnkit-users-unsubscribe@...
For additional commands, e-mail: svnkit-users-help@...


Re: How to use a Conflict Handler to resolve Property conflicts

by elsabio :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Alexander Sinyushkin wrote:
Changing local or repository files will not make any affect
as those are temporary files just to provide values to the conflict
handler. You may only return appropriate SVNConflictChoice
from your handler.
So to be clear here: are you saying that I cannot resolve a Property conflict by editing the property value?  If I have a Text conflict, I may well want to edit the file, so it seems reasonable that I might want to edit a property value.

For example, maybe my local Instrument property has a value "Hurdy" and I'm trying to merge with a file which has an Instrument property of "Gurdy", are you saying that I cannot resolve this conflict by committing an Instrument Property of "HurdyGurdy" on that file?

Re: How to use a Conflict Handler to resolve Property conflicts

by Alexander Sinyushkin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm not saying you can not resolve the conflict, you can, but
with the help of the conflict handler you can only command which value
(local,repository,base)
must be chosen to resolve the conflict, or 'postpone' the conflict to
resolve it manually later. That is, editing a property
conflict during merge\update\whatever is not possible currently neither
with SVNKit, nor with SVN. But after merge\update\whatever
finishes, you can always edit the property manually as you wish.

----
Alexander Sinyushkin,
TMate Software,
http://svnkit.com/ - Java [Sub]Versioning Library!



elsabio wrote:

>
> Alexander Sinyushkin wrote:
>> Changing local or repository files will not make any affect
>> as those are temporary files just to provide values to the conflict
>> handler. You may only return appropriate SVNConflictChoice
>> from your handler.
>>
>
> So to be clear here: are you saying that I cannot resolve a Property
> conflict by editing the property value?  If I have a Text conflict, I may
> well want to edit the file, so it seems reasonable that I might want to edit
> a property value.
>
> For example, maybe my local Instrument property has a value "Hurdy" and I'm
> trying to merge with a file which has an Instrument property of "Gurdy", are
> you saying that I cannot resolve this conflict by committing an Instrument
> Property of "HurdyGurdy" on that file?

---------------------------------------------------------------------
To unsubscribe, e-mail: svnkit-users-unsubscribe@...
For additional commands, e-mail: svnkit-users-help@...