1 11 package org.eclipse.team.internal.ccvs.core; 12 13 import org.eclipse.core.resources.IFile; 14 import org.eclipse.core.resources.IResource; 15 import org.eclipse.team.core.variants.IResourceVariant; 16 import org.eclipse.team.core.variants.IResourceVariantComparator; 17 import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; 18 import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; 19 20 23 public class CVSRevisionNumberCompareCriteria implements IResourceVariantComparator { 24 25 private boolean isThreeWay; 26 27 public CVSRevisionNumberCompareCriteria(boolean isThreeWay) { 28 this.isThreeWay = isThreeWay; 29 } 30 31 34 protected boolean compare(ICVSRemoteResource e1, ICVSRemoteResource e2) { 35 if(e1.isContainer()) { 36 if(e2.isContainer()) { 37 return true; 38 } 39 return false; 40 } 41 return e1.equals(e2); 42 } 43 44 47 protected boolean compare(IResource e1, ICVSRemoteResource e2) { 48 if(e1.getType() != IResource.FILE) { 49 if(e2.isContainer()) { 50 return true; 51 } 52 return false; 53 } 54 ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile)e1); 55 try { 56 byte[] syncBytes1 = cvsFile.getSyncBytes(); 57 byte[] syncBytes2 = ((ICVSRemoteFile)e2).getSyncBytes(); 58 59 if(syncBytes1 != null) { 60 if(ResourceSyncInfo.isDeletion(syncBytes1) || ResourceSyncInfo.isMerge(syncBytes1) || cvsFile.isModified(null)) { 61 return false; 62 } 63 return ResourceSyncInfo.getRevision(syncBytes1).equals(ResourceSyncInfo.getRevision(syncBytes2)); 64 } 65 return false; 66 } catch(CVSException e) { 67 CVSProviderPlugin.log(e); 68 return false; 69 } 70 } 71 72 75 public boolean compare(IResource local, IResourceVariant remote) { 76 return compare(local, (ICVSRemoteResource)remote); 77 } 78 79 82 public boolean compare(IResourceVariant base, IResourceVariant remote) { 83 return compare((ICVSRemoteResource)base, (ICVSRemoteResource)remote); 84 } 85 86 89 public boolean isThreeWay() { 90 return isThreeWay; 91 } 92 } 93 | Popular Tags |