项目:github-bucket
文件:WorkerTest.java
public Workertest() {
URIish fetchUrl = new URIish();
SyncableRepository pushRepository = mock(SyncableRepository.class);
when(config.getFetchUrl()).thenReturn(fetchUrl);
when(config.getPushRepository()).thenReturn(pushRepository);
ObjectDatabase database = mock(ObjectDatabase.class);
when(database.exists()).thenReturn(false);
Repository repository = mock(Repository.class);
when(repository.getobjectDatabase()).thenReturn(database);
when(config.getWorkingFileRepository()).thenReturn(repository);
uut = new Worker(config);
}
项目:incubator-netbeans
文件:CheckoutRevisionCommand.java
private void mergeConflicts (List<String> conflicts,DirCache cache) throws GitException {
DirCacheBuilder builder = cache.builder();
DirCacheBuildIterator dci = new DirCacheBuildIterator(builder);
TreeWalk walk = new TreeWalk(getRepository());
ObjectDatabase od = null;
DiffAlgorithm.SupportedAlgorithm diffAlg = getRepository().getConfig().getEnum(
ConfigConstants.CONfig_DIFF_SECTION,null,ConfigConstants.CONfig_KEY_ALGORITHM,DiffAlgorithm.SupportedAlgorithm.HISTOGRAM);
MergeAlgorithm merger = new MergeAlgorithm(DiffAlgorithm.getAlgorithm(diffAlg));
try {
od = getRepository().getobjectDatabase();
walk.addTree(dci);
walk.setFilter(PathFilterGroup.create(Utils.getPathFilters(conflicts)));
String lastPath = null;
DirCacheEntry[] entries = new DirCacheEntry[3];
walk.setRecursive(true);
while (walk.next()) {
DirCacheEntry e = walk.getTree(0,DirCacheIterator.class).getDirCacheEntry();
String path = e.getPathString();
if (lastPath != null && !lastPath.equals(path)) {
resolveEntries(merger,lastPath,entries,od,builder);
}
if (e.getStage() == 0) {
DirCacheIterator c = walk.getTree(0,DirCacheIterator.class);
builder.add(c.getDirCacheEntry());
} else {
entries[e.getStage() - 1] = e;
lastPath = path;
}
}
resolveEntries(merger,builder);
builder.commit();
} catch (IOException ex) {
throw new GitException(ex);
} finally {
walk.release();
if (od != null) {
od.close();
}
}
}
项目:incubator-netbeans
文件:Utils.java
public static RawText getRawText (ObjectId id,ObjectDatabase db) throws IOException {
if (id.equals(ObjectId.zeroId())) {
return RawText.EMPTY_TEXT;
}
return new RawText(db.open(id,Constants.OBJ_BLOB).getCachedBytes());
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。