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


Java DiffEntry.getNewMode方法代码示例

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


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

示例1: format

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的package包/类
/**
 * Format a patch script for one file entry.
 *
 * @param ent the entry to be formatted.
 * @throws IOException a file's content cannot be read, or the output stream cannot
 *                     be written to.
 */
public List<Hunk> format(DiffEntry ent) throws IOException {
    //writeDiffHeader(out, ent);

    if (ent.getOldMode() == GITLINK || ent.getNewMode() == GITLINK) {
        // writeGitLinkDiffText(out, ent);
        return emptyList();
    } else {
        byte[] aRaw, bRaw;
        try {
            aRaw = open(objectReader, ent.getOldMode(), ent.getOldId());
            bRaw = open(objectReader, ent.getNewMode(), ent.getNewId());
        } finally {
            // objectReader.release();
        }

        if (RawText.isBinary(aRaw) || RawText.isBinary(bRaw)) {
            //out.write(encodeASCII("Binary files differ\n"));
            return emptyList();
        } else {
            RawText a = new RawText(aRaw);
            RawText b = new RawText(bRaw);
            return formatEdits(a, b, MyersDiff.INSTANCE.diff(DEFAULT, a, b));
        }
    }
}
 
开发者ID:m4rzEE1,项目名称:ninja_chic-,代码行数:33,代码来源:LineContextDiffer.java

示例2: writeGitLinkDiffText

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的package包/类
private void writeGitLinkDiffText(OutputStream o, DiffEntry ent)
        throws IOException {
    if (ent.getOldMode() == GITLINK) {
        o.write(encodeASCII("-Subproject commit " + ent.getOldId().name()
                + "\n"));
    }
    if (ent.getNewMode() == GITLINK) {
        o.write(encodeASCII("+Subproject commit " + ent.getNewId().name()
                + "\n"));
    }
}
 
开发者ID:m4rzEE1,项目名称:ninja_chic-,代码行数:12,代码来源:LineContextDiffer.java

示例3: commitInfo

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的package包/类
private JsonObject commitInfo(JsonArray map, Repository repository, ObjectId objectID, ObjectId newerrId) throws MissingObjectException, IncorrectObjectTypeException, IOException{
	try{
		JsonObject jsonObject = new JsonObject();
		RevWalk walk = new RevWalk(repository);
		RevCommit commit = null;
		if(objectID!=null){
			commit = walk.parseCommit(objectID);
		}
		if(commit!=null){
			if(objectID!=null){
				jsonObject.put("ID", objectID.getName());
			}
			jsonObject.put("TIME", "" + commit.getCommitTime());
			if(commit.getCommitterIdent() != null) {
				jsonObject.put("COMMITER", commit.getCommitterIdent().getName());
			}
			jsonObject.put("MESSAGE", commit.getFullMessage());

			if(newerrId!=null && full){
				RevCommit newerCommit = walk.parseCommit(newerrId);
				ObjectReader reader = repository.newObjectReader();
				CanonicalTreeParser newerTreeIter = new CanonicalTreeParser();
				List<DiffEntry> diffs=null;
				if(newerCommit.getTree()!=null){
					newerTreeIter.reset(reader, newerCommit.getTree());
					CanonicalTreeParser newTreeIter = new CanonicalTreeParser();
					if(commit.getTree()!=null){
						newTreeIter.reset(reader, commit.getTree());
						diffs= new Git(repository).diff()
												.setNewTree(newerTreeIter)
												.setOldTree(newTreeIter)
												.call();
					}
				}
				if(diffs!=null){
					JsonArray files= new JsonArray();
					for (DiffEntry entry : diffs) {
						FileMode mode =entry.getNewMode();
						if(FileMode.MISSING==mode){
							files.add(new JsonObject().withValue("REM", entry.getNewPath()));
						} else {
							files.add(new JsonObject().withValue("CHANGE", entry.getNewPath()));
						}
					}
					jsonObject.put("FILES", files);
				}
			}
			map.add(jsonObject);
		}
		walk.close();
		return jsonObject;
	}catch(GitAPIException e) {
	}
	return null;
}
 
开发者ID:fujaba,项目名称:NetworkParser,代码行数:56,代码来源:GitRevision.java

示例4: format

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的package包/类
public void format(final DiffEntry ent) throws IOException {
	if (ent.getOldMode() == GITLINK || ent.getNewMode() == GITLINK
			|| ent.getOldId() == null || ent.getNewId() == null) {
		// No diff lines for git links, renames, file adds
		return;
	}
	
	byte[] aRaw = open(OLD, ent);
	byte[] bRaw = open(NEW, ent);
	
	if (aRaw == BINARY || bRaw == BINARY //
			|| RawText.isBinary(aRaw) || RawText.isBinary(bRaw)) {
		// No diff lines for binary files
		return;
	}
	
	RawText a = new RawText(aRaw);
	RawText b = new RawText(bRaw);
	List<Edit> edits = diff(a, b);
	
	for (int curIdx = 0; curIdx < edits.size();) {
		Edit curEdit = edits.get(curIdx);
		final int endIdx = findCombinedEnd(edits, curIdx);
		final Edit endEdit = edits.get(endIdx);

		int aCur = Math.max(0, curEdit.getBeginA() - context);
		int bCur = Math.max(0, curEdit.getBeginB() - context);
		final int aEnd = Math.min(a.size(), endEdit.getEndA() + context);
		final int bEnd = Math.min(b.size(), endEdit.getEndB() + context);
		
		final DiffContext diffContext = new DiffContext();
		List<DiffLine> diffLines = Lists.newArrayListWithCapacity(2 * context + 1);
		diffContext.setLines(diffLines);

		while (aCur < aEnd || bCur < bEnd) {
			DiffLine line = new DiffLine();

			if (aCur < curEdit.getBeginA() || endIdx + 1 < curIdx) {
				line.setContent(a.getString(aCur));
                   line.setNewLineNumber(bCur + 1);
                   line.setOldLineNumber(aCur + 1);
				diffLines.add(line);
				aCur++;
				bCur++;
			} else if (aCur < curEdit.getEndA()) {
				line.setContent(a.getString(aCur));
                   line.setOldLineNumber(aCur + 1);
				diffLines.add(line);
				aCur++;
			} else if (bCur < curEdit.getEndB()) {
				line.setContent(b.getString(bCur));
                   line.setNewLineNumber(bCur + 1);
				diffLines.add(line);
				bCur++;
			}

			if (end(curEdit, aCur, bCur) && ++curIdx < edits.size())
				curEdit = edits.get(curIdx);
		}
		
		list.add(diffContext);
	}
}
 
开发者ID:devhub-tud,项目名称:git-server,代码行数:64,代码来源:DiffContextFormatter.java


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