本文整理汇总了Java中org.eclipse.jgit.diff.DiffEntry.ChangeType.MODIFY属性的典型用法代码示例。如果您正苦于以下问题:Java ChangeType.MODIFY属性的具体用法?Java ChangeType.MODIFY怎么用?Java ChangeType.MODIFY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.jgit.diff.DiffEntry.ChangeType
的用法示例。
在下文中一共展示了ChangeType.MODIFY属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testOpenFile
@Test
public void testOpenFile() throws Exception {
UIFile 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", IVCS.WORKINGTREE );
controller.openFile();
verify( controller ).loadMainPerspective();
file = new UIFile( "test.kjb", ChangeType.MODIFY, true );
doReturn( false ).when( controller ).isOnlyWIP();
doReturn( new UIRepositoryObjectRevision( new PurObjectRevision( "XXX", "", null, "" ) ) ).when( controller ).getFirstSelectedRevision();
doReturn( Collections.singletonList( file ) ).when( controller ).getSelectedChangedFiles();
doReturn( new FileInputStream( new File( "src/test/resources/r1.ktr" ) ) ).when( uiGit ).open( "test.kjb", "XXX" );
controller.openFile();
verify( controller, times( 2 ) ).loadMainPerspective();
}
示例2: 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();
}
示例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: BlobChange
public BlobChange(String oldRev, String newRev, DiffEntry diffEntry,
WhitespaceOption whitespaceOption) {
if (diffEntry.getChangeType() == ChangeType.RENAME
&& diffEntry.getOldPath().equals(diffEntry.getNewPath())) {
// for some unknown reason, jgit detects rename even if path
// is the same
type = ChangeType.MODIFY;
} else {
type = diffEntry.getChangeType();
}
this.whitespaceOption = whitespaceOption;
oldBlobIdent = GitUtils.getOldBlobIdent(diffEntry, oldRev);
newBlobIdent = GitUtils.getNewBlobIdent(diffEntry, newRev);
}
示例6: 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;
}
}
示例7: calculateDiffChangeHeader
/**
* Finds the appropriate title for an individual change given its various attributes.
*/
private String calculateDiffChangeHeader(TaskAttribute diffTaskAttribute) {
String newPath = diffTaskAttribute.getAttribute(AppraiseReviewTaskSchema.DIFF_NEWPATH).getValue();
String oldPath = diffTaskAttribute.getAttribute(AppraiseReviewTaskSchema.DIFF_OLDPATH).getValue();
String type = diffTaskAttribute.getAttribute(AppraiseReviewTaskSchema.DIFF_TYPE).getValue();
ChangeType changeType = ChangeType.MODIFY;
try {
changeType = ChangeType.valueOf(type);
} catch (Exception e) {
}
switch (changeType) {
case ADD:
return newPath + " (Added)";
case COPY:
return newPath + " (Copied from " + oldPath + ")";
case DELETE:
return newPath + " (Deleted)";
case RENAME:
return newPath + " (was " + oldPath + ")";
case MODIFY:
default:
return newPath + " (Modified)";
}
}
示例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: 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;
}