diff options
author | Shawn O. Pearce | 2010-08-21 00:28:52 +0000 |
---|---|---|
committer | Shawn O. Pearce | 2010-08-21 00:28:52 +0000 |
commit | aa1733a1b61ee86340206b02f5c090eacb8c4a0b (patch) | |
tree | 4e2658be47bfe8949e276493d667dd89015761bc /org.eclipse.egit.core/src/org/eclipse/egit/core/op/BranchOperation.java | |
parent | b193fa793fdca803ef04963a5b09634f39f72d39 (diff) | |
download | egit-aa1733a1b61ee86340206b02f5c090eacb8c4a0b.tar.gz egit-aa1733a1b61ee86340206b02f5c090eacb8c4a0b.tar.xz egit-aa1733a1b61ee86340206b02f5c090eacb8c4a0b.zip |
Replace deprecated Tag, Commit usage with RevTag, RevCommit
JGit is changing its API to no longer make Tag and Commit classes
accessible for reading purposes. The only thing they will support
is the creation of new objects, and even then their APIs are moving
to a simpler and more consistent usage style.
Replace relevant uses of tags and commits with their RevWalk based
variants, fixing any build breakages caused by this JGit change.
Change-Id: I070e309894989024b26be7638bbfcc62a9a4b00d
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.egit.core/src/org/eclipse/egit/core/op/BranchOperation.java')
-rw-r--r-- | org.eclipse.egit.core/src/org/eclipse/egit/core/op/BranchOperation.java | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/BranchOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/BranchOperation.java index 27c4ad467f..f32d29d0a6 100644 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/BranchOperation.java +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/BranchOperation.java @@ -30,9 +30,10 @@ import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.RefUpdate; import org.eclipse.jgit.lib.Repository; -import org.eclipse.jgit.lib.Tree; import org.eclipse.jgit.lib.WorkDirCheckout; import org.eclipse.jgit.lib.RefUpdate.Result; +import org.eclipse.jgit.revwalk.RevCommit; +import org.eclipse.jgit.revwalk.RevTree; import org.eclipse.jgit.revwalk.RevWalk; import org.eclipse.osgi.util.NLS; import org.eclipse.team.core.TeamException; @@ -71,17 +72,15 @@ public class BranchOperation implements IEGitOperation { this.commitId = commit; } - private Tree oldTree; + private RevTree oldTree; private GitIndex index; - private Tree newTree; + private RevTree newTree; - // TODO replace with RevCommit - private Commit oldCommit; + private RevCommit oldCommit; - // TODO replace with RevCommit - private Commit newCommit; + private RevCommit newCommit; @@ -149,13 +148,13 @@ public class BranchOperation implements IEGitOperation { RefUpdate u = repository.updateRef(Constants.HEAD, detach); Result res; if (detach) { - u.setNewObjectId(newCommit.getCommitId()); + u.setNewObjectId(newCommit.getId()); // using forceUpdate instead of update avoids // the merge tests which would otherwise make // this fail u.setRefLogMessage(NLS.bind( CoreText.BranchOperation_checkoutMovingTo, newCommit - .getCommitId().toString()), false); + .getId().name()), false); res = u.forceUpdate(); } else { u.setRefLogMessage(NLS.bind( @@ -188,8 +187,9 @@ public class BranchOperation implements IEGitOperation { private void checkoutTree() throws TeamException { try { - new WorkDirCheckout(repository, repository.getWorkTree(), oldTree, - index, newTree).checkout(); + new WorkDirCheckout(repository, repository.getWorkTree(), + repository.mapTree(oldTree), index, repository + .mapTree(newTree)).checkout(); } catch (CheckoutConflictException e) { TeamException teamException = new TeamException(e.getMessage()); throw teamException; @@ -212,11 +212,10 @@ public class BranchOperation implements IEGitOperation { RevWalk walk = new RevWalk(repository); try { if (refName != null) { - newCommit = walk.parseCommit(repository.resolve(refName)) - .asCommit(walk); + newCommit = walk.parseCommit(repository.resolve(refName)); } if (commitId != null) { - newCommit = walk.parseCommit(commitId).asCommit(walk); + newCommit = walk.parseCommit(commitId); } } catch (IOException e) { throw new TeamException(NLS.bind( @@ -224,8 +223,7 @@ public class BranchOperation implements IEGitOperation { } try { - oldCommit = walk.parseCommit(repository.resolve(Constants.HEAD)) - .asCommit(walk); + oldCommit = walk.parseCommit(repository.resolve(Constants.HEAD)); } catch (IOException e) { throw new TeamException(CoreText.BranchOperation_mappingCommitHead, e); |