Lines 12-19
Link Here
|
12 |
|
12 |
|
13 |
import java.util.*; |
13 |
import java.util.*; |
14 |
|
14 |
|
15 |
import org.eclipse.compare.internal.core.patch.*; |
15 |
import org.eclipse.compare.internal.core.patch.DiffProject; |
16 |
import org.eclipse.compare.internal.patch.*; |
16 |
import org.eclipse.compare.internal.core.patch.FilePatch2; |
|
|
17 |
import org.eclipse.compare.internal.patch.PatchProjectDiffNode; |
18 |
import org.eclipse.compare.internal.patch.WorkspacePatcher; |
17 |
import org.eclipse.compare.structuremergeviewer.IDiffElement; |
19 |
import org.eclipse.compare.structuremergeviewer.IDiffElement; |
18 |
import org.eclipse.core.resources.*; |
20 |
import org.eclipse.core.resources.*; |
19 |
import org.eclipse.core.runtime.CoreException; |
21 |
import org.eclipse.core.runtime.CoreException; |
Lines 53-81
Link Here
|
53 |
IResourceVariant variant = null; |
55 |
IResourceVariant variant = null; |
54 |
if (resource.getType() == IResource.FILE) { |
56 |
if (resource.getType() == IResource.FILE) { |
55 |
for (int i = 0; i < diffs.length; i++) { |
57 |
for (int i = 0; i < diffs.length; i++) { |
56 |
if (diffs[i] instanceof FilePatch2) { |
58 |
if (resource.equals(PatchModelProvider.getFile(diffs[i], getPatcher()))) { |
57 |
DiffProject diffProject = (diffs[i]).getProject(); |
59 |
// null as 'variant' for deletions |
58 |
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(diffProject.getName()); |
60 |
if (diffs[i].getDiffType(patcher.isReversed()) != FilePatch2.DELETION) |
59 |
IFile file = project.getFile(diffs[i].getPath(getPatcher().isReversed())); |
61 |
variant = new PatchedFileVariant(getPatcher(), diffs[i]); |
60 |
if (file.equals(resource)) { |
62 |
IResourceVariant base = resource.exists() ? new LocalResourceVariant(resource) : null; |
61 |
// null as 'variant' for deletions |
63 |
SyncInfo info = new SyncInfo(resource, base, variant, getResourceComparator()) { |
62 |
if (diffs[i].getDiffType(patcher.isReversed()) != FilePatch2.DELETION) |
64 |
protected int calculateKind() throws TeamException { |
63 |
variant = new PatchedFileVariant(getPatcher(), diffs[i]); |
65 |
// TODO: this will work only for files, what about excluding individual hunks? |
64 |
IResourceVariant base = resource.exists() ? new LocalResourceVariant(resource) : null; |
66 |
if (!getPatcher().isEnabled(PatchModelProvider.getPatchObject(getLocal(), patcher))) |
65 |
SyncInfo info = new SyncInfo(resource, base, variant, getResourceComparator()) { |
67 |
return IN_SYNC; |
66 |
protected int calculateKind() throws TeamException { |
68 |
if (getRemote() != null |
67 |
// TODO: this will work only for files, what about excluding individual hunks? |
69 |
&& getPatcher().getDiffResult(((PatchedFileVariant)getRemote()).getDiff()).containsProblems()) |
68 |
if (!getPatcher().isEnabled(PatchModelProvider.getPatchObject(getLocal(), patcher))) |
70 |
return CONFLICTING; |
69 |
return IN_SYNC; |
71 |
return super.calculateKind(); |
70 |
if (getRemote() != null |
72 |
} |
71 |
&& getPatcher().getDiffResult(((PatchedFileVariant)getRemote()).getDiff()).containsProblems()) |
73 |
}; |
72 |
return CONFLICTING; |
74 |
info.init(); |
73 |
return super.calculateKind(); |
75 |
return info; |
74 |
} |
|
|
75 |
}; |
76 |
info.init(); |
77 |
return info; |
78 |
} |
79 |
} |
76 |
} |
80 |
} |
77 |
} |
81 |
} |
78 |
} |
Lines 85-90
Link Here
|
85 |
} |
82 |
} |
86 |
} |
83 |
} |
87 |
|
84 |
|
|
|
85 |
|
86 |
|
88 |
public boolean isSupervised(IResource resource) throws TeamException { |
87 |
public boolean isSupervised(IResource resource) throws TeamException { |
89 |
// TODO Auto-generated method stub |
88 |
// TODO Auto-generated method stub |
90 |
System.out.println(">> [true] isSupervised: " + resource.getName()); //$NON-NLS-1$ |
89 |
System.out.println(">> [true] isSupervised: " + resource.getName()); //$NON-NLS-1$ |
Lines 92-98
Link Here
|
92 |
} |
91 |
} |
93 |
|
92 |
|
94 |
public IResource[] members(IResource resource) throws TeamException { |
93 |
public IResource[] members(IResource resource) throws TeamException { |
95 |
FilePatch2[] diffs = getPatcher().getDiffs(); |
|
|
96 |
try { |
94 |
try { |
97 |
if(resource.getType() == IResource.FILE) |
95 |
if(resource.getType() == IResource.FILE) |
98 |
// file has no members |
96 |
// file has no members |
Lines 103-116
Link Here
|
103 |
List existingChildren = new ArrayList(Arrays.asList(container.members())); |
101 |
List existingChildren = new ArrayList(Arrays.asList(container.members())); |
104 |
|
102 |
|
105 |
// patch members, subscriber location |
103 |
// patch members, subscriber location |
|
|
104 |
FilePatch2[] diffs = getPatcher().getDiffs(); |
106 |
for (int i = 0; i < diffs.length; i++) { |
105 |
for (int i = 0; i < diffs.length; i++) { |
107 |
DiffProject diffProject = diffs[i].getProject(); |
106 |
IResource file = PatchModelProvider.getFile(diffs[i], getPatcher()); |
108 |
IProject project = container.getProject(); |
107 |
if (!container.exists(file.getProjectRelativePath())) { |
109 |
if (project.getName().equals(diffProject.getName())) { |
108 |
existingChildren.add(file); |
110 |
IResource file = project.getFile(diffs[i].getPath(getPatcher().isReversed())); |
|
|
111 |
if (!existingChildren.contains(file)) { |
112 |
existingChildren.add(file); |
113 |
} |
114 |
} |
109 |
} |
115 |
} |
110 |
} |
116 |
return (IResource[]) existingChildren.toArray(new IResource[existingChildren.size()]); |
111 |
return (IResource[]) existingChildren.toArray(new IResource[existingChildren.size()]); |
Lines 131-149
Link Here
|
131 |
} |
126 |
} |
132 |
|
127 |
|
133 |
public IResource[] roots() { |
128 |
public IResource[] roots() { |
134 |
IDiffElement[] children = PatchWorkspace.getInstance().getChildren(); |
|
|
135 |
Set roots = new HashSet(); |
129 |
Set roots = new HashSet(); |
136 |
for (int i = 0; i < children.length; i++) { |
130 |
if (getPatcher().isWorkspacePatch()) { |
137 |
if (getPatcher().isWorkspacePatch()) { |
131 |
IDiffElement[] children = PatchWorkspace.getInstance().getChildren(); |
|
|
132 |
for (int i = 0; i < children.length; i++) { |
138 |
// return array of projects from the patch |
133 |
// return array of projects from the patch |
139 |
DiffProject diffProject = ((PatchProjectDiffNode)children[i]).getDiffProject(); |
134 |
DiffProject diffProject = ((PatchProjectDiffNode)children[i]).getDiffProject(); |
140 |
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(diffProject.getName()); |
135 |
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(diffProject.getName()); |
141 |
roots.add(project); |
136 |
roots.add(project); |
142 |
} else { |
|
|
143 |
FileDiffResult diffResult = ((PatchFileDiffNode)children[i]).getDiffResult(); |
144 |
IFile file = ((WorkspaceFileDiffResult)diffResult).getTargetFile(); |
145 |
roots.add(file); |
146 |
} |
137 |
} |
|
|
138 |
} else { |
139 |
roots.add(getPatcher().getTarget()); |
147 |
} |
140 |
} |
148 |
return (IResource[]) roots.toArray(new IResource[0]); |
141 |
return (IResource[]) roots.toArray(new IResource[0]); |
149 |
} |
142 |
} |