本文整理汇总了Java中org.eclipse.jgit.diff.DiffEntry.ChangeType.ADD属性的典型用法代码示例。如果您正苦于以下问题:Java ChangeType.ADD属性的具体用法?Java ChangeType.ADD怎么用?Java ChangeType.ADD使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.jgit.diff.DiffEntry.ChangeType
的用法示例。
在下文中一共展示了ChangeType.ADD属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testVisualDiff
@Test
public void testVisualDiff() throws Exception {
XulMessageBox message = spy( new XulMessageBoxMock( XulDialogCallback.Status.ACCEPT ) );
when( document.createElement( MESSAGEBOX ) ).thenReturn( message );
UIFile file = new UIFile( "test.txt", ChangeType.MODIFY, true );
doReturn( Collections.singletonList( file ) ).when( controller ).getSelectedChangedFiles();
controller.visualdiff();
verify( message ).setTitle( BaseMessages.getString( PKG, "Dialog.Error" ) );
// .ktr
file = new UIFile( "test.ktr", ChangeType.MODIFY, true );
doReturn( Collections.singletonList( file ) ).when( controller ).getSelectedChangedFiles();
doReturn( new FileInputStream( new File( "src/test/resources/r1.ktr" ) ) ).when( uiGit ).open( "test.ktr", Constants.HEAD );
doReturn( new FileInputStream( new File( "src/test/resources/r2.ktr" ) ) ).when( uiGit ).open( "test.ktr", IVCS.WORKINGTREE );
controller.visualdiff();
verify( uiGit ).open( "test.ktr", Constants.HEAD );
verify( uiGit ).open( "test.ktr", IVCS.WORKINGTREE );
verify( controller ).loadMainPerspective();
// conflicted ktr
file = new UIFile( "test.kjb.ours", ChangeType.ADD, false );
File dir = File.createTempFile( "git_test_", "_controller" );
dir.delete();
dir.mkdir();
File ours = new File( dir.getPath(), "test.kjb.ours" );
File theirs = new File( dir.getPath(), "test.kjb.theirs" );
FileUtils.copyFile( new File( "src/test/resources/r1.kjb" ), ours );
FileUtils.copyFile( new File( "src/test/resources/r2.kjb" ), theirs );
doReturn( dir.getPath() ).when( uiGit ).getDirectory();
doReturn( Collections.singletonList( file ) ).when( controller ).getSelectedChangedFiles();
doReturn( new FileInputStream( ours ) ).when( uiGit ).open( "test.kjb.ours", IVCS.WORKINGTREE );
doReturn( new FileInputStream( theirs ) ).when( uiGit ).open( "test.kjb.theirs", IVCS.WORKINGTREE );
controller.visualdiff();
FileUtils.deleteDirectory( dir );
verify( uiGit ).open( "test.kjb.ours", IVCS.WORKINGTREE );
verify( uiGit ).open( "test.kjb.theirs", IVCS.WORKINGTREE );
verify( controller, times( 2 ) ).loadMainPerspective();
}
示例2: ofNewCommit
public static DiffInfo ofNewCommit(FileContent fileContent) {
DiffInfo diffInfo = new DiffInfo(null, null, fileContent.getPath(), ChangeType.ADD,
fileContent.isBinary(), /*null, fileContent.getText(),*/ null);
if (!fileContent.isBinary()) {
DiffBlock diffBlock = new DiffBlock(0, 0);
String[] lines = fileContent.getText().split("\n");
for (int i = 0; i < lines.length; i++) {
DiffLine diffLine = new DiffLine(2, lines[i]);
diffLine.setALine(0);
diffLine.setBLine(i);
diffBlock.getDiffLines().add(diffLine);
}
diffBlock.setEnd(false, 0, lines.length);
diffInfo.diffBlocks = Arrays.asList(diffBlock);
}
return diffInfo;
}
示例3: visitRev
private void visitRev(Rev rev, int number) {
Timer visitAllTimer = visitAllStat.timer();
visitor.onStartRev(rev, null, number);
for (ParentRelation parentRelation: rev.getParentRelations()) {
for (Diff diff : parentRelation.getDiffs()) {
if (diff.getType() == ChangeType.ADD) {
visitor.onAddedFile(diff);
} else if (diff.getType() == ChangeType.COPY) {
visitor.onCopiedFile(diff);
} else if (diff.getType() == ChangeType.DELETE) {
visitor.onDeletedFile(diff);
} else if (diff.getType() == ChangeType.MODIFY) {
visitor.onModifiedFile(diff);
} else if (diff.getType() == ChangeType.RENAME) {
visitor.onRenamedFile(diff);
}
}
}
visitor.onCompleteRev(rev, null);
visitAllTimer.track();
}
示例4: visitRev
private void visitRev(Rev rev, Rev traverseParentRev, int number) {
Preconditions.checkArgument(!traversedRevs.contains(rev));
Timer visitAllTimer = visitFullETStat.timer();
visitor.onStartRev(rev,traverseParentRev, number);
for (ParentRelation parentRelation: rev.getParentRelations()) {
for (Diff diff : parentRelation.getDiffs()) {
if (diff.getType() == ChangeType.ADD) {
visitor.onAddedFile(diff);
} else if (diff.getType() == ChangeType.COPY) {
visitor.onCopiedFile(diff);
} else if (diff.getType() == ChangeType.DELETE) {
visitor.onDeletedFile(diff);
} else if (diff.getType() == ChangeType.MODIFY) {
visitor.onModifiedFile(diff);
} else if (diff.getType() == ChangeType.RENAME) {
visitor.onRenamedFile(diff);
}
}
}
visitor.onCompleteRev(rev, traverseParentRev);
visitAllTimer.track();
}
示例5: onInitialize
@Override
protected void onInitialize() {
super.onInitialize();
if (change.getType() == ChangeType.ADD || change.getType() == ChangeType.COPY) {
showBlob(change.getNewBlob());
} else if (change.getType() == ChangeType.DELETE) {
showBlob(change.getOldBlob());
} else {
if (change.getOldText() != null && change.getNewText() != null) {
if (change.getOldText().getLines().size() + change.getNewText().getLines().size() > DiffUtils.MAX_DIFF_SIZE) {
add(newFragment("Unable to diff as the file is too large.", true));
} else if (change.getAdditions() + change.getDeletions() > WebConstants.MAX_SINGLE_FILE_DIFF_LINES) {
add(newFragment("Diff is too large to be displayed.", true));
} else if (change.getAdditions() + change.getDeletions() == 0
&& (markSupport == null || markSupport.getComments().isEmpty())) {
add(newFragment("Content is identical", false));
} else {
add(new TextDiffPanel(CONTENT_ID, projectModel, requestModel, change, diffMode, blameModel, markSupport));
}
} else if (change.getOldBlob().isPartial() || change.getNewBlob().isPartial()) {
add(newFragment("File is too large to be loaded.", true));
} else if (change.getOldBlob().getMediaType().equals(change.getNewBlob().getMediaType())) {
Panel diffPanel = null;
for (DiffRenderer renderer: GitPlex.getExtensions(DiffRenderer.class)) {
diffPanel = renderer.render(CONTENT_ID, change.getNewBlob().getMediaType(), change);
if (diffPanel != null)
break;
}
if (diffPanel != null)
add(diffPanel);
else
add(newFragment("Binary file.", false));
} else {
add(newFragment("Binary file.", false));
}
}
}
示例6: getOldBlobIdent
public static BlobIdent getOldBlobIdent(DiffEntry diffEntry, String oldRev) {
BlobIdent blobIdent;
if (diffEntry.getChangeType() != ChangeType.ADD) {
blobIdent = new BlobIdent(oldRev, diffEntry.getOldPath(), diffEntry.getOldMode().getBits());
} else {
blobIdent = new BlobIdent(oldRev, null, null);
}
return blobIdent;
}
示例7: convertTypeToGit
private static ChangeType convertTypeToGit( String type ) {
if ( type.equals( "added" ) | type.equals( "unversioned" ) ) {
return ChangeType.ADD;
} else if ( type.equals( "deleted" ) | type.equals( "missing" ) ) {
return ChangeType.DELETE;
} else if ( type.equals( "modified" ) | type.equals( "normal" ) | type.equals( "replaced" ) ) {
return ChangeType.MODIFY;
} else {
return ChangeType.MODIFY;
}
}
示例8: FindClassDiff
private static List<ClassNode> FindClassDiff(Map<String,ClassNode> oldClasses,
Map<String,ClassNode> newClasses) {
List<ClassNode> _res = new ArrayList<ClassNode>();
// Compare each class
for (ClassNode _classNew : newClasses.values()){
// Try to find the class in previous version
ClassNode _oldClass = oldClasses.get(_classNew.name);
if (_oldClass != null){
// See if they are different
if (_classNew.data.compareTo(_oldClass.data) != 0){
_classNew.changeType = ChangeType.MODIFY;
// Check for functions modified
_classNew.functions = FunctionNode.Parse(_classNew, _oldClass);
_res.add(_classNew);
}
} else { // The old file does not have this class (NEW)
_classNew.changeType = ChangeType.ADD;
_classNew.functions = FunctionNode.Parse(_classNew, null);
_res.add(_classNew);
}
}
return _res;
}
示例9: Parse
public static List<FunctionNode> Parse(ClassNode _newClass, ClassNode _oldClass) {
List<FunctionNode> resultFunctions = new ArrayList<FunctionNode>();
switch (_newClass.getChangeType()) {
case ADD: {
Map<String,List<MethodDeclaration>> methodsDec = ExtractFunctions(_newClass);
for (Entry<String, List<MethodDeclaration>> _entry : methodsDec.entrySet()) {
List<MethodDeclaration> _mdl = _entry.getValue();
for (MethodDeclaration _md : _mdl){
FunctionNode _functionNode = new FunctionNode();
_functionNode.name = _md.getName().toString();
_functionNode.lineStart = _md.getStartPosition();
_functionNode.lineEnd = _md.getStartPosition() + _md.getLength();
_functionNode.changeType = ChangeType.ADD;
resultFunctions.add(_functionNode);
}
}
}
break;
case MODIFY: {
// Extract functions from class in order to see if there is any
// modification on it
Map<String, List<MethodDeclaration>> oldFunctions = ExtractFunctions(_oldClass);
Map<String, List<MethodDeclaration>> newFunctions = ExtractFunctions(_newClass);
resultFunctions = FindFunctionsDiff(oldFunctions, newFunctions, _oldClass, _newClass);
}
break;
default:
break;
}
return resultFunctions;
}
示例10: FindFunctionsDiff
private static List<FunctionNode> FindFunctionsDiff(Map<String,List<MethodDeclaration>> oldFunctions,
Map<String,List<MethodDeclaration>> newFunctions, ClassNode _oldClass, ClassNode _newClass) {
List<FunctionNode> _res = new ArrayList<FunctionNode>();
// Compare each Function
for (Entry<String,List<MethodDeclaration>> _entryN : newFunctions.entrySet()){
List<MethodDeclaration> _mdNList = _entryN.getValue();
for (MethodDeclaration _mdN : _mdNList){
FunctionNode _functionNodeNew = new FunctionNode();
_functionNodeNew.name = _mdN.getName().toString();
_functionNodeNew.lineStart = _mdN.getStartPosition();
_functionNodeNew.lineEnd = _mdN.getStartPosition() + _mdN.getLength();
// Try to find if the function exists previously
List<MethodDeclaration> _mdOList = oldFunctions.get(_entryN.getKey());
if (_mdOList != null){
// Get the function's body to see if they are different
String _newFunctionBody = _newClass.getData().substring(
_functionNodeNew.lineStart, _functionNodeNew.lineEnd);
boolean changed = true;
for (MethodDeclaration _mdO : _mdOList){
String _oldFunctionBody = _oldClass.getData().substring(
_mdO.getStartPosition(), _mdO.getStartPosition() + _mdO.getLength());
if (_newFunctionBody.compareTo(_oldFunctionBody) == 0){
changed = false;
break;
}
}
if (changed){
_functionNodeNew.changeType = ChangeType.MODIFY;
_res.add(_functionNodeNew);
}
} else {
_functionNodeNew.changeType = ChangeType.ADD;
_res.add(_functionNodeNew);
}
}
}
return _res;
}