diff options
author | zkoppany | 2011-01-18 14:11:41 +0000 |
---|---|---|
committer | Chris Aniszczyk | 2011-01-19 08:09:11 +0000 |
commit | ce7037c0aa77f2cad1bae78f3f1dad7969c0212c (patch) | |
tree | d1301163398d8fd67ea56a37689afc0d19aa6e0e | |
parent | 27cbe0b50ac8fd91d161bd10caea009c134c9672 (diff) | |
download | egit-ce7037c0.tar.gz egit-ce7037c0.tar.xz egit-ce7037c0.zip |
Synchronize View Performance Enhancement
The results of GitResourceVariantTree.fetchVariant() seams to be unused
by Team Synchronization framework therefore it can return null.
This change adds huge performance benefit for synchronization since we
don't travel on all trees searching for changed variants.
Bug: 323839
Change-Id: I6b030af13ba092855ef68e5a6087bb357fdb7bb2
Signed-off-by: Zsolt Koppany <zsolt.koppany@intland.com>
Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
-rw-r--r-- | org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTree.java | 108 |
1 files changed, 0 insertions, 108 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTree.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTree.java index 3cbbaadbaf..5003b1bfdb 100644 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTree.java +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTree.java @@ -11,30 +11,17 @@ *******************************************************************************/ package org.eclipse.egit.core.synchronize; -import static org.eclipse.jgit.lib.ObjectId.zeroId; - import java.io.IOException; import java.util.HashSet; import java.util.Set; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.SubMonitor; import org.eclipse.egit.core.CoreText; import org.eclipse.egit.core.synchronize.dto.GitSynchronizeData; import org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet; -import org.eclipse.jgit.errors.CorruptObjectException; -import org.eclipse.jgit.lib.ObjectId; -import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevTree; -import org.eclipse.jgit.treewalk.FileTreeIterator; -import org.eclipse.jgit.treewalk.TreeWalk; -import org.eclipse.jgit.treewalk.filter.AndTreeFilter; -import org.eclipse.jgit.treewalk.filter.NotIgnoredFilter; -import org.eclipse.jgit.treewalk.filter.PathFilter; -import org.eclipse.jgit.treewalk.filter.TreeFilter; import org.eclipse.osgi.util.NLS; import org.eclipse.team.core.TeamException; import org.eclipse.team.core.variants.IResourceVariant; @@ -62,69 +49,6 @@ abstract class GitResourceVariantTree extends ResourceVariantTree { @Override protected IResourceVariant fetchVariant(IResource resource, int depth, IProgressMonitor monitor) throws TeamException { - SubMonitor subMonitor = SubMonitor.convert(monitor); - if (resource == null || resource.getLocation() == null) { - subMonitor.done(); - return null; - } - - subMonitor.beginTask(NLS.bind( - CoreText.GitResourceVariantTree_fetchingVariant, - resource.getName()), IProgressMonitor.UNKNOWN); - try { - return fetchVariant(resource, subMonitor); - } finally { - subMonitor.done(); - } - } - - private IResourceVariant fetchVariant(IResource resource, - IProgressMonitor monitor) throws TeamException { - GitSynchronizeData gsd = gsds.getData(resource.getProject()); - if (gsd == null) - return null; - - Repository repo = gsd.getRepository(); - String path = getPath(resource, repo); - RevCommit revCommit = getRevCommit(gsd); - if (revCommit == null) - return null; - - if (path.length() == 0) - return handleRepositoryRoot(resource, repo, revCommit); - - try { - if (monitor.isCanceled()) - throw new OperationCanceledException(); - - TreeWalk tw = initializeTreeWalk(repo, path); - - int nth = tw.addTree(revCommit.getTree()); - if (resource.getType() == IResource.FILE) { - tw.setRecursive(true); - if (tw.next() && !tw.getObjectId(nth).equals(zeroId())) - return new GitBlobResourceVariant(repo, revCommit, - tw.getObjectId(nth), path); - } else { - while (tw.next() && !path.equals(tw.getPathString())) { - if (monitor.isCanceled()) - throw new OperationCanceledException(); - - if (tw.isSubtree()) - tw.enterSubtree(); - } - - ObjectId objectId = tw.getObjectId(nth); - if (!objectId.equals(zeroId())) - return new GitFolderResourceVariant(repo, revCommit, objectId, path); - } - } catch (IOException e) { - throw new TeamException( - NLS.bind( - CoreText.GitResourceVariantTree_couldNotFindResourceVariant, - resource), e); - } - return null; } @@ -159,36 +83,4 @@ abstract class GitResourceVariantTree extends ResourceVariantTree { */ protected abstract RevCommit getRevCommit(GitSynchronizeData gsd) throws TeamException; - - private IResourceVariant handleRepositoryRoot(final IResource resource, - Repository repo, RevCommit revCommit) throws TeamException { - try { - return new GitFolderResourceVariant(repo, revCommit, - revCommit.getTree(), resource.getLocation().toString()); - } catch (IOException e) { - throw new TeamException( - NLS.bind( - CoreText.GitResourceVariantTree_couldNotFindResourceVariant, - resource), e); - } - } - - private TreeWalk initializeTreeWalk(Repository repo, String path) - throws CorruptObjectException { - TreeWalk tw = new TreeWalk(repo); - tw.reset(); - int ignoreNth = tw.addTree(new FileTreeIterator(repo)); - - TreeFilter pathFilter = PathFilter.create(path); - TreeFilter ignoreFilter = new NotIgnoredFilter(ignoreNth); - tw.setFilter(AndTreeFilter.create(pathFilter, ignoreFilter)); - - return tw; - } - - private String getPath(final IResource resource, Repository repo) { - return Repository.stripWorkDir(repo.getWorkTree(), resource - .getLocation().toFile()); - } - } |