当前位置: 首页>>代码示例>>Java>>正文


Java RevWalk.close方法代码示例

本文整理汇总了Java中org.eclipse.jgit.revwalk.RevWalk.close方法的典型用法代码示例。如果您正苦于以下问题:Java RevWalk.close方法的具体用法?Java RevWalk.close怎么用?Java RevWalk.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jgit.revwalk.RevWalk的用法示例。


在下文中一共展示了RevWalk.close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLoaderFrom

import org.eclipse.jgit.revwalk.RevWalk; //导入方法依赖的package包/类
/**
 * Gets the loader for a file from a specified commit and its path
 * 
 * @param commit
 *          - the commit from which to get the loader
 * @param path
 *          - the path to the file
 * @return the loader
 * @throws MissingObjectException
 * @throws IncorrectObjectTypeException
 * @throws CorruptObjectException
 * @throws IOException
 */
public ObjectLoader getLoaderFrom(ObjectId commit, String path)
		throws IOException {
	Repository repository = git.getRepository();
	RevWalk revWalk = new RevWalk(repository);
	RevCommit revCommit = revWalk.parseCommit(commit);
	// and using commit's tree find the path
	RevTree tree = revCommit.getTree();
	TreeWalk treeWalk = new TreeWalk(repository);
	treeWalk.addTree(tree);
	treeWalk.setRecursive(true);
	treeWalk.setFilter(PathFilter.create(path));

	ObjectLoader loader = null;
	if (treeWalk.next()) {
		ObjectId objectId = treeWalk.getObjectId(0);
		loader = repository.open(objectId);
	}

	treeWalk.close();
	revWalk.close();
	return loader;
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:36,代码来源:GitAccess.java

示例2: getBaseCommit

import org.eclipse.jgit.revwalk.RevWalk; //导入方法依赖的package包/类
/**
 * Finds the base commit from the last local commit and the remote commit
 * 
 * @param branchInfo Current branch info or <code>null</code> if unknown.
 * 
 * @return the base commit
 */
public ObjectId getBaseCommit(BranchInfo branchInfo) {
  if (branchInfo == null) {
    branchInfo = getBranchInfo();
  }
	Repository repository = git.getRepository();
	RevWalk walk = new RevWalk(repository);
	ObjectId localCommit = null;
	ObjectId remoteCommit = null;
	ObjectId baseCommit = null;
	try {
		remoteCommit = repository.resolve("origin/" + branchInfo.getBranchName() + "^{commit}");
		localCommit = repository.resolve("HEAD^{commit}");
		if (remoteCommit != null && localCommit != null) {
			RevCommit base = getCommonAncestor(walk, walk.parseCommit(localCommit), walk.parseCommit(remoteCommit));
			if (base != null) {
				baseCommit = base.toObjectId();
			}
		}
	} catch (IOException e) {
		if (logger.isDebugEnabled()) {
			logger.debug(e, e);
		}
	}
	walk.close();
	return baseCommit;
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:34,代码来源:GitAccess.java

示例3: updateWithRemoteFile

import org.eclipse.jgit.revwalk.RevWalk; //导入方法依赖的package包/类
public void updateWithRemoteFile(String filePath) {
	try {
		RevWalk walk = new RevWalk(git.getRepository());
		walk.reset();
		RevCommit commit = walk.parseCommit(git.getRepository().resolve("MERGE_HEAD"));
		git.checkout().setStartPoint(commit).addPath(filePath).call();
		walk.close();
	} catch (Exception e) {
		if (logger.isDebugEnabled()) {
			logger.debug(e, e);
		}
	}
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:14,代码来源:GitAccess.java

示例4: getCommit

import org.eclipse.jgit.revwalk.RevWalk; //导入方法依赖的package包/类
/**
 * Returns the SHA-1 commit id for a file by specifying what commit to get for
 * that file and it's path
 * 
 * @param commit
 *          - specifies the commit to return(MINE, THEIRS, BASE, LOCAL)
 * @param path
 *          - the file path for the specified commit
 * @return the SHA-1 commit id
 */
public ObjectId getCommit(Commit commit, String path) {
	List<DiffEntry> entries;
	boolean baseIsNull = false;
	int index = 0;
	try {
		entries = git.diff().setPathFilter(PathFilter.create(path)).call();
		if (entries.size() == 2) {
			baseIsNull = true;
		}
		if (commit == Commit.MINE) {
			if (baseIsNull) {
				index = 0;
			} else {
				index = 1;
			}
			return entries.get(index).getOldId().toObjectId();
		} else if (commit == Commit.THEIRS) {
			if (baseIsNull) {
				index = 1;
			} else {
				index = 2;
			}
			return entries.get(index).getOldId().toObjectId();
		} else if (commit == Commit.BASE) {
			return entries.get(index).getOldId().toObjectId();
		} else if (commit == Commit.LOCAL) {
			ObjectId lastLocalCommit = getLastLocalCommit();
			RevWalk revWalk = new RevWalk(git.getRepository());
			RevCommit revCommit = revWalk.parseCommit(lastLocalCommit);
			RevTree tree = revCommit.getTree();
			TreeWalk treeWalk = new TreeWalk(git.getRepository());
			treeWalk.addTree(tree);
			treeWalk.setRecursive(true);
			treeWalk.setFilter(PathFilter.create(path));
			ObjectId objectId = null;
			if (treeWalk.next()) {
				objectId = treeWalk.getObjectId(0);
			}
			treeWalk.close();
			revWalk.close();
			return objectId;
		}
	} catch (GitAPIException |IOException e) {
		if (logger.isDebugEnabled()) {
			logger.debug(e, e);
		}
	}
	return null;
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:60,代码来源:GitAccess.java


注:本文中的org.eclipse.jgit.revwalk.RevWalk.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。