Hi subclipse developers,
Subversion has a encoding problem when file charset is different from
system charset. For example, default charset are Shift_JIS on Japanese
MS-Windows. If I has the file charset is EUC-JP, remote resources
characters are broken in compare view. See attached irregal_encoding.jpg.
To resolve this problem, set same charset of local resource to SVN's
resource. I attached the patch to fix this problem. After apply patch,
I could obtain correct compare view like attached
correct_encoding.jpg.
Please fix the problem.
thanks,
Takashi Okamoto
Index: src/org/tigris/subversion/subclipse/ui/compare/SVNLocalCompareInput.java
===================================================================
--- src/org/tigris/subversion/subclipse/ui/compare/SVNLocalCompareInput.java (revision 1702)
+++ src/org/tigris/subversion/subclipse/ui/compare/SVNLocalCompareInput.java (working copy)
@@ -22,6 +22,7 @@
import org.eclipse.compare.ResourceNode;
import org.eclipse.compare.structuremergeviewer.Differencer;
import org.eclipse.compare.structuremergeviewer.IStructureComparator;
+import org.eclipse.core.resources.IEncodedStorage;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -39,6 +40,7 @@
import org.tigris.subversion.subclipse.core.SVNException;
import org.tigris.subversion.subclipse.ui.Policy;
import org.tigris.subversion.subclipse.ui.SVNUIPlugin;
+import org.tigris.subversion.subclipse.ui.compare.internal.Utilities;
import org.tigris.subversion.subclipse.ui.internal.Utils;
import org.tigris.subversion.svnclientadapter.SVNRevision;
@@ -208,7 +210,19 @@
protected Object prepareInput(IProgressMonitor monitor){
initLabels();
ITypedElement left = new SVNLocalResourceNode(resource);
- ITypedElement right = new ResourceEditionNode(remoteResource);
+ ResourceEditionNode right = new ResourceEditionNode(remoteResource);
+ if(left.getType()==ITypedElement.FOLDER_TYPE){
+ right.setLocalResource((SVNLocalResourceNode) left);
+ }
+
+
+ String localCharset = Utilities.getCharset(resource.getIResource());
+ try {
+ right.setCharset(localCharset);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+
if (SVNRevision.BASE.equals(remoteRevision)) {
return new StatusAwareDifferencer().findDifferences(false, monitor,null,null,left,right);
}
Index: src/org/tigris/subversion/subclipse/ui/compare/ResourceEditionNode.java
===================================================================
--- src/org/tigris/subversion/subclipse/ui/compare/ResourceEditionNode.java (revision 1702)
+++ src/org/tigris/subversion/subclipse/ui/compare/ResourceEditionNode.java (working copy)
@@ -15,6 +15,7 @@
import java.lang.reflect.InvocationTargetException;
import org.eclipse.compare.CompareUI;
+import org.eclipse.compare.IEncodedStreamContentAccessor;
import org.eclipse.compare.IStreamContentAccessor;
import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.structuremergeviewer.IStructureComparator;
@@ -23,8 +24,10 @@
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.graphics.Image;
import org.eclipse.team.core.TeamException;
+import org.tigris.subversion.subclipse.core.ISVNLocalResource;
import org.tigris.subversion.subclipse.core.ISVNRemoteResource;
import org.tigris.subversion.subclipse.ui.SVNUIPlugin;
+import org.tigris.subversion.subclipse.ui.compare.SVNLocalCompareInput.SVNLocalResourceNode;
/**
* A class for comparing ISVNRemoteResource objects
*
@@ -41,9 +44,12 @@
implements
IStructureComparator,
ITypedElement,
- IStreamContentAccessor {
+ IStreamContentAccessor,
+ IEncodedStreamContentAccessor {
private ISVNRemoteResource resource;
private ResourceEditionNode[] children;
+ private SVNLocalResourceNode localResource = null;
+ private String charset = null;
/**
* Creates a new ResourceEditionNode on the given resource edition.
*/
@@ -90,6 +96,11 @@
for (int i = 0; i < members.length; i++) {
children[i] = new ResourceEditionNode(
members[i]);
+ SVNLocalResourceNode localNode = matchLocalResource((ISVNRemoteResource) members[i]);
+ if (localNode != null) {
+ children[i]
+ .setLocalResource(localNode);
+ }
}
} catch (TeamException e) {
throw new InvocationTargetException(e);
@@ -175,4 +186,36 @@
public int hashCode() {
return getName().hashCode();
}
+
+ public String getCharset() throws CoreException {
+ return charset;
+ }
+
+ public void setCharset(String charset) throws CoreException {
+ this.charset = charset;
+ }
+
+ public void setLocalResource(SVNLocalResourceNode localResource){
+ this.localResource = localResource;
+ }
+
+ private SVNLocalResourceNode matchLocalResource(ISVNRemoteResource remoteNode){
+ Object[] lrn = localResource.getChildren();
+ String remotePath=remoteNode.getRepositoryRelativePath();
+ remotePath = remotePath.substring(remotePath.indexOf("/",1));
+ for(int i=0;i<lrn.length;i++){
+ String localPath=((SVNLocalResourceNode)lrn[i]).getResource().getFullPath().toString();
+ localPath = localPath.substring(localPath.indexOf("/",1));
+ if(localPath.equals(remotePath)){
+ try {
+ setCharset(((SVNLocalResourceNode)lrn[i]).getCharset());
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ return (SVNLocalResourceNode)lrn[i];
+ }
+ }
+ return null;
+ }
+
}
\ No newline at end of file
Received on Thu Nov 17 00:40:24 2005