blob: 09a6996ac2919f5ade76cfa72c9975eeb55db248 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/*******************************************************************************
* Copyright (C) 2010, Dariusz Luksza <dariusz@luksza.org>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.eclipse.egit.ui.internal.synchronize.compare;
import static org.eclipse.egit.ui.internal.CompareUtils.getFileCachedRevisionTypedElement;
import org.eclipse.compare.ITypedElement;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Path;
import org.eclipse.egit.ui.internal.LocalResourceTypedElement;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.team.ui.mapping.ISynchronizationCompareInput;
/**
* Specific implementation of {@link ISynchronizationCompareInput} for showing
* locally changed files
*/
public class GitLocalCompareInput extends GitCompareInput {
private static final IWorkspaceRoot ROOT = ResourcesPlugin.getWorkspace().getRoot();
/**
* Creates {@link GitLocalCompareInput}
*
* @param repo
* repository that is connected with this object
* @param ancestorDataSource
* data that should be use to obtain common ancestor object data
* @param baseDataSource
* data that should be use to obtain base object data
* @param remoteDataSource
* data that should be used to obtain remote object data
* @param gitPath
* repository relative path of object
*/
public GitLocalCompareInput(Repository repo,
ComparisonDataSource ancestorDataSource,
ComparisonDataSource baseDataSource,
ComparisonDataSource remoteDataSource, String gitPath) {
super(repo, ancestorDataSource, baseDataSource, remoteDataSource,
gitPath);
}
public ITypedElement getLeft() {
String absoluteFilePath = repo.getWorkTree().getAbsolutePath()
+ "/" + gitPath; //$NON-NLS-1$
IFile file = ROOT.getFileForLocation(new Path(absoluteFilePath));
if (file == null)
return new LocalNonWorkspaceTypedElement(absoluteFilePath);
return new LocalResourceTypedElement(file);
}
public ITypedElement getRight() {
return getFileCachedRevisionTypedElement(gitPath, repo);
}
@Override
public ITypedElement getAncestor() {
return getRight();
}
}
|