當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。