當前位置: 首頁>>代碼示例>>Java>>正文


Java RevWalk.setRevFilter方法代碼示例

本文整理匯總了Java中org.eclipse.jgit.revwalk.RevWalk.setRevFilter方法的典型用法代碼示例。如果您正苦於以下問題:Java RevWalk.setRevFilter方法的具體用法?Java RevWalk.setRevFilter怎麽用?Java RevWalk.setRevFilter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jgit.revwalk.RevWalk的用法示例。


在下文中一共展示了RevWalk.setRevFilter方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getSingleBaseCommit

import org.eclipse.jgit.revwalk.RevWalk; //導入方法依賴的package包/類
private GitRevisionInfo getSingleBaseCommit (RevWalk walk, List<RevCommit> commits) throws IOException {
    while (commits.size() > 1) {
        walk.reset();
        for (RevCommit c : commits) {
            walk.markStart(walk.parseCommit(c));
        }
        walk.setRevFilter(RevFilter.MERGE_BASE);
        commits.clear();
        for (RevCommit commit = walk.next(); commit != null; commit = walk.next()) {
            commits.add(commit);
        }
    }
    if (commits.isEmpty()) {
        return null;
    } else {
        return getClassFactory().createRevisionInfo(commits.get(0), getRepository());
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:GetCommonAncestorCommand.java

示例2: getCommonAncestor

import org.eclipse.jgit.revwalk.RevWalk; //導入方法依賴的package包/類
/**
 * Finds the common base for the given commit "a" and the given commit "b"
 * 
 * @param walk
 *          - used to browse through commits
 * @param a
 *          - commit "a"
 * @param b
 *          - commit "b"
 * @return the bese commit
 * @throws IncorrectObjectTypeException
 * @throws IOException
 */
private RevCommit getCommonAncestor(RevWalk walk, RevCommit a, RevCommit b)
		throws IOException {
	walk.reset();
	walk.setRevFilter(RevFilter.MERGE_BASE);
	walk.markStart(a);
	walk.markStart(b);
	final RevCommit base = walk.next();
	if (base == null)
		return null;
	final RevCommit base2 = walk.next();
	if (base2 != null) {
		throw new NoMergeBaseException(MergeBaseFailureReason.MULTIPLE_MERGE_BASES_NOT_SUPPORTED,
				MessageFormat.format(JGitText.get().multipleMergeBasesFor, a.name(), b.name(), base.name(), base2.name()));
	}
	return base;
}
 
開發者ID:oxygenxml,項目名稱:oxygen-git-plugin,代碼行數:30,代碼來源:GitAccess.java

示例3: fetchAndCreateNewRevsWalk

import org.eclipse.jgit.revwalk.RevWalk; //導入方法依賴的package包/類
public RevWalk fetchAndCreateNewRevsWalk(Repository repository, String branch) throws Exception {
	List<ObjectId> currentRemoteRefs = new ArrayList<ObjectId>();
	for (Ref ref : repository.getAllRefs().values()) {
		String refName = ref.getName();
		if (refName.startsWith(REMOTE_REFS_PREFIX)) {
			currentRemoteRefs.add(ref.getObjectId());
		}
	}
	
	List<TrackingRefUpdate> newRemoteRefs = this.fetch(repository);
	
	RevWalk walk = new RevWalk(repository);
	for (TrackingRefUpdate newRef : newRemoteRefs) {
		if (branch == null || newRef.getLocalName().endsWith("/" + branch)) {
			walk.markStart(walk.parseCommit(newRef.getNewObjectId()));
		}
	}
	for (ObjectId oldRef : currentRemoteRefs) {
		walk.markUninteresting(walk.parseCommit(oldRef));
	}
	walk.setRevFilter(commitsFilter);
	return walk;
}
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:24,代碼來源:GitHelper.java

示例4: createAllRevsWalk

import org.eclipse.jgit.revwalk.RevWalk; //導入方法依賴的package包/類
public RevWalk createAllRevsWalk(Repository repository, String branch) throws Exception {
	List<ObjectId> currentRemoteRefs = new ArrayList<ObjectId>();
	for (Ref ref : repository.getAllRefs().values()) {
		String refName = ref.getName();
		if (refName.startsWith(REMOTE_REFS_PREFIX)) {
			if (branch == null || refName.endsWith("/" + branch)) {
				currentRemoteRefs.add(ref.getObjectId());
			}
		}
	}
	
	RevWalk walk = new RevWalk(repository);
	for (ObjectId newRef : currentRemoteRefs) {
		walk.markStart(walk.parseCommit(newRef));
	}
	walk.setRevFilter(commitsFilter);
	return walk;
}
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:19,代碼來源:GitHelper.java

示例5: fetchAndCreateNewRevsWalk

import org.eclipse.jgit.revwalk.RevWalk; //導入方法依賴的package包/類
public RevWalk fetchAndCreateNewRevsWalk(Repository repository, String branch) throws Exception {
	List<ObjectId> currentRemoteRefs = new ArrayList<ObjectId>(); 
	for (Ref ref : repository.getAllRefs().values()) {
		String refName = ref.getName();
		if (refName.startsWith(REMOTE_REFS_PREFIX)) {
			currentRemoteRefs.add(ref.getObjectId());
		}
	}
	
	List<TrackingRefUpdate> newRemoteRefs = this.fetch(repository);
	
	RevWalk walk = new RevWalk(repository);
	for (TrackingRefUpdate newRef : newRemoteRefs) {
		if (branch == null || newRef.getLocalName().endsWith("/" + branch)) {
			walk.markStart(walk.parseCommit(newRef.getNewObjectId()));
		}
	}
	for (ObjectId oldRef : currentRemoteRefs) {
		walk.markUninteresting(walk.parseCommit(oldRef));
	}
	walk.setRevFilter(commitsFilter);
	return walk;
}
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:24,代碼來源:GitServiceImpl.java

示例6: createAllRevsWalk

import org.eclipse.jgit.revwalk.RevWalk; //導入方法依賴的package包/類
public RevWalk createAllRevsWalk(Repository repository, String branch) throws Exception {
	List<ObjectId> currentRemoteRefs = new ArrayList<ObjectId>(); 
	for (Ref ref : repository.getAllRefs().values()) {
		String refName = ref.getName();
		if (refName.startsWith(REMOTE_REFS_PREFIX)) {
			if (branch == null || refName.endsWith("/" + branch)) {
				currentRemoteRefs.add(ref.getObjectId());
			}
		}
	}
	
	RevWalk walk = new RevWalk(repository);
	for (ObjectId newRef : currentRemoteRefs) {
		walk.markStart(walk.parseCommit(newRef));
	}
	walk.setRevFilter(commitsFilter);
	return walk;
}
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:19,代碼來源:GitServiceImpl.java

示例7: listFiles

import org.eclipse.jgit.revwalk.RevWalk; //導入方法依賴的package包/類
private void listFiles() throws GitException {
    RevWalk revWalk = new RevWalk(repository);
    TreeWalk walk = new TreeWalk(repository);
    try {
        List<GitFileInfo> result;
        walk.reset();
        walk.setRecursive(true);
        RevCommit parentCommit = null;
        if (revCommit.getParentCount() > 0) {
            for (RevCommit commit : revCommit.getParents()) {
                revWalk.markStart(revWalk.lookupCommit(commit));
            }
            revWalk.setRevFilter(RevFilter.MERGE_BASE);
            Iterator<RevCommit> it = revWalk.iterator();
            if (it.hasNext()) {
                parentCommit = it.next();
            }
            if (parentCommit != null) {
                walk.addTree(parentCommit.getTree().getId());
            }
        }
        walk.addTree(revCommit.getTree().getId());
        walk.setFilter(AndTreeFilter.create(TreeFilter.ANY_DIFF, PathFilter.ANY_DIFF));
        if (parentCommit != null) {
            result = Utils.getDiffEntries(repository, walk, GitClassFactoryImpl.getInstance());
        } else {
            result = new ArrayList<GitFileInfo>();
            while (walk.next()) {
                result.add(new GitFileInfo(new File(repository.getWorkTree(), walk.getPathString()), walk.getPathString(), GitFileInfo.Status.ADDED, null, null));
            }
        }
        this.modifiedFiles = result.toArray(new GitFileInfo[result.size()]);
    } catch (IOException ex) {
        throw new GitException(ex);
    } finally {
        revWalk.release();
        walk.release();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:40,代碼來源:GitRevisionInfo.java

示例8: applyCriteria

import org.eclipse.jgit.revwalk.RevWalk; //導入方法依賴的package包/類
private void applyCriteria (RevWalk walk, SearchCriteria criteria,
        final RevFlag partOfResultFlag, DiffConfig diffConfig) {
    File[] files = criteria.getFiles();
    if (files.length > 0) {
        Collection<PathFilter> pathFilters = Utils.getPathFilters(getRepository().getWorkTree(), files);
        if (!pathFilters.isEmpty()) {
            if (criteria.isFollow() && pathFilters.size() == 1) {
                walk.setTreeFilter(FollowFilter.create(pathFilters.iterator().next().getPath(), diffConfig));
            } else {
                walk.setTreeFilter(AndTreeFilter.create(TreeFilter.ANY_DIFF, PathFilterGroup.create(pathFilters)));
            }
        }
    }
    RevFilter filter;
    if (criteria.isIncludeMerges()) {
        filter = RevFilter.ALL;
    } else {
        filter = RevFilter.NO_MERGES;
    }
    filter = AndRevFilter.create(filter, new CancelRevFilter(monitor));
    filter = AndRevFilter.create(filter, new RevFilter() {

        @Override
        public boolean include (RevWalk walker, RevCommit cmit) {
            return cmit.has(partOfResultFlag);
        }

        @Override
        public RevFilter clone () {
            return this;
        }

        @Override
        public boolean requiresCommitBody () {
            return false;
        }            
        
    });
    
    String username = criteria.getUsername();
    if (username != null && !(username = username.trim()).isEmpty()) {
        filter = AndRevFilter.create(filter, OrRevFilter.create(CommitterRevFilter.create(username), AuthorRevFilter.create(username)));
    }
    String message = criteria.getMessage();
    if (message != null && !(message = message.trim()).isEmpty()) {
        filter = AndRevFilter.create(filter, MessageRevFilter.create(message));
    }
    Date from  = criteria.getFrom();
    Date to  = criteria.getTo();
    if (from != null && to != null) {
        filter = AndRevFilter.create(filter, CommitTimeRevFilter.between(from, to));
    } else if (from != null) {
        filter = AndRevFilter.create(filter, CommitTimeRevFilter.after(from));
    } else if (to != null) {
        filter = AndRevFilter.create(filter, CommitTimeRevFilter.before(to));
    }
    // this must be at the end, limit filter must apply as the last
    if (criteria.getLimit() != -1) {
        filter = AndRevFilter.create(filter, MaxCountRevFilter.create(criteria.getLimit()));
    }
    walk.setRevFilter(filter);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:63,代碼來源:LogCommand.java

示例9: countCommits

import org.eclipse.jgit.revwalk.RevWalk; //導入方法依賴的package包/類
public int countCommits(Repository repository, String branch) throws Exception {
	RevWalk walk = new RevWalk(repository);
	try {
		Ref ref = repository.findRef(REMOTE_REFS_PREFIX + branch);
		ObjectId objectId = ref.getObjectId();
		RevCommit start = walk.parseCommit(objectId);
		walk.setRevFilter(RevFilter.NO_MERGES);
		return RevWalkUtils.count(walk, start, null);
	} finally {
		walk.dispose();
	}
}
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:13,代碼來源:GitHelper.java

示例10: countCommits

import org.eclipse.jgit.revwalk.RevWalk; //導入方法依賴的package包/類
@Override
public int countCommits(Repository repository, String branch) throws Exception {
	RevWalk walk = new RevWalk(repository);
	try {
		Ref ref = repository.findRef(REMOTE_REFS_PREFIX + branch);
		ObjectId objectId = ref.getObjectId();
		RevCommit start = walk.parseCommit(objectId);
		walk.setRevFilter(RevFilter.NO_MERGES);
		return RevWalkUtils.count(walk, start, null);
	} finally {
		walk.dispose();
	}
}
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:14,代碼來源:GitServiceImpl.java


注:本文中的org.eclipse.jgit.revwalk.RevWalk.setRevFilter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。