The Unified and Autonomous Development Platform
Display commented files in diff view even if they are not changed.
robin shine550325524435
diff --git a/commons.git/src/main/java/com/pmease/commons/git/BlobChange.java b/commons.git/src/main/java/com/pmease/commons/git/BlobChange.javaindex 65605545ff..ea2b1d4540 100644--- a/commons.git/src/main/java/com/pmease/commons/git/BlobChange.java+++ b/commons.git/src/main/java/com/pmease/commons/git/BlobChange.java@@ -46,7 +46,7 @@ public abstract class BlobChange implements Serializable {newBlobIdent = GitUtils.getNewBlobIdent(diffEntry, newRev);}- public BlobChange(ChangeType type, BlobIdent oldBlobIdent, BlobIdent newBlobIdent,+ public BlobChange(@Nullable ChangeType type, BlobIdent oldBlobIdent, BlobIdent newBlobIdent,WhitespaceOption whitespaceOption) {this.type = type;this.oldBlobIdent = oldBlobIdent;@@ -54,6 +54,14 @@ public abstract class BlobChange implements Serializable {this.whitespaceOption = whitespaceOption;}+ /**+ * Get change type. Return <tt>null</tt> if this is a faked change representing+ * an unchanged file+ *+ * @return+ * type of change, or <tt>null</tt> if the file is not changed actually+ */+ @Nullablepublic ChangeType getType() {return type;}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultAuxiliaryManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultAuxiliaryManager.javaindex 44e2eeb711..02dd888662 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultAuxiliaryManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultAuxiliaryManager.java@@ -460,7 +460,7 @@ public class DefaultAuxiliaryManager implements AuxiliaryManager, DepotListener,List<Path> paths = new ArrayList<>();for (String file: (Set<String>)SerializationUtils.deserialize(bytes))paths.add(Paths.get(file));- paths.sort((path1, path2) -> path1.compareTo(path2));+ paths.sort(Path::compareTo);List<String> files = new ArrayList<>();for (Path path: paths)files.add(path.toString().replace('\\', '/'));diff --git a/gitplex.product/src/test/java/gitplex/product/Test.java b/gitplex.product/src/test/java/gitplex/product/Test.javaindex a92117ff35..bd86f2bdfe 100644--- a/gitplex.product/src/test/java/gitplex/product/Test.java+++ b/gitplex.product/src/test/java/gitplex/product/Test.java@@ -1,9 +1,15 @@package gitplex.product;+import java.nio.file.Paths;+public class Test {@org.junit.Testpublic void test() {+ long time = System.currentTimeMillis();+ for (int i=0; i<1000000; i++)+ Paths.get("hello/world/just/do/it/and/I/will/help/you/to/get/it/done/" + i);+ System.out.println(System.currentTimeMillis()-time);}}\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/BlobDiffPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/BlobDiffPanel.javaindex d0b9c6c0f5..75a78bebac 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/BlobDiffPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/BlobDiffPanel.java@@ -111,7 +111,8 @@ public class BlobDiffPanel extends Panel implements MarkAware {add(newFragment("Unable to diff as the file is too large.", true));} else if (change.getAdditions() + change.getDeletions() > Constants.MAX_SINGLE_FILE_DIFF_LINES) {add(newFragment("Diff is too large to be displayed.", true));- } else if (change.getAdditions() + change.getDeletions() == 0) {+ } else if (change.getAdditions() + change.getDeletions() == 0+ && (markSupport == null || markSupport.getComments().isEmpty())) {add(newFragment("Content is identical", false));} else {add(new TextDiffPanel(CONTENT_ID, depotModel, requestModel, change, diffMode, markSupport));diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.javaindex 6242ab6f6c..d61b4b6a24 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java@@ -1,11 +1,14 @@package com.pmease.gitplex.web.component.diff.revision;+import java.nio.file.Paths;import java.util.ArrayList;import java.util.Collection;import java.util.HashMap;+import java.util.HashSet;import java.util.Iterator;import java.util.List;import java.util.Map;+import java.util.Set;import java.util.concurrent.Callable;import java.util.concurrent.ExecutionException;import java.util.concurrent.ForkJoinPool;@@ -47,6 +50,7 @@ import org.apache.wicket.util.visit.IVisit;import org.apache.wicket.util.visit.IVisitor;import org.eclipse.jgit.diff.DiffEntry;import org.eclipse.jgit.diff.DiffEntry.ChangeType;+import org.eclipse.jgit.lib.FileMode;import org.eclipse.jgit.revwalk.RevCommit;import com.google.common.base.Objects;@@ -133,8 +137,9 @@ public abstract class RevisionDiffPanel extends Panel {protected ChangesAndCount load() {List<DiffEntry> diffEntries = diffEntriesModel.getObject();- List<BlobChange> filterChanges = new ArrayList<>();- for (DiffEntry entry: diffEntries) {+ Set<String> changedPaths = new HashSet<>();+ List<BlobChange> allChanges = new ArrayList<>();+ for (DiffEntry entry: diffEntries) {BlobChange change = new BlobChange(oldRev, newRev, entry, whitespaceOption) {@Override@@ -143,6 +148,30 @@ public abstract class RevisionDiffPanel extends Panel {}};+ allChanges.add(change);+ changedPaths.addAll(change.getPaths());+ }++ Set<String> commentedPaths = new HashSet<>();+ for (CodeComment comment: commentsModel.getObject()) {+ if (!changedPaths.contains(comment.getPath())+ && !commentedPaths.contains(comment.getPath())) {+ BlobIdent oldBlobIdent = new BlobIdent(oldRev, comment.getPath(), FileMode.TYPE_FILE);+ BlobIdent newBlobIdent = new BlobIdent(newRev, comment.getPath(), FileMode.TYPE_FILE);+ allChanges.add(new BlobChange(null, oldBlobIdent, newBlobIdent, whitespaceOption) {++ @Override+ public Blob getBlob(BlobIdent blobIdent) {+ return depotModel.getObject().getBlob(blobIdent);+ }++ });+ }+ commentedPaths.add(comment.getPath());+ }++ List<BlobChange> filterChanges = new ArrayList<>();+ for (BlobChange change: allChanges) {if (StringUtils.isNotBlank(pathFilter)) {String matchWith = pathFilter.toLowerCase().trim();matchWith = StringUtils.stripStart(matchWith, "/");@@ -193,6 +222,9 @@ public abstract class RevisionDiffPanel extends Panel {normalizedChanges.add(change);}}++ normalizedChanges.sort((change1, change2)+ ->Paths.get(change1.getPath()).compareTo(Paths.get(change2.getPath())));List<BlobChange> diffChanges = new ArrayList<>();if (normalizedChanges.size() > Constants.MAX_DIFF_FILES)@@ -224,13 +256,15 @@ public abstract class RevisionDiffPanel extends Panel {}int totalChanges = normalizedChanges.size();+if (diffChanges.size() == totalChanges) {// some changes should be removed if content is the same after line processingfor (Iterator<BlobChange> it = diffChanges.iterator(); it.hasNext();) {BlobChange change = it.next();if (change.getType() == ChangeType.MODIFY&& Objects.equal(change.getOldBlobIdent().mode, change.getNewBlobIdent().mode)- && change.getAdditions() + change.getDeletions() == 0) {+ && change.getAdditions() + change.getDeletions() == 0+ && !commentedPaths.contains(change.getPath())) {Blob.Text oldText = change.getOldText();Blob.Text newText = change.getNewText();if (oldText != null && newText != null@@ -275,9 +309,13 @@ public abstract class RevisionDiffPanel extends Panel {@Overrideprotected Collection<CodeComment> load() {- Depot depot = depotModel.getObject();- return GitPlex.getInstance(CodeCommentManager.class).query(- depot, depot.getRevCommit(oldRev), depot.getRevCommit(newRev));+ if (markSupport != null) {+ Depot depot = depotModel.getObject();+ return GitPlex.getInstance(CodeCommentManager.class).query(+ depot, depot.getRevCommit(oldRev), depot.getRevCommit(newRev));+ } else {+ return new ArrayList<>();+ }}};@@ -423,31 +461,37 @@ public abstract class RevisionDiffPanel extends Panel {}));- List<String> diffPaths = new ArrayList<>();+ Set<String> setOfInvolvedPaths = new HashSet<>();for (DiffEntry diffEntry: diffEntriesModel.getObject()) {if (diffEntry.getChangeType() == DiffEntry.ChangeType.ADD) {- diffPaths.add(diffEntry.getNewPath());+ setOfInvolvedPaths.add(diffEntry.getNewPath());} else if (diffEntry.getChangeType() == DiffEntry.ChangeType.COPY) {- diffPaths.add(diffEntry.getNewPath());- diffPaths.add(diffEntry.getOldPath());+ setOfInvolvedPaths.add(diffEntry.getNewPath());+ setOfInvolvedPaths.add(diffEntry.getOldPath());} else if (diffEntry.getChangeType() == DiffEntry.ChangeType.DELETE) {- diffPaths.add(diffEntry.getOldPath());+ setOfInvolvedPaths.add(diffEntry.getOldPath());} else if (diffEntry.getChangeType() == DiffEntry.ChangeType.MODIFY) {- diffPaths.add(diffEntry.getNewPath());+ setOfInvolvedPaths.add(diffEntry.getNewPath());} else if (diffEntry.getChangeType() == DiffEntry.ChangeType.RENAME) {- diffPaths.add(diffEntry.getNewPath());- diffPaths.add(diffEntry.getOldPath());+ setOfInvolvedPaths.add(diffEntry.getNewPath());+ setOfInvolvedPaths.add(diffEntry.getOldPath());} else {throw new IllegalStateException();}}+ for (CodeComment comment: commentsModel.getObject()) {+ setOfInvolvedPaths.add(comment.getPath());+ }++ List<String> listOfInvolvedPaths = new ArrayList<>(setOfInvolvedPaths);+ listOfInvolvedPaths.sort((path1, path2)->Paths.get(path1).compareTo(Paths.get(path2)));filterInput.add(new InputAssistBehavior() {@Overrideprotected List<InputCompletion> getSuggestions(InputStatus inputStatus, int count) {List<InputCompletion> completions = new ArrayList<>();- for (InputSuggestion suggestion: SuggestionUtils.suggestPath(diffPaths,+ for (InputSuggestion suggestion: SuggestionUtils.suggestPath(listOfInvolvedPaths,inputStatus.getContentBeforeCaret().trim(), count)) {int caret = suggestion.getCaret();if (caret == -1)@@ -621,7 +665,7 @@ public abstract class RevisionDiffPanel extends Panel {@Overridepublic String getObject() {- return changesAndCountModel.getObject().getChanges().size() + " changed files ";+ return changesAndCountModel.getObject().getChanges().size() + " changed or commented files ";}}));@@ -659,7 +703,9 @@ public abstract class RevisionDiffPanel extends Panel {protected void populateItem(ListItem<BlobChange> item) {BlobChange change = item.getModelObject();String iconClass;- if (change.getType() == ChangeType.ADD || change.getType() == ChangeType.COPY)+ if (change.getType() == null) {+ iconClass = " fa fa-commenting";+ } else if (change.getType() == ChangeType.ADD || change.getType() == ChangeType.COPY)iconClass = " fa-ext fa-diff-added";else if (change.getType() == ChangeType.DELETE)iconClass = " fa-ext fa-diff-removed";diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.cssindex e74665e247..e8f181f35a 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.css+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.css@@ -27,6 +27,7 @@}.revision-diff>.body>.diff-stats>.diff-stat>.icon {margin-top: 2px;+ margin-right: 0;}.revision-diff>.body>.diff-stats>.diff-stat .fa-diff-modified,.revision-diff>.body>.diff-stats>.diff-stat .fa-diff-renamed {