The Unified and Autonomous Development Platform
midwork
robin shinef4cbad6d6cc0
diff --git a/commons.git/src/main/java/com/pmease/commons/git/Blob.java b/commons.git/src/main/java/com/pmease/commons/git/Blob.javaindex 54463250e3..dfff85acb3 100644--- a/commons.git/src/main/java/com/pmease/commons/git/Blob.java+++ b/commons.git/src/main/java/com/pmease/commons/git/Blob.java@@ -112,10 +112,10 @@ public class Blob {return content;}- public List<String> getLines(LineProcessor processor) {+ public List<String> getLines(WhitespaceOption whitespaceOption) {List<String> processedLines = new ArrayList<>();for (String line: getLines())- processedLines.add(processor.process(line));+ processedLines.add(whitespaceOption.process(line));return processedLines;}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 b41c555540..3120bbd564 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@@ -20,22 +20,28 @@ public abstract class BlobChange implements Serializable {protected final ChangeType type;+ protected final WhitespaceOption whitespaceOption;+protected final BlobIdent oldBlobIdent;protected final BlobIdent newBlobIdent;private transient List<DiffBlock<List<CmToken>>> diffBlocks;- public BlobChange(String oldRev, String newRev, DiffEntry diffEntry) {+ public BlobChange(String oldRev, String newRev, DiffEntry diffEntry,+ WhitespaceOption whitespaceOption) {type = diffEntry.getChangeType();+ this.whitespaceOption = whitespaceOption;oldBlobIdent = GitUtils.getOldBlobIdent(diffEntry, oldRev);newBlobIdent = GitUtils.getNewBlobIdent(diffEntry, newRev);}- public BlobChange(ChangeType type, BlobIdent oldBlobIdent, BlobIdent newBlobIdent) {+ public BlobChange(ChangeType type, BlobIdent oldBlobIdent, BlobIdent newBlobIdent,+ WhitespaceOption whitespaceOption) {this.type = type;this.oldBlobIdent = oldBlobIdent;this.newBlobIdent = newBlobIdent;+ this.whitespaceOption = whitespaceOption;}public ChangeType getType() {@@ -63,7 +69,7 @@ public abstract class BlobChange implements Serializable {try {if (type == ChangeType.ADD || type == ChangeType.COPY) {if (getNewText() != null) {- List<String> newLines = getNewText().getLines(getLineProcessor());+ List<String> newLines = getNewText().getLines(whitespaceOption);if (newLines.size() <= DiffUtils.MAX_DIFF_SIZE) {List<String> oldLines = new ArrayList<>();diffBlocks = DiffUtils.diff(@@ -77,7 +83,7 @@ public abstract class BlobChange implements Serializable {}} else if (type == ChangeType.DELETE) {if (getOldText() != null) {- List<String> oldLines = getOldText().getLines(getLineProcessor());+ List<String> oldLines = getOldText().getLines(whitespaceOption);if (oldLines.size() <= DiffUtils.MAX_DIFF_SIZE) {List<String> newLines = new ArrayList<>();diffBlocks = DiffUtils.diff(@@ -93,8 +99,8 @@ public abstract class BlobChange implements Serializable {diffBlocks = new ArrayList<>();} else {if (getOldText() != null && getNewText() != null) {- List<String> oldLines = getOldText().getLines(getLineProcessor());- List<String> newLines = getNewText().getLines(getLineProcessor());+ List<String> oldLines = getOldText().getLines(whitespaceOption);+ List<String> newLines = getNewText().getLines(whitespaceOption);if (oldLines.size() + newLines.size() <= DiffUtils.MAX_DIFF_SIZE)diffBlocks = DiffUtils.diff(oldLines, oldBlobIdent.isFile()?newBlobIdent.path:null,@@ -152,6 +158,4 @@ public abstract class BlobChange implements Serializable {public abstract Blob getBlob(BlobIdent blobIdent);- public abstract LineProcessor getLineProcessor();-}diff --git a/commons.git/src/main/java/com/pmease/commons/git/LineProcessor.java b/commons.git/src/main/java/com/pmease/commons/git/LineProcessor.javadeleted file mode 100644index 6a1690d401..0000000000--- a/commons.git/src/main/java/com/pmease/commons/git/LineProcessor.java+++ /dev/null@@ -1,9 +0,0 @@-package com.pmease.commons.git;--public interface LineProcessor {-- String getName();-- String process(String line);--}\ No newline at end of filediff --git a/commons.git/src/main/java/com/pmease/commons/git/WhitespaceOption.java b/commons.git/src/main/java/com/pmease/commons/git/WhitespaceOption.javanew file mode 100644index 0000000000..4c8242d8ed--- /dev/null+++ b/commons.git/src/main/java/com/pmease/commons/git/WhitespaceOption.java@@ -0,0 +1,118 @@+package com.pmease.commons.git;++import java.util.regex.Pattern;++import javax.annotation.Nullable;++import org.apache.commons.lang3.StringUtils;+import org.eclipse.jgit.diff.RawTextComparator;++public enum WhitespaceOption {++ DEFAULT() {++ @Override+ public String process(String line) {+ return line;+ }++ @Override+ public RawTextComparator getComparator() {+ return RawTextComparator.DEFAULT;+ }++ @Override+ public String getDescription() {+ return "Do not ignore white spaces";+ }++ },+ IGNORE_LEADING() {++ @Override+ public String process(String line) {+ return StringUtils.stripStart(line, " \t\r\n");+ }++ @Override+ public RawTextComparator getComparator() {+ return RawTextComparator.WS_IGNORE_LEADING;+ }++ @Override+ public String getDescription() {+ return "Ignore leading white spaces";+ }++ },+ IGNORE_TRAILING() {++ @Override+ public String process(String line) {+ return StringUtils.stripEnd(line, " \t\r\n");+ }++ @Override+ public RawTextComparator getComparator() {+ return RawTextComparator.WS_IGNORE_TRAILING;+ }++ @Override+ public String getDescription() {+ return "Ignore trailing white spaces";+ }++ },+ IGNORE_CHANGE() {++ @Override+ public String process(String line) {+ return WHITESPACE_PATTERN.matcher(line.trim()).replaceAll(" ");+ }++ @Override+ public RawTextComparator getComparator() {+ return RawTextComparator.WS_IGNORE_CHANGE;+ }++ @Override+ public String getDescription() {+ return "Ignore white space changes";+ }++ },+ IGNORE_ALL() {++ @Override+ public String process(String line) {+ return WHITESPACE_PATTERN.matcher(line.trim()).replaceAll(" ");+ }++ @Override+ public RawTextComparator getComparator() {+ return RawTextComparator.WS_IGNORE_ALL;+ }++ @Override+ public String getDescription() {+ return "Ignore all white spaces";+ }++ };++ private static final Pattern WHITESPACE_PATTERN = Pattern.compile("\\s+");++ public abstract String getDescription();++ public abstract String process(String line);++ public abstract RawTextComparator getComparator();++ public static WhitespaceOption of(@Nullable String name) {+ if (name != null) {+ return valueOf(name);+ } else {+ return DEFAULT;+ }+ }+}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Depot.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Depot.javaindex 33085cdff7..8162feab04 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Depot.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Depot.java@@ -35,6 +35,8 @@ import org.eclipse.jgit.api.TagCommand;import org.eclipse.jgit.api.errors.GitAPIException;import org.eclipse.jgit.diff.DiffEntry;import org.eclipse.jgit.diff.DiffFormatter;+import org.eclipse.jgit.diff.MyersDiff;+import org.eclipse.jgit.diff.RawTextComparator;import org.eclipse.jgit.errors.MissingObjectException;import org.eclipse.jgit.errors.RevisionSyntaxException;import org.eclipse.jgit.lib.AnyObjectId;@@ -54,7 +56,6 @@ import org.eclipse.jgit.revwalk.RevTree;import org.eclipse.jgit.revwalk.RevWalk;import org.eclipse.jgit.revwalk.filter.RevFilter;import org.eclipse.jgit.treewalk.TreeWalk;-import org.eclipse.jgit.treewalk.filter.PathFilter;import org.eclipse.jgit.util.io.NullOutputStream;import org.hibernate.annotations.Cache;import org.hibernate.annotations.CacheConcurrencyStrategy;@@ -686,20 +687,20 @@ public class Depot extends AbstractEntity implements AccountBelonging {objectIdCache.put(revision, Optional.fromNullable(objectId));}- public List<DiffEntry> getDiffs(String oldRev, String newRev, boolean detectRenames, @Nullable String path) {+ public List<DiffEntry> getDiffs(String oldRev, String newRev) {if (diffCache == null)diffCache = new HashMap<>();- DiffKey key = new DiffKey(oldRev, newRev, detectRenames, path);+ DiffKey key = new DiffKey(oldRev, newRev);List<DiffEntry> diffs = diffCache.get(key);if (diffs == null) {try (DiffFormatter diffFormatter = new DiffFormatter(NullOutputStream.INSTANCE);) {diffFormatter.setRepository(getRepository());- diffFormatter.setDetectRenames(detectRenames);+ diffFormatter.setDetectRenames(true);+ diffFormatter.setDiffAlgorithm(MyersDiff.INSTANCE);+ diffFormatter.setDiffComparator(RawTextComparator.DEFAULT);AnyObjectId oldCommitId = getObjectId(oldRev);AnyObjectId newCommitId = getObjectId(newRev);- if (path != null)- diffFormatter.setPathFilter(PathFilter.create(path));diffs = new ArrayList<>();for (DiffEntry entry: diffFormatter.scan(oldCommitId, newCommitId)) {if (!Objects.equal(entry.getOldPath(), entry.getNewPath())@@ -998,16 +999,10 @@ public class Depot extends AbstractEntity implements AccountBelonging {String oldRev;String newRev;-- String path;-- boolean detectRenames;-- DiffKey(String oldRev, String newRev, boolean detectRenames, @Nullable String path) {++ DiffKey(String oldRev, String newRev) {this.oldRev = oldRev;this.newRev = newRev;- this.detectRenames = detectRenames;- this.path = path;}public boolean equals(Object other) {@@ -1017,13 +1012,11 @@ public class Depot extends AbstractEntity implements AccountBelonging {return true;DiffKey otherKey = (DiffKey) other;return Objects.equal(oldRev, otherKey.oldRev)- && Objects.equal(newRev, otherKey.newRev)- && Objects.equal(path, otherKey.path)- && Objects.equal(detectRenames, otherKey.detectRenames);+ && Objects.equal(newRev, otherKey.newRev);}public int hashCode() {- return Objects.hashCode(oldRev, newRev, path, detectRenames);+ return Objects.hashCode(oldRev, newRev);}}diff --git a/gitplex.product/src/test/java/gitplex/product/Test.java b/gitplex.product/src/test/java/gitplex/product/Test.javaindex 4c20719c54..4f2b20a36b 100644--- a/gitplex.product/src/test/java/gitplex/product/Test.java+++ b/gitplex.product/src/test/java/gitplex/product/Test.java@@ -1,8 +1,13 @@package gitplex.product;+import java.io.IOException;++import org.eclipse.jgit.errors.RepositoryNotFoundException;+public class Test {@org.junit.Test- public void test() {+ public void test() throws RepositoryNotFoundException, IOException {}+}\ 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 72a34e1bb4..5a6f5f27f5 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@@ -21,7 +21,7 @@ import com.pmease.gitplex.web.Constants;import com.pmease.gitplex.web.component.diff.DiffRenderer;import com.pmease.gitplex.web.component.diff.blob.text.TextDiffPanel;import com.pmease.gitplex.web.component.diff.difftitle.BlobDiffTitle;-import com.pmease.gitplex.web.component.diff.revision.DiffMode;+import com.pmease.gitplex.web.component.diff.revision.DiffViewMode;@SuppressWarnings("serial")public class BlobDiffPanel extends Panel {@@ -34,10 +34,10 @@ public class BlobDiffPanel extends Panel {private final BlobChange change;- private final DiffMode diffMode;+ private final DiffViewMode diffMode;public BlobDiffPanel(String id, IModel<Depot> depotModel,- IModel<PullRequest> requestModel, BlobChange change, DiffMode diffMode) {+ IModel<PullRequest> requestModel, BlobChange change, DiffViewMode diffMode) {super(id);this.depotModel = depotModel;diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/TextDiffPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/TextDiffPanel.javaindex 6eb74e9f3f..c1365cf6e0 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/TextDiffPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/TextDiffPanel.java@@ -49,7 +49,7 @@ import com.pmease.gitplex.web.Constants;import com.pmease.gitplex.web.component.diff.blob.text.MarkAwareDiffBlock.Type;import com.pmease.gitplex.web.component.diff.diffstat.DiffStatBar;import com.pmease.gitplex.web.component.diff.difftitle.BlobDiffTitle;-import com.pmease.gitplex.web.component.diff.revision.DiffMode;+import com.pmease.gitplex.web.component.diff.revision.DiffViewMode;import com.pmease.gitplex.web.component.repofile.blobview.BlobViewContext.Mode;import com.pmease.gitplex.web.component.symboltooltip.SymbolTooltipPanel;import com.pmease.gitplex.web.page.depot.file.DepotFilePage;@@ -73,7 +73,7 @@ public class TextDiffPanel extends Panel {private final Map<Integer, Integer> contextSizes = new HashMap<>();- private final DiffMode diffMode;+ private final DiffViewMode diffMode;private MarkInfo markInfo;@@ -84,7 +84,7 @@ public class TextDiffPanel extends Panel {private transient List<MarkAwareDiffBlock> diffBlocks;public TextDiffPanel(String id, IModel<Depot> depotModel, IModel<PullRequest> requestModel,- BlobChange change, DiffMode diffMode) {+ BlobChange change, DiffViewMode diffMode) {super(id);this.depotModel = depotModel;@@ -285,7 +285,7 @@ public class TextDiffPanel extends Panel {private String renderDiffs() {int contextSize = CodeComment.DIFF_CONTEXT_SIZE;StringBuilder builder = new StringBuilder();- if (diffMode == DiffMode.UNIFIED) {+ if (diffMode == DiffViewMode.UNIFIED) {builder.append(""+ "<colgroup>"+ "<col width='40'></col>"@@ -354,7 +354,7 @@ public class TextDiffPanel extends Panel {private void appendDeletesAndInserts(StringBuilder builder, MarkAwareDiffBlock deleteBlock,MarkAwareDiffBlock insertBlock, int fromDeleteLineIndex, int toDeleteLineIndex,int fromInsertLineIndex, int toInsertLineIndex) {- if (diffMode == DiffMode.UNIFIED) {+ if (diffMode == DiffViewMode.UNIFIED) {for (int i=fromDeleteLineIndex; i<toDeleteLineIndex; i++)appendDelete(builder, deleteBlock, i);for (int i=fromInsertLineIndex; i<toInsertLineIndex; i++)@@ -385,7 +385,7 @@ public class TextDiffPanel extends Panel {int oldLineNo = block.getOldStart() + lineIndex;int newLineNo = block.getNewStart() + lineIndex;- if (diffMode == DiffMode.UNIFIED) {+ if (diffMode == DiffViewMode.UNIFIED) {builder.append("<td class='number noselect'>").append(oldLineNo+1).append("</td>");builder.append("<td class='number noselect'>").append(newLineNo+1).append("</td>");builder.append("<td class='operation noselect'> </td>");@@ -432,7 +432,7 @@ public class TextDiffPanel extends Panel {builder.append("<tr class='code original'>");int newLineNo = block.getNewStart() + lineIndex;- if (diffMode == DiffMode.UNIFIED) {+ if (diffMode == DiffViewMode.UNIFIED) {builder.append("<td class='number noselect new'> </td>");builder.append("<td class='number noselect new'>").append(newLineNo+1).append("</td>");builder.append("<td class='operation noselect new'>+</td>");@@ -468,7 +468,7 @@ public class TextDiffPanel extends Panel {builder.append("<tr class='code original'>");int oldLineNo = block.getOldStart() + lineIndex;- if (diffMode == DiffMode.UNIFIED) {+ if (diffMode == DiffViewMode.UNIFIED) {builder.append("<td class='number noselect old'>").append(oldLineNo+1).append("</td>");builder.append("<td class='number noselect old'> </td>");builder.append("<td class='operation noselect old'>-</td>");@@ -540,7 +540,7 @@ public class TextDiffPanel extends Panel {int oldLineNo = deleteBlock.getOldStart() + deleteLineIndex;int newLineNo = insertBlock.getNewStart() + insertLineIndex;- if (diffMode == DiffMode.UNIFIED) {+ if (diffMode == DiffViewMode.UNIFIED) {builder.append("<td class='number noselect old new'>").append(oldLineNo+1).append("</td>");builder.append("<td class='number noselect old new'>").append(newLineNo+1).append("</td>");builder.append("<td class='operation noselect old new'>*</td>");@@ -596,7 +596,7 @@ public class TextDiffPanel extends Panel {+ "var callback = $('#%s').data('callback');"+ "if (callback) callback('expand', %d);",getMarkupId(), blockIndex);- if (diffMode == DiffMode.UNIFIED) {+ if (diffMode == DiffViewMode.UNIFIED) {builder.append("<td colspan='2' class='expander noselect'><a title='Show more lines' href=\"").append(script).append("\"><i class='fa fa-sort'></i></a></td>");builder.append("<td colspan='2' class='skipped noselect'><i class='fa fa-ellipsis-h'></i> skipped ")diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/DiffMode.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/DiffViewMode.javasimilarity index 73%rename from gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/DiffMode.javarename to gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/DiffViewMode.javaindex c6cec3df9d..43ee6152c1 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/DiffMode.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/DiffViewMode.java@@ -1,5 +1,5 @@package com.pmease.gitplex.web.component.diff.revision;-public enum DiffMode {+public enum DiffViewMode {UNIFIED, SPLIT}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/LineProcessOption.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/LineProcessOption.javadeleted file mode 100644index f0f1489812..0000000000--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/LineProcessOption.java+++ /dev/null@@ -1,66 +0,0 @@-package com.pmease.gitplex.web.component.diff.revision;--import java.util.regex.Pattern;--import org.apache.commons.lang3.StringUtils;--import com.pmease.commons.git.LineProcessor;--public enum LineProcessOption implements LineProcessor {-- IGNORE_NOTHING() {-- @Override- public String process(String line) {- return line;- }-- @Override- public String getName() {- return "Compare using original lines";- }-- },- IGNORE_EOL() {-- @Override- public String process(String line) {- return StringUtils.stripEnd(line, "\r\n");- }-- @Override- public String getName() {- return "Ignore end of line differences";- }-- },- IGNORE_EOL_SPACES() {-- @Override- public String process(String line) {- return StringUtils.stripEnd(line, " \t\r\n");- }-- @Override- public String getName() {- return "Ignore white spaces at line end";- }-- },- IGNORE_CHANGE_SPACES() {-- @Override- public String process(String line) {- return WHITESPACE_PATTERN.matcher(line.trim()).replaceAll(" ");- }-- @Override- public String getName() {- return "Ignore white space changes";- }-- };-- private static final Pattern WHITESPACE_PATTERN = Pattern.compile("\\s+");--}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.htmlindex 3634d8c213..2d92ba2d45 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.html@@ -1,8 +1,28 @@<wicket:panel><div class="revision-diff">+ <div class="option clearfix">+ <div class="pull-left">+ <form wicket:id="pathFilter" class="form-inline path-filter">+ <div class="input-group">+ <input wicket:id="input" class="form-control" placeholder="Filter by path pattern" type="text"></input>+ <span class="input-group-btn">+ <button wicket:id="submit" title="Filter" class="btn btn-default" type="submit"><i class="fa fa-filter"></i></button>+ </span>+ </div>+ </form>+ </div>+ <div class="pull-right view-mode">+ <span class="btn-group">+ <a wicket:id="unified" class="btn btn-default">Unified</a>+ <a wicket:id="split" class="btn btn-default">Split</a>+ </span>+ </div>+ <div class="pull-right">+ <select wicket:id="whitespaceOption" class="form-control"></select>+ </div>+ </div><div class="title">Total <a wicket:id="totalChanged" class="total-changed"></a>- <span wicket:id="filterPath"></span> <a wicket:id="clearPath" title="Clear filter path"><i class="fa fa-times"></i></a></div><div wicket:id="tooManyChanges" class="alert alert-warning">Sorry we are unable to display the full diff as there are too many changes</div><ul wicket:id="diffStats" class="diff-stats list-unstyled">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 011859aeea..2b96711bc0 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@@ -16,7 +16,9 @@ import org.apache.wicket.AttributeModifier;import org.apache.wicket.Component;import org.apache.wicket.ajax.AjaxRequestTarget;import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;+import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;import org.apache.wicket.ajax.markup.html.AjaxLink;+import org.apache.wicket.ajax.markup.html.form.AjaxButton;import org.apache.wicket.behavior.AttributeAppender;import org.apache.wicket.markup.head.CssHeaderItem;import org.apache.wicket.markup.head.IHeaderResponse;@@ -24,6 +26,10 @@ import org.apache.wicket.markup.head.JavaScriptHeaderItem;import org.apache.wicket.markup.head.OnDomReadyHeaderItem;import org.apache.wicket.markup.html.WebMarkupContainer;import org.apache.wicket.markup.html.basic.Label;+import org.apache.wicket.markup.html.form.DropDownChoice;+import org.apache.wicket.markup.html.form.Form;+import org.apache.wicket.markup.html.form.IChoiceRenderer;+import org.apache.wicket.markup.html.form.TextField;import org.apache.wicket.markup.html.list.ListItem;import org.apache.wicket.markup.html.list.ListView;import org.apache.wicket.markup.html.panel.Panel;@@ -32,19 +38,24 @@ import org.apache.wicket.model.IModel;import org.apache.wicket.model.LoadableDetachableModel;import org.apache.wicket.request.cycle.RequestCycle;import org.apache.wicket.request.http.WebRequest;+import org.apache.wicket.request.http.WebResponse;import org.apache.wicket.request.resource.CssResourceReference;import org.apache.wicket.request.resource.JavaScriptResourceReference;-import org.apache.wicket.util.lang.Objects;import org.eclipse.jgit.diff.DiffEntry;import org.eclipse.jgit.diff.DiffEntry.ChangeType;+import com.google.common.base.Objects;+import com.google.common.base.Preconditions;import com.pmease.commons.git.Blob;import com.pmease.commons.git.BlobChange;import com.pmease.commons.git.BlobIdent;-import com.pmease.commons.git.LineProcessor;+import com.pmease.commons.git.WhitespaceOption;import com.pmease.commons.lang.diff.DiffUtils;+import com.pmease.commons.util.StringUtils;+import com.pmease.commons.util.match.WildcardUtils;import com.pmease.commons.wicket.ajaxlistener.ConfirmLeaveListener;import com.pmease.commons.wicket.ajaxlistener.IndicateLoadingListener;+import com.pmease.commons.wicket.assets.clearable.ClearableResourceReference;import com.pmease.commons.wicket.assets.cookies.CookiesResourceReference;import com.pmease.commons.wicket.assets.uri.URIResourceReference;import com.pmease.gitplex.core.GitPlex;@@ -57,6 +68,8 @@ import com.pmease.gitplex.web.component.diff.diffstat.DiffStatBar;@SuppressWarnings("serial")public abstract class RevisionDiffPanel extends Panel {+ private static final String COOKIE_VIEW_MODE = "gitplex.diff.viewmode";+private final IModel<Depot> depotModel;private final IModel<PullRequest> requestModel;@@ -65,11 +78,11 @@ public abstract class RevisionDiffPanel extends Panel {private final String newRev;- private final String path;+ private String pathFilter;- private final LineProcessor lineProcessor;+ private WhitespaceOption whitespaceOption;- private final DiffMode diffMode;+ private DiffViewMode diffMode;private IModel<ChangesAndCount> changesAndCountModel = new LoadableDetachableModel<ChangesAndCount>() {@@ -77,70 +90,38 @@ public abstract class RevisionDiffPanel extends Panel {protected ChangesAndCount load() {String oldCommitHash = depotModel.getObject().getObjectId(oldRev).name();String newCommitHash = depotModel.getObject().getObjectId(newRev).name();- List<String> paths = new ArrayList<>();- if (path != null)- paths.add(path);- List<DiffEntry> diffEntries = depotModel.getObject().getDiffs(oldCommitHash, newCommitHash, true, path);+ List<DiffEntry> diffEntries = depotModel.getObject()+ .getDiffs(oldCommitHash, newCommitHash);- /*- * If a single path is specified, JGit will not detect renames, hence we add logic below- * to make rename detection possible- */- boolean renamePossible = false;- if (path != null) {- for (DiffEntry entry: diffEntries) {- if ((entry.getChangeType() == ChangeType.ADD || entry.getChangeType() == ChangeType.DELETE)- && (path.equals(entry.getOldPath()) || path.equals(entry.getNewPath()))) {- renamePossible = true;- break;- }- }- }- if (renamePossible) {- diffEntries = depotModel.getObject().getDiffs(oldCommitHash, newCommitHash, true, null);- for (Iterator<DiffEntry> it = diffEntries.iterator(); it.hasNext();) {- DiffEntry entry = it.next();- boolean oldPathMatches = false;- if (entry.getOldPath() != null && entry.getOldPath().startsWith(path)) {- String subpath = entry.getOldPath().substring(path.length());- oldPathMatches = subpath.length() == 0 || subpath.charAt(0) == '/';- }- boolean newPathMatches = false;- if (entry.getNewPath() != null && entry.getNewPath().startsWith(path)) {- String subpath = entry.getNewPath().substring(path.length());- newPathMatches = subpath.length() == 0 || subpath.charAt(0) == '/';- }- if (!oldPathMatches && !newPathMatches)- it.remove();- }- }-- List<BlobChange> diffableChanges = new ArrayList<>();+ List<BlobChange> filterChanges = new ArrayList<>();for (DiffEntry entry: diffEntries) {- if (diffableChanges.size() < Constants.MAX_DIFF_FILES) {- diffableChanges.add(new BlobChange(oldRev, newRev, entry) {-- @Override- public Blob getBlob(BlobIdent blobIdent) {- return depotModel.getObject().getBlob(blobIdent);- }+ BlobChange change = new BlobChange(oldRev, newRev, entry, whitespaceOption) {- @Override- public LineProcessor getLineProcessor() {- return lineProcessor;- }+ @Override+ public Blob getBlob(BlobIdent blobIdent) {+ return depotModel.getObject().getBlob(blobIdent);+ }- });+ };+ String pattern = pathFilter;+ if (StringUtils.isNotBlank(pattern)) {+ if (WildcardUtils.matchString(pattern, change.getPath()))+ filterChanges.add(change);} else {- break;+ filterChanges.add(change);}}-- long time = System.currentTimeMillis();++ List<BlobChange> diffChanges = new ArrayList<>();+ if (filterChanges.size() > Constants.MAX_DIFF_FILES)+ diffChanges = filterChanges.subList(0, Constants.MAX_DIFF_FILES);+ else+ diffChanges = filterChanges;+// Diff calculation can be slow, so we pre-load diffs of each change// concurrentlyCollection<Callable<Void>> tasks = new ArrayList<>();- for (final BlobChange change: diffableChanges) {+ for (BlobChange change: diffChanges) {tasks.add(new Callable<Void>() {@Override@@ -159,12 +140,11 @@ public abstract class RevisionDiffPanel extends Panel {throw new RuntimeException(e);}}- System.out.println(System.currentTimeMillis()-time);-- int totalChanges = diffEntries.size();- if (diffableChanges.size() == totalChanges) {++ int totalChanges = filterChanges.size();+ if (diffChanges.size() == totalChanges) {// some changes should be removed if content is the same after line processing- for (Iterator<BlobChange> it = diffableChanges.iterator(); it.hasNext();) {+ for (Iterator<BlobChange> it = diffChanges.iterator(); it.hasNext();) {BlobChange change = it.next();if (change.getType() == ChangeType.MODIFY&& Objects.equal(change.getOldBlobIdent().mode, change.getNewBlobIdent().mode)@@ -177,90 +157,193 @@ public abstract class RevisionDiffPanel extends Panel {}}}- totalChanges = diffableChanges.size();+ totalChanges = diffChanges.size();}-- List<BlobChange> displayableChanges = new ArrayList<>();++ List<BlobChange> displayChanges = new ArrayList<>();int totalChangedLines = 0;- for (BlobChange change: diffableChanges) {+ for (BlobChange change: diffChanges) {int changedLines = change.getAdditions() + change.getDeletions();-- // we do not count large diff in a single file in order to- // display smaller diffs from different files as many as- // possible.+ /*+ * we do not count large diff in a single file in order to+ * display smaller diffs from different files as many as+ * possible+ */if (changedLines <= Constants.MAX_SINGLE_FILE_DIFF_LINES) {totalChangedLines += changedLines;if (totalChangedLines <= Constants.MAX_DIFF_LINES)- displayableChanges.add(change);+ displayChanges.add(change);elsebreak;} else {- // large diff in a single file will not be displayed, so- // adding it to change list will do no harm, and can avoid- // displaying "too many changes" when some big text file- // is added/removed without touching too many files- displayableChanges.add(change);+ /*+ * large diff in a single file will not be displayed, but+ * we still add it into the list as otherwise we may+ * incorrectly display the "too many changed files" warning+ */+ displayChanges.add(change);}}- return new ChangesAndCount(displayableChanges, totalChanges);+ return new ChangesAndCount(displayChanges, totalChanges);}};public RevisionDiffPanel(String id, IModel<Depot> depotModel, IModel<PullRequest> requestModel,- String oldRev, String newRev, @Nullable String path,- LineProcessor lineProcessor, DiffMode diffMode) {+ String oldRev, String newRev, @Nullable String pathFilter,+ WhitespaceOption whitespaceOption) {super(id);this.depotModel = depotModel;this.requestModel = requestModel;this.oldRev = oldRev;this.newRev = newRev;- this.path = path;- this.lineProcessor = lineProcessor;- this.diffMode = diffMode;+ this.pathFilter = pathFilter;+ this.whitespaceOption = whitespaceOption;++ WebRequest request = (WebRequest) RequestCycle.get().getRequest();+ Cookie cookie = request.getCookie(COOKIE_VIEW_MODE);+ if (cookie == null)+ diffMode = DiffViewMode.UNIFIED;+ else+ diffMode = DiffViewMode.valueOf(cookie.getValue());}@Overrideprotected void onInitialize() {super.onInitialize();- Component totalChangedLink;- add(totalChangedLink = new Label("totalChanged", new AbstractReadOnlyModel<String>() {+ List<WhitespaceOption> choices = new ArrayList<>();+ for (WhitespaceOption each: WhitespaceOption.values())+ choices.add(each);++ IModel<WhitespaceOption> choiceModel = new IModel<WhitespaceOption>() {++ @Override+ public void detach() {+ }++ @Override+ public WhitespaceOption getObject() {+ return whitespaceOption;+ }++ @Override+ public void setObject(WhitespaceOption object) {+ whitespaceOption = object;+ }++ };+ IChoiceRenderer<WhitespaceOption> choiceRenderer = new IChoiceRenderer<WhitespaceOption>() {++ @Override+ public Object getDisplayValue(WhitespaceOption object) {+ return object.getDescription();+ }++ @Override+ public String getIdValue(WhitespaceOption object, int index) {+ return object.name();+ }++ @Override+ public WhitespaceOption getObject(String id, IModel<? extends List<? extends WhitespaceOption>> choices) {+ return WhitespaceOption.valueOf(id);+ }+ };++ DropDownChoice<WhitespaceOption> whitespaceChoice =+ new DropDownChoice<WhitespaceOption>("whitespaceOption", choiceModel, choices, choiceRenderer);+ whitespaceChoice.add(new OnChangeAjaxBehavior() {++ @Override+ protected void onUpdate(AjaxRequestTarget target) {+ target.add(RevisionDiffPanel.this);+ onWhitespaceOptionChange(target, whitespaceOption);+ }++ });+ add(whitespaceChoice);++ Form<?> form = new Form<Void>("pathFilter") {++ @Override+ protected void onSubmit() {+ super.onSubmit();+ AjaxRequestTarget target = RequestCycle.get().find(AjaxRequestTarget.class);+ Preconditions.checkNotNull(target);+ target.add(RevisionDiffPanel.this);+ onPathFilterChange(target, pathFilter);+ }++ };+ form.add(new TextField<String>("input", new IModel<String>() {++ @Override+ public void detach() {+ }@Overridepublic String getObject() {- return getChangesCount() + " changed files ";+ return pathFilter;+ }++ @Override+ public void setObject(String object) {+ pathFilter = object;}}));- if (path != null) {- add(new Label("filterPath", "filter by " + path));- add(new AjaxLink<Void>("clearPath") {+ form.add(new AjaxButton("submit") {});+ add(form);++ for (DiffViewMode each: DiffViewMode.values()) {+ add(new AjaxLink<Void>(each.name().toLowerCase()) {@Overrideprotected void updateAjaxAttributes(AjaxRequestAttributes attributes) {super.updateAjaxAttributes(attributes);- attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(RevisionDiffPanel.this));attributes.getAjaxCallListeners().add(new IndicateLoadingListener());+ if (getDirtyContainer() != null)+ attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(getDirtyContainer()));}-+@Overridepublic void onClick(AjaxRequestTarget target) {- onClearPath(target);+ diffMode = each;+ WebResponse response = (WebResponse) RequestCycle.get().getResponse();+ Cookie cookie = new Cookie(COOKIE_VIEW_MODE, diffMode.name());+ cookie.setMaxAge(Integer.MAX_VALUE);+ response.addCookie(cookie);+ target.add(RevisionDiffPanel.this);}- });- } else {- add(new WebMarkupContainer("filterPath").setVisible(false));- add(new WebMarkupContainer("clearPath").setVisible(false));+ }.add(AttributeAppender.append("class", new LoadableDetachableModel<String>() {++ @Override+ protected String load() {+ return each==diffMode?" active":"";+ }++ })));}++ Component totalChangedLink;+ add(totalChangedLink = new Label("totalChanged", new AbstractReadOnlyModel<String>() {++ @Override+ public String getObject() {+ return changesAndCountModel.getObject().getChanges().size() + " changed files ";+ }++ }));add(new WebMarkupContainer("tooManyChanges") {@Overrideprotected void onConfigure() {super.onConfigure();- setVisible(getChanges().size() < getChangesCount());+ ChangesAndCount changesAndCount = changesAndCountModel.getObject();+ setVisible(changesAndCount.getChanges().size() < changesAndCount.getCount());}});@@ -278,7 +361,7 @@ public abstract class RevisionDiffPanel extends Panel {@Overridepublic List<BlobChange> getObject() {- return getChanges();+ return changesAndCountModel.getObject().getChanges();}}) {@@ -329,7 +412,7 @@ public abstract class RevisionDiffPanel extends Panel {@Overridepublic List<BlobChange> getObject() {- return getChanges();+ return changesAndCountModel.getObject().getChanges();}}) {@@ -342,15 +425,13 @@ public abstract class RevisionDiffPanel extends Panel {}});++ setOutputMarkupId(true);}- private List<BlobChange> getChanges() {- return changesAndCountModel.getObject().getChanges();- }-- private int getChangesCount() {- return changesAndCountModel.getObject().getCount();- }+ protected Component getDirtyContainer() {+ return null;+ };@Overrideprotected void onDetach() {@@ -365,6 +446,7 @@ public abstract class RevisionDiffPanel extends Panel {public void renderHead(IHeaderResponse response) {super.renderHead(response);response.render(JavaScriptHeaderItem.forReference(URIResourceReference.INSTANCE));+ response.render(JavaScriptHeaderItem.forReference(ClearableResourceReference.INSTANCE));response.render(JavaScriptHeaderItem.forReference(CookiesResourceReference.INSTANCE));response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(RevisionDiffPanel.class, "revision-diff.js")));@@ -376,8 +458,11 @@ public abstract class RevisionDiffPanel extends Panel {response.render(OnDomReadyHeaderItem.forScript(script));}- protected abstract void onClearPath(AjaxRequestTarget target);-+ protected abstract void onPathFilterChange(AjaxRequestTarget target, String pathFilter);++ protected abstract void onWhitespaceOptionChange(AjaxRequestTarget target,+ WhitespaceOption whitespaceOption);+private static class ChangesAndCount {private final List<BlobChange> changes;@@ -386,13 +471,27 @@ public abstract class RevisionDiffPanel extends Panel {public ChangesAndCount(List<BlobChange> changes, int count) {this.changes = changes;- this.count = count;+ this.count = count;}-++ /**+ * Get list of changes we are capable to handle, note that size of this list+ * might be less than total number of changes in order not to put heavy+ * burden on the system and browser+ *+ * @return+ * list of changes we are capable to handle+ */public List<BlobChange> getChanges() {return changes;}+ /**+ * Get total number of changes detected+ *+ * @return+ * total number of changes detected+ */public int getCount() {return count;}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/option/DiffOptionPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/option/DiffOptionPanel.htmldeleted file mode 100644index 75b2bdaf8b..0000000000--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/option/DiffOptionPanel.html+++ /dev/null@@ -1,14 +0,0 @@-<wicket:panel>- <span class="diff-option clearfix">- <span class="pull-left">- <span wicket:id="filter" class="btn btn-sm btn-default" title="Filter changes by path">- Filter by <i class="fa fa-caret-down"></i>- </span>- </span>- <span wicket:id="lineProcessor" class="line-process btn btn-sm btn-default pull-left" title="Line process options">White space <i class="caret"></i></span>- <span class="btn-group pull-right">- <a wicket:id="unified" class="btn btn-sm btn-default">Unified</a>- <a wicket:id="split" class="btn btn-sm btn-default">Split</a>- </span>- </span>-</wicket:panel>\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/option/DiffOptionPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/option/DiffOptionPanel.javadeleted file mode 100644index 725081da2a..0000000000--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/option/DiffOptionPanel.java+++ /dev/null@@ -1,216 +0,0 @@-package com.pmease.gitplex.web.component.diff.revision.option;--import java.util.ArrayList;-import java.util.List;--import javax.servlet.http.Cookie;--import org.apache.wicket.Component;-import org.apache.wicket.ajax.AjaxRequestTarget;-import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;-import org.apache.wicket.ajax.markup.html.AjaxLink;-import org.apache.wicket.behavior.AttributeAppender;-import org.apache.wicket.markup.head.CssHeaderItem;-import org.apache.wicket.markup.head.IHeaderResponse;-import org.apache.wicket.markup.html.link.AbstractLink;-import org.apache.wicket.markup.html.panel.Panel;-import org.apache.wicket.model.IModel;-import org.apache.wicket.model.LoadableDetachableModel;-import org.apache.wicket.request.cycle.RequestCycle;-import org.apache.wicket.request.http.WebRequest;-import org.apache.wicket.request.http.WebResponse;-import org.apache.wicket.request.resource.CssResourceReference;-import org.eclipse.jgit.lib.FileMode;--import com.pmease.commons.git.BlobIdent;-import com.pmease.commons.git.LineProcessor;-import com.pmease.commons.wicket.ajaxlistener.ConfirmLeaveListener;-import com.pmease.commons.wicket.ajaxlistener.IndicateLoadingListener;-import com.pmease.commons.wicket.component.DropdownLink;-import com.pmease.commons.wicket.component.menu.MenuItem;-import com.pmease.commons.wicket.component.menu.MenuLink;-import com.pmease.gitplex.core.entity.Depot;-import com.pmease.gitplex.web.component.diff.revision.DiffMode;-import com.pmease.gitplex.web.component.diff.revision.LineProcessOption;-import com.pmease.gitplex.web.component.pathselector.PathSelector;--@SuppressWarnings("serial")-public abstract class DiffOptionPanel extends Panel {-- private static final String COOKIE_DIFF_MODE = "gitplex.diff.mode";-- private final IModel<Depot> depotModel;-- private final String newRev;-- private LineProcessor lineProcessor = LineProcessOption.IGNORE_EOL_SPACES;-- private DiffMode diffMode;-- public DiffOptionPanel(String id, IModel<Depot> depotModel, String newRev) {- super(id);-- this.depotModel = depotModel;- this.newRev = newRev;-- WebRequest request = (WebRequest) RequestCycle.get().getRequest();- Cookie cookie = request.getCookie(COOKIE_DIFF_MODE);- if (cookie == null)- diffMode = DiffMode.UNIFIED;- else- diffMode = DiffMode.valueOf(cookie.getValue());- }-- @Override- protected void onInitialize() {- super.onInitialize();-- add(new MenuLink("lineProcessor") {-- @Override- protected List<MenuItem> getMenuItems() {- List<MenuItem> menuItems = new ArrayList<>();-- for (final LineProcessOption option: LineProcessOption.values()) {- menuItems.add(new MenuItem() {-- @Override- public String getLabel() {- return option.getName();- }-- @Override- public String getIconClass() {- if (lineProcessor == option)- return "fa fa-check";- else- return null;- }-- @Override- public AbstractLink newLink(String id) {- return new AjaxLink<Void>(id) {-- @Override- public void onClick(AjaxRequestTarget target) {- close();- lineProcessor = option;- onLineProcessorChange(target);- }-- @Override- protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {- super.updateAjaxAttributes(attributes);- attributes.getAjaxCallListeners().add(new IndicateLoadingListener());- if (getDirtyContainer() != null)- attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(getDirtyContainer()));- }-- };- }-- });- }-- return menuItems;- }-- });-- for (final DiffMode each: DiffMode.values()) {- add(new AjaxLink<Void>(each.name().toLowerCase()) {-- @Override- protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {- super.updateAjaxAttributes(attributes);- attributes.getAjaxCallListeners().add(new IndicateLoadingListener());- if (getDirtyContainer() != null)- attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(getDirtyContainer()));- }-- @Override- public void onClick(AjaxRequestTarget target) {- diffMode = each;- WebResponse response = (WebResponse) RequestCycle.get().getResponse();- Cookie cookie = new Cookie(COOKIE_DIFF_MODE, diffMode.name());- cookie.setMaxAge(Integer.MAX_VALUE);- response.addCookie(cookie);- target.add(DiffOptionPanel.this);-- target.focusComponent(null);- onDiffModeChange(target);- }-- }.add(AttributeAppender.append("class", new LoadableDetachableModel<String>() {-- @Override- protected String load() {- return each==diffMode?" active":"";- }-- })));- }-- add(new DropdownLink("filter") {-- @Override- protected Component newContent(String id) {- return new PathSelector(id, depotModel, newRev, FileMode.TYPE_TREE,- FileMode.TYPE_FILE, FileMode.TYPE_GITLINK, FileMode.TYPE_SYMLINK) {-- @Override- protected void onSelect(AjaxRequestTarget target, BlobIdent blobIdent) {- close();- target.add(DiffOptionPanel.this);- onSelectPath(target, blobIdent.path);- }-- @Override- protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {- attributes.getAjaxCallListeners().add(new IndicateLoadingListener());- if (getDirtyContainer() != null)- attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(getDirtyContainer()));- }-- };- }-- });-- setOutputMarkupId(true);- }-- @Override- protected void onDetach() {- depotModel.detach();-- super.onDetach();- }-- @Override- public void renderHead(IHeaderResponse response) {- super.renderHead(response);-- response.render(CssHeaderItem.forReference(- new CssResourceReference(DiffOptionPanel.class, "diff-option.css")));- }-- protected abstract void onSelectPath(AjaxRequestTarget target, String path);-- protected abstract void onLineProcessorChange(AjaxRequestTarget target);-- protected abstract void onDiffModeChange(AjaxRequestTarget target);-- public LineProcessor getLineProcessor() {- return lineProcessor;- }-- public DiffMode getDiffMode() {- return diffMode;- }-- protected Component getDirtyContainer() {- return null;- };--}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/option/diff-option.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/option/diff-option.cssdeleted file mode 100644index 295c0758ce..0000000000--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/option/diff-option.css+++ /dev/null@@ -1,16 +0,0 @@-.diff-option>.pull-left {- margin-right: 8px;-}-.dropdown-panel .filter-path>.current {- padding: 12px;- font-weight: bold;- background: #F2F2F2;- border-radius: 4px 4px 0 0;- border-bottom: 1px solid #DDD;-}-.dropdown-panel .filter-path>.current a {- color: #666;-}-.dropdown-panel .filter-path .path-selector {- width: auto;-}\ No newline at end of filediff --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 334e30dc3d..0f96b5b61a 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@@ -1,3 +1,12 @@+.revision-diff>.option {+ margin-bottom: 16px;+}+.revision-diff>.option>.view-mode {+ margin-left: 16px;+}+.revision-diff>.option .path-filter input {+ width: 300px;+}.revision-diff>.title {font-size: 16px;margin-bottom: 16px;diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.jsindex 07cfc9a5c3..c57951b0df 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.js+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.js@@ -28,6 +28,7 @@ gitplex.revisionDiff = {gitplex.revisionDiff.jumpToFile($this.data("file"));});});+if (scroll) {var uri = URI(window.location.href);var search = uri.search(true);diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/SourceViewPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/SourceViewPanel.javaindex a14da75668..5bf7a84fb6 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/SourceViewPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/SourceViewPanel.java@@ -239,7 +239,7 @@ public class SourceViewPanel extends BlobViewPanel {commit.hash = GitUtils.abbreviateSHA(blame.getCommit().getHash(), 7);commit.message = blame.getCommit().getSubject();CommitDetailPage.HistoryState state = new CommitDetailPage.HistoryState();- state.path = context.getBlobIdent().path;+ state.pathFilter = context.getBlobIdent().path;PageParameters params = CommitDetailPage.paramsOf(context.getDepot(),blame.getCommit().getHash(), state);commit.url = RequestCycle.get().urlFor(CommitDetailPage.class, params).toString();diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/editsave/EditSavePanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/editsave/EditSavePanel.javaindex 0f49da3628..31e453530a 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/editsave/EditSavePanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/editsave/EditSavePanel.java@@ -35,8 +35,8 @@ import com.pmease.commons.git.Blob;import com.pmease.commons.git.BlobChange;import com.pmease.commons.git.BlobIdent;import com.pmease.commons.git.FileEdit;-import com.pmease.commons.git.LineProcessor;import com.pmease.commons.git.PathAndContent;+import com.pmease.commons.git.WhitespaceOption;import com.pmease.commons.git.exception.NotTreeException;import com.pmease.commons.git.exception.ObjectAlreadyExistException;import com.pmease.commons.git.exception.ObsoleteCommitException;@@ -46,8 +46,7 @@ import com.pmease.gitplex.core.entity.Depot;import com.pmease.gitplex.core.entity.PullRequest;import com.pmease.gitplex.core.manager.AccountManager;import com.pmease.gitplex.web.component.diff.blob.BlobDiffPanel;-import com.pmease.gitplex.web.component.diff.revision.DiffMode;-import com.pmease.gitplex.web.component.diff.revision.LineProcessOption;+import com.pmease.gitplex.web.component.diff.revision.DiffViewMode;import de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationPanel;import jersey.repackaged.com.google.common.base.Objects;@@ -125,7 +124,7 @@ public abstract class EditSavePanel extends Panel {changedContainer.setOutputMarkupPlaceholderTag(true);if (change != null) {changedContainer.add(new BlobDiffPanel("changes", depotModel,- new Model<PullRequest>(null), change, DiffMode.UNIFIED));+ new Model<PullRequest>(null), change, DiffViewMode.UNIFIED));} else {changedContainer.add(new WebMarkupContainer("changes"));}@@ -340,18 +339,13 @@ public abstract class EditSavePanel extends Panel {changeType = DiffEntry.ChangeType.DELETE;}- return new BlobChange(changeType, oldBlobIdent, newBlobIdent) {+ return new BlobChange(changeType, oldBlobIdent, newBlobIdent, WhitespaceOption.DEFAULT) {@Overridepublic Blob getBlob(BlobIdent blobIdent) {return depotModel.getObject().getBlob(blobIdent);}- @Override- public LineProcessor getLineProcessor() {- return LineProcessOption.IGNORE_NOTHING;- }-};}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/fileedit/FileEditPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/fileedit/FileEditPanel.javaindex 7889dd86d9..c13dcbf001 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/fileedit/FileEditPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/fileedit/FileEditPanel.java@@ -30,8 +30,8 @@ import com.pmease.commons.git.Blob;import com.pmease.commons.git.BlobChange;import com.pmease.commons.git.BlobIdent;import com.pmease.commons.git.GitUtils;-import com.pmease.commons.git.LineProcessor;import com.pmease.commons.git.PathAndContent;+import com.pmease.commons.git.WhitespaceOption;import com.pmease.commons.wicket.ajaxlistener.ConfirmLeaveListener;import com.pmease.commons.wicket.assets.closestdescendant.ClosestDescendantResourceReference;import com.pmease.commons.wicket.assets.codemirror.CodeMirrorResourceReference;@@ -39,8 +39,7 @@ import com.pmease.commons.wicket.assets.diffmatchpatch.DiffMatchPatchResourceRefimport com.pmease.gitplex.core.entity.Depot;import com.pmease.gitplex.core.entity.PullRequest;import com.pmease.gitplex.web.component.diff.blob.BlobDiffPanel;-import com.pmease.gitplex.web.component.diff.revision.DiffMode;-import com.pmease.gitplex.web.component.diff.revision.LineProcessOption;+import com.pmease.gitplex.web.component.diff.revision.DiffViewMode;import com.pmease.gitplex.web.component.repofile.editsave.EditSavePanel;import com.pmease.gitplex.web.page.depot.file.Mark;@@ -122,7 +121,8 @@ public abstract class FileEditPanel extends Panel {elsechangeType = DiffEntry.ChangeType.MODIFY;- BlobChange change = new BlobChange(changeType, oldBlobIdent, newBlobIdent) {+ BlobChange change = new BlobChange(changeType, oldBlobIdent, newBlobIdent,+ WhitespaceOption.DEFAULT) {@Overridepublic Blob getBlob(BlobIdent blobIdent) {@@ -132,14 +132,9 @@ public abstract class FileEditPanel extends Panel {return depotModel.getObject().getBlob(blobIdent);}- @Override- public LineProcessor getLineProcessor() {- return LineProcessOption.IGNORE_NOTHING;- }-};BlobDiffPanel preview = new BlobDiffPanel("preview", depotModel, new Model<PullRequest>(null),- change, DiffMode.UNIFIED);+ change, DiffViewMode.UNIFIED);replace(preview);target.add(preview);diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/branches/DepotBranchesPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/branches/DepotBranchesPage.javaindex 0629636d8f..77bcd191d0 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/branches/DepotBranchesPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/branches/DepotBranchesPage.java@@ -50,6 +50,7 @@ import org.eclipse.jgit.revwalk.RevWalk;import com.google.common.base.Preconditions;import com.pmease.commons.git.GitUtils;+import com.pmease.commons.git.WhitespaceOption;import com.pmease.commons.hibernate.dao.Dao;import com.pmease.commons.util.StringUtils;import com.pmease.commons.wicket.ajaxlistener.ConfirmListener;@@ -485,6 +486,7 @@ public class DepotBranchesPage extends DepotPage {new DepotAndBranch(getDepot(), branch),new DepotAndBranch(getDepot(), getBaseBranch()),true,+ WhitespaceOption.DEFAULT,null);setResponsePage(RevisionComparePage.class, params);}@@ -546,6 +548,7 @@ public class DepotBranchesPage extends DepotPage {new DepotAndBranch(getDepot(), getBaseBranch()),new DepotAndBranch(getDepot(), branch),true,+ WhitespaceOption.DEFAULT,null);setResponsePage(RevisionComparePage.class, params);}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitDetailPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitDetailPage.htmlindex 22581ee851..6699ed5395 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitDetailPage.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitDetailPage.html@@ -37,8 +37,7 @@</div></div></div>- <div wicket:id="compareOption" class="compare-option"></div>- <div wicket:id="compareResult"></div>+ <div wicket:id="revisionDiff"></div></div><wicket:fragment wicket:id="refsFrag"><span wicket:id="refs">diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitDetailPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitDetailPage.javaindex 8ddf368d12..66fc9fea82 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitDetailPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitDetailPage.java@@ -39,6 +39,7 @@ import org.eclipse.jgit.revwalk.RevWalk;import com.google.common.base.Preconditions;import com.pmease.commons.git.GitUtils;+import com.pmease.commons.git.WhitespaceOption;import com.pmease.commons.wicket.assets.oneline.OnelineResourceReference;import com.pmease.gitplex.core.GitPlex;import com.pmease.gitplex.core.entity.Depot;@@ -49,7 +50,6 @@ import com.pmease.gitplex.web.component.contributorpanel.ContributorPanel;import com.pmease.gitplex.web.component.createbranch.CreateBranchLink;import com.pmease.gitplex.web.component.createtag.CreateTagLink;import com.pmease.gitplex.web.component.diff.revision.RevisionDiffPanel;-import com.pmease.gitplex.web.component.diff.revision.option.DiffOptionPanel;import com.pmease.gitplex.web.component.hashandcode.HashAndCodePanel;import com.pmease.gitplex.web.page.depot.DepotPage;import com.pmease.gitplex.web.page.depot.branches.DepotBranchesPage;@@ -63,9 +63,11 @@ public class CommitDetailPage extends DepotPage {// make sure to use a different value from wicket:id according to wicket bug:// https://issues.apache.org/jira/browse/WICKET-6069- private static final String PARAM_COMPARE_WITH = "compareWith";+ private static final String PARAM_COMPARE_WITH = "compare-with";- private static final String PARAM_PATH = "path";+ private static final String PARAM_WHITESPACE_OPTION = "whitespace-option";++ private static final String PARAM_PATH_FILTER = "path-filter";protected String revision;@@ -89,9 +91,7 @@ public class CommitDetailPage extends DepotPage {};- private DiffOptionPanel diffOption;-- private RevisionDiffPanel compareResult;+ private RevisionDiffPanel revisionDiff;public CommitDetailPage(PageParameters params) {super(params);@@ -258,7 +258,7 @@ public class CommitDetailPage extends DepotPage {public void onClick(AjaxRequestTarget target) {setCompareWith(parent);target.add(parentsContainer);- newCompareResult(target);+ newRevisionDiff(target);pushState(target);}@@ -276,30 +276,9 @@ public class CommitDetailPage extends DepotPage {}if (getCommit().getParentCount() != 0) {- add(diffOption = new DiffOptionPanel("compareOption", depotModel, getCommit().name()) {-- @Override- protected void onSelectPath(AjaxRequestTarget target, String path) {- CommitDetailPage.this.state.path = path;- newCompareResult(target);- pushState(target);- }-- @Override- protected void onLineProcessorChange(AjaxRequestTarget target) {- newCompareResult(target);- }-- @Override- protected void onDiffModeChange(AjaxRequestTarget target) {- newCompareResult(target);- }-- });- newCompareResult(null);+ newRevisionDiff(null);} else {- add(new WebMarkupContainer("compareOption").setVisible(false));- add(new WebMarkupContainer("compareResult").setVisible(false));+ add(new WebMarkupContainer("revisionDiff").setVisible(false));}}@@ -313,26 +292,31 @@ public class CommitDetailPage extends DepotPage {state.compareWith = compareWith;}- private void newCompareResult(@Nullable AjaxRequestTarget target) {- compareResult = new RevisionDiffPanel("compareResult", depotModel,+ private void newRevisionDiff(@Nullable AjaxRequestTarget target) {+ revisionDiff = new RevisionDiffPanel("revisionDiff", depotModel,Model.of((PullRequest)null), getCompareWith(),- getCommit().name(), state.path, diffOption.getLineProcessor(),- diffOption.getDiffMode()) {+ getCommit().name(), state.pathFilter, state.whitespaceOption) {@Override- protected void onClearPath(AjaxRequestTarget target) {- state.path = null;- newCompareResult(target);+ protected void onPathFilterChange(AjaxRequestTarget target, String pathFilter) {+ state.pathFilter = pathFilter;pushState(target);}+ @Override+ protected void onWhitespaceOptionChange(AjaxRequestTarget target,+ WhitespaceOption whitespaceOption) {+ state.whitespaceOption = whitespaceOption;+ pushState(target);+ }+};- compareResult.setOutputMarkupId(true);+ revisionDiff.setOutputMarkupId(true);if (target != null) {- replace(compareResult);- target.add(compareResult);+ replace(revisionDiff);+ target.add(revisionDiff);} else {- add(compareResult);+ add(revisionDiff);}}@@ -355,8 +339,10 @@ public class CommitDetailPage extends DepotPage {params.set(PARAM_REVISION, revision);if (state.compareWith != null)params.set(PARAM_COMPARE_WITH, state.compareWith);- if (state.path != null)- params.set(PARAM_PATH, state.path);+ if (state.whitespaceOption != WhitespaceOption.DEFAULT)+ params.set(PARAM_WHITESPACE_OPTION, state.whitespaceOption.name());+ if (state.pathFilter != null)+ params.set(PARAM_PATH_FILTER, state.pathFilter);return params;}@@ -383,7 +369,7 @@ public class CommitDetailPage extends DepotPage {super.onPopState(target, data);state = (HistoryState) data;- newCompareResult(target);+ newRevisionDiff(target);}public static class HistoryState implements Serializable {@@ -392,14 +378,17 @@ public class CommitDetailPage extends DepotPage {public String compareWith;- public String path;+ public WhitespaceOption whitespaceOption = WhitespaceOption.DEFAULT;++ public String pathFilter;public HistoryState() {}public HistoryState(PageParameters params) {compareWith = params.get(PARAM_COMPARE_WITH).toString();- path = params.get(PARAM_PATH).toString();+ whitespaceOption = WhitespaceOption.of(params.get(PARAM_WHITESPACE_OPTION).toString());+ pathFilter = params.get(PARAM_PATH_FILTER).toString();}}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/DepotCommitsPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/DepotCommitsPage.javaindex 04794d29d5..fec3e31ab2 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/DepotCommitsPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/DepotCommitsPage.java@@ -33,7 +33,6 @@ import org.apache.wicket.model.LoadableDetachableModel;import org.apache.wicket.request.cycle.RequestCycle;import org.apache.wicket.request.mapper.parameter.PageParameters;import org.apache.wicket.request.resource.CssResourceReference;-import org.apache.wicket.request.resource.JavaScriptResourceReference;import org.joda.time.DateTime;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -42,6 +41,7 @@ import org.unbescape.java.JavaEscape;import com.google.common.base.Optional;import com.google.common.base.Throwables;import com.pmease.commons.git.Commit;+import com.pmease.commons.git.WhitespaceOption;import com.pmease.commons.git.command.LogCommand;import com.pmease.commons.util.StringUtils;import com.pmease.commons.util.concurrent.PrioritizedCallable;@@ -202,12 +202,6 @@ public class DepotCommitsPage extends DepotPage {RequestCycle.get().find(AjaxRequestTarget.class).add(feedback);}- @Override- public void renderHead(IHeaderResponse response) {- super.renderHead(response);- response.render(OnDomReadyHeaderItem.forScript("gitplex.repocommits.initQuery();"));- }-};queryForm.add(new TextField<String>("input", new IModel<String>() {@@ -438,7 +432,7 @@ public class DepotCommitsPage extends DepotPage {PageParameters params = RevisionComparePage.paramsOf(getDepot(),new DepotAndRevision(getDepot(), commit.getHash()),new DepotAndRevision(getDepot(), state.getCompareWith()),- true, path);+ true, WhitespaceOption.DEFAULT, path);item.add(new BookmarkablePageLink<Void>("compare", RevisionComparePage.class, params));} else {item.add(new WebMarkupContainer("compare").setVisible(false));@@ -522,8 +516,6 @@ public class DepotCommitsPage extends DepotPage {response.render(JavaScriptHeaderItem.forReference(ClearableResourceReference.INSTANCE));response.render(JavaScriptHeaderItem.forReference(CommitGraphResourceReference.INSTANCE));- response.render(JavaScriptHeaderItem.forReference(- new JavaScriptResourceReference(DepotCommitsPage.class, "depot-commits.js")));response.render(CssHeaderItem.forReference(new CssResourceReference(DepotCommitsPage.class, "depot-commits.css")));diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/depot-commits.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/depot-commits.jsdeleted file mode 100644index ed33b84356..0000000000--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/depot-commits.js+++ /dev/null@@ -1,11 +0,0 @@-gitplex.repocommits = {- initQuery: function() {- var $queryForm = $("#repo-commits>.head>.query");- var $queryInput = $queryForm.find(".input-group>input");- $queryInput.clearable();- $queryInput.on("input", function() {- if (!$queryInput.is(":focus"))- $queryForm.find("button[type='submit']").click();- });- }-}\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/compare/RevisionComparePage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/compare/RevisionComparePage.htmlindex db81f6b61c..51425ddedc 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/compare/RevisionComparePage.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/compare/RevisionComparePage.html@@ -41,8 +41,4 @@</div></div><div wicket:id="backToTop"></div>- <wicket:fragment wicket:id="compareFrag">- <div wicket:id="diffOption" class="diff-option"></div>- <div wicket:id="revisionDiff"></div>- </wicket:fragment></wicket:extend>\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/compare/RevisionComparePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/compare/RevisionComparePage.javaindex f7ff703ad4..389e3bae40 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/compare/RevisionComparePage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/compare/RevisionComparePage.java@@ -16,7 +16,6 @@ import org.apache.wicket.markup.html.WebMarkupContainer;import org.apache.wicket.markup.html.basic.Label;import org.apache.wicket.markup.html.form.CheckBox;import org.apache.wicket.markup.html.link.Link;-import org.apache.wicket.markup.html.panel.Fragment;import org.apache.wicket.model.AbstractReadOnlyModel;import org.apache.wicket.model.IModel;import org.apache.wicket.model.LoadableDetachableModel;@@ -28,10 +27,9 @@ import org.apache.wicket.request.resource.CssResourceReference;import com.google.common.collect.Lists;import com.pmease.commons.git.Commit;import com.pmease.commons.git.Git;+import com.pmease.commons.git.WhitespaceOption;import com.pmease.commons.git.command.LogCommand;import com.pmease.commons.util.FileUtils;-import com.pmease.commons.util.StringUtils;-import com.pmease.commons.wicket.behavior.StickyBehavior;import com.pmease.commons.wicket.behavior.TooltipBehavior;import com.pmease.commons.wicket.component.backtotop.BackToTop;import com.pmease.commons.wicket.component.tabbable.AjaxActionTab;@@ -45,7 +43,6 @@ import com.pmease.gitplex.core.entity.component.DepotAndRevision;import com.pmease.gitplex.core.manager.PullRequestManager;import com.pmease.gitplex.web.component.commitlist.CommitListPanel;import com.pmease.gitplex.web.component.diff.revision.RevisionDiffPanel;-import com.pmease.gitplex.web.component.diff.revision.option.DiffOptionPanel;import com.pmease.gitplex.web.component.revisionpicker.AffinalRevisionPicker;import com.pmease.gitplex.web.page.depot.DepotPage;import com.pmease.gitplex.web.page.depot.NoCommitsPage;@@ -62,7 +59,9 @@ public class RevisionComparePage extends DepotPage {private static final String PARAM_COMPARE_WITH_MERGE_BASE = "compare-with-merge-base";- private static final String PARAM_PATH = "path";+ private static final String PARAM_WHITESPACE_OPTION = "whitespace-option";++ private static final String PARAM_PATH_FILTER = "path-filter";private static final String TAB_PANEL_ID = "tabPanel";@@ -76,24 +75,27 @@ public class RevisionComparePage extends DepotPage {private DepotAndRevision rightSide;- private DiffOptionPanel diffOption;-private AjaxActionTab commitsTab;private AjaxActionTab filesTab;private boolean compareWithMergeBase;- private String path;+ private WhitespaceOption whitespaceOption = WhitespaceOption.DEFAULT;++ private String pathFilter;public static PageParameters paramsOf(Depot depot, DepotAndRevision leftSide,- DepotAndRevision rightSide, boolean compareWithMergeBase, @Nullable String path) {+ DepotAndRevision rightSide, boolean compareWithMergeBase,+ WhitespaceOption whitespaceOption, @Nullable String pathFilter) {PageParameters params = paramsOf(depot);params.set(PARAM_LEFT, leftSide.toString());params.set(PARAM_RIGHT, rightSide.toString());params.set(PARAM_COMPARE_WITH_MERGE_BASE, compareWithMergeBase);- if (path != null)- params.set(PARAM_PATH, path);+ if (whitespaceOption != WhitespaceOption.DEFAULT)+ params.set(PARAM_WHITESPACE_OPTION, whitespaceOption.name());+ if (pathFilter != null)+ params.set(PARAM_PATH_FILTER, pathFilter);return params;}@@ -119,7 +121,7 @@ public class RevisionComparePage extends DepotPage {compareWithMergeBase = params.get(PARAM_COMPARE_WITH_MERGE_BASE).toBoolean(false);- path = params.get(PARAM_PATH).toString();+ pathFilter = params.get(PARAM_PATH_FILTER).toString();requestModel = new LoadableDetachableModel<PullRequest>() {@@ -186,7 +188,8 @@ public class RevisionComparePage extends DepotPage {@Overrideprotected void onSelect(AjaxRequestTarget target, Depot depot, String revision) {- PageParameters params = paramsOf(getDepot(), new DepotAndRevision(depot, revision), rightSide, compareWithMergeBase, path);+ PageParameters params = paramsOf(getDepot(), new DepotAndRevision(depot, revision),+ rightSide, compareWithMergeBase, whitespaceOption, pathFilter);setResponsePage(RevisionComparePage.class, params);}@@ -196,7 +199,7 @@ public class RevisionComparePage extends DepotPage {@Overrideprotected void onUpdate(AjaxRequestTarget target) {PageParameters params = RevisionComparePage.paramsOf(depotModel.getObject(),- leftSide, rightSide, !compareWithMergeBase, path);+ leftSide, rightSide, !compareWithMergeBase, whitespaceOption, pathFilter);setResponsePage(RevisionComparePage.class, params);}@@ -209,7 +212,8 @@ public class RevisionComparePage extends DepotPage {@Overrideprotected void onSelect(AjaxRequestTarget target, Depot depot, String revision) {PageParameters params = paramsOf(getDepot(), leftSide,- new DepotAndRevision(depot, revision), compareWithMergeBase, path);+ new DepotAndRevision(depot, revision), compareWithMergeBase,+ whitespaceOption, pathFilter);setResponsePage(RevisionComparePage.class, params);}@@ -220,7 +224,7 @@ public class RevisionComparePage extends DepotPage {@Overridepublic void onClick() {setResponsePage(RevisionComparePage.class,paramsOf(getDepot(), rightSide, leftSide,- compareWithMergeBase, path));+ compareWithMergeBase, whitespaceOption, pathFilter));}});@@ -318,7 +322,8 @@ public class RevisionComparePage extends DepotPage {@Overridepublic void onClick() {- PageParameters params = paramsOf(getDepot(), leftSide, rightSide, true, path);+ PageParameters params = paramsOf(getDepot(), leftSide, rightSide, true,+ whitespaceOption, pathFilter);setResponsePage(RevisionComparePage.class, params);}@@ -341,7 +346,7 @@ public class RevisionComparePage extends DepotPage {@Overrideprotected void onSelect(AjaxRequestTarget target, Component tabLink) {- path = null;+ pathFilter = null;newTabPanel(target);pushState(target);}@@ -352,7 +357,7 @@ public class RevisionComparePage extends DepotPage {@Overrideprotected void onSelect(AjaxRequestTarget target, Component tabLink) {- path = "";+ pathFilter = "";newTabPanel(target);pushState(target);}@@ -391,47 +396,32 @@ public class RevisionComparePage extends DepotPage {private void newTabPanel(@Nullable AjaxRequestTarget target) {WebMarkupContainer tabPanel;- if (path != null) {- tabPanel = new Fragment(TAB_PANEL_ID, "compareFrag", this) {+ if (pathFilter != null) {+ tabPanel = new RevisionDiffPanel(TAB_PANEL_ID, depotModel,+ new Model<PullRequest>(null),+ compareWithMergeBase?mergeBaseModel.getObject():leftSide.getRevision(),+ rightSide.getRevision(), pathFilter, whitespaceOption) {@Override- protected void onConfigure() {- super.onConfigure();- setVisible(hasChanges());- }-- };-- diffOption = new DiffOptionPanel("diffOption", new AbstractReadOnlyModel<Depot>() {-- @Override- public Depot getObject() {- return getDepot();- }-- }, rightSide.getRevision()) {-- @Override- protected void onSelectPath(AjaxRequestTarget target, String path) {- RevisionComparePage.this.path = path;- newRevDiffPanel(tabPanel, target);+ protected void onPathFilterChange(AjaxRequestTarget target, String pathFilter) {+ RevisionComparePage.this.pathFilter = pathFilter;pushState(target);}@Override- protected void onLineProcessorChange(AjaxRequestTarget target) {- newRevDiffPanel(tabPanel, target);+ protected void onWhitespaceOptionChange(AjaxRequestTarget target,+ WhitespaceOption whitespaceOption) {+ RevisionComparePage.this.whitespaceOption = whitespaceOption;+ pushState(target);}-+@Override- protected void onDiffModeChange(AjaxRequestTarget target) {- newRevDiffPanel(tabPanel, target);+ protected void onConfigure() {+ super.onConfigure();+ setVisible(hasChanges());}};- diffOption.add(new StickyBehavior());- tabPanel.add(diffOption);- newRevDiffPanel(tabPanel, null);commitsTab.setSelected(false);filesTab.setSelected(true);} else {@@ -456,43 +446,18 @@ public class RevisionComparePage extends DepotPage {}}- private void newRevDiffPanel(final WebMarkupContainer tabPanel, @Nullable AjaxRequestTarget target) {- RevisionDiffPanel diffPanel = new RevisionDiffPanel("revisionDiff", depotModel,- new Model<PullRequest>(null),- compareWithMergeBase?mergeBaseModel.getObject():leftSide.getRevision(),- rightSide.getRevision(),- StringUtils.isNotBlank(path)?path:null, diffOption.getLineProcessor(),- diffOption.getDiffMode()) {-- @Override- protected void onClearPath(AjaxRequestTarget target) {- path = "";- newRevDiffPanel(tabPanel, target);- pushState(target);- }-- };- diffPanel.setOutputMarkupId(true);- if (target != null) {- tabPanel.replace(diffPanel);- target.add(diffPanel);- } else {- tabPanel.add(diffPanel);- }- }-private void pushState(AjaxRequestTarget target) {PageParameters params = paramsOf(getDepot(), leftSide,- rightSide, compareWithMergeBase, path);+ rightSide, compareWithMergeBase, whitespaceOption, pathFilter);CharSequence url = RequestCycle.get().urlFor(RevisionComparePage.class, params);- pushState(target, url.toString(), path);+ pushState(target, url.toString(), pathFilter);}@Overrideprotected void onPopState(AjaxRequestTarget target, Serializable data) {super.onPopState(target, data);- path = (String) data;+ pathFilter = (String) data;newTabPanel(target);}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.htmlindex 81b94f73bc..31a42701fd 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.html@@ -104,8 +104,4 @@</form></div></wicket:fragment>- <wicket:fragment wicket:id="compareFrag">- <div wicket:id="diffOption" class="diff-option"></div>- <div wicket:id="revisionDiff"></div>- </wicket:fragment></wicket:extend>\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.javaindex 64edc59500..b4041111ef 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.java@@ -35,9 +35,9 @@ import org.apache.wicket.request.resource.CssResourceReference;import com.google.common.base.Preconditions;import com.pmease.commons.git.Commit;import com.pmease.commons.git.Git;+import com.pmease.commons.git.WhitespaceOption;import com.pmease.commons.hibernate.dao.Dao;import com.pmease.commons.util.FileUtils;-import com.pmease.commons.wicket.behavior.StickyBehavior;import com.pmease.commons.wicket.component.backtotop.BackToTop;import com.pmease.commons.wicket.component.tabbable.AjaxActionTab;import com.pmease.commons.wicket.component.tabbable.Tab;@@ -60,7 +60,6 @@ import com.pmease.gitplex.web.component.branchpicker.AffinalBranchPicker;import com.pmease.gitplex.web.component.comment.CommentInput;import com.pmease.gitplex.web.component.commitlist.CommitListPanel;import com.pmease.gitplex.web.component.diff.revision.RevisionDiffPanel;-import com.pmease.gitplex.web.component.diff.revision.option.DiffOptionPanel;import com.pmease.gitplex.web.component.pullrequest.requestassignee.AssigneeChoice;import com.pmease.gitplex.web.component.pullrequest.requestreviewer.ReviewerAvatar;import com.pmease.gitplex.web.component.pullrequest.requestreviewer.ReviewerChoice;@@ -87,10 +86,6 @@ public class NewRequestPage extends PullRequestPage {private IModel<PullRequest> requestModel;- private DiffOptionPanel diffOption;-- private String path;-public static PageParameters paramsOf(Depot depot, DepotAndBranch target, DepotAndBranch source) {PageParameters params = paramsOf(depot);params.set("target", target.toString());@@ -283,7 +278,7 @@ public class NewRequestPage extends PullRequestPage {@Overrideprotected void onSelect(AjaxRequestTarget target, Component tabLink) {- Component panel = newComparePanel();+ Component panel = newRevDiffPanel();getPage().replace(panel);target.add(panel);}@@ -310,56 +305,21 @@ public class NewRequestPage extends PullRequestPage {return new CommitListPanel(TAB_PANEL_ID, depotModel, commitsModel).setOutputMarkupId(true);}- private Component newComparePanel() {- final Fragment fragment = new Fragment(TAB_PANEL_ID, "compareFrag", this);-- diffOption = new DiffOptionPanel("diffOption", depotModel, getPullRequest().getLatestUpdate().getHeadCommitHash()) {-- @Override- protected void onSelectPath(AjaxRequestTarget target, String path) {- NewRequestPage.this.path = path;- RevisionDiffPanel diffPanel = newRevDiffPanel();- fragment.replace(diffPanel);- target.add(diffPanel);- }-- @Override- protected void onLineProcessorChange(AjaxRequestTarget target) {- RevisionDiffPanel diffPanel = newRevDiffPanel();- fragment.replace(diffPanel);- target.add(diffPanel);- }-- @Override- protected void onDiffModeChange(AjaxRequestTarget target) {- RevisionDiffPanel diffPanel = newRevDiffPanel();- fragment.replace(diffPanel);- target.add(diffPanel);- }-- };- diffOption.add(new StickyBehavior());- fragment.add(diffOption);- fragment.add(newRevDiffPanel());-- return fragment;- }-- protected RevisionDiffPanel newRevDiffPanel() {+ private RevisionDiffPanel newRevDiffPanel() {PullRequest request = getPullRequest();String oldRev = request.getBaseCommitHash();String newRev = request.getLatestUpdate().getHeadCommitHash();RevisionDiffPanel diffPanel = new RevisionDiffPanel("revisionDiff", depotModel,- new Model<PullRequest>(null), oldRev, newRev, path, diffOption.getLineProcessor(),- diffOption.getDiffMode()) {+ new Model<PullRequest>(null), oldRev, newRev, null, null) {++ @Override+ protected void onPathFilterChange(AjaxRequestTarget target, String pathFilter) {+ }@Override- protected void onClearPath(AjaxRequestTarget target) {- path = null;- RevisionDiffPanel diffPanel = newRevDiffPanel();- replaceWith(diffPanel);- target.add(diffPanel);+ protected void onWhitespaceOptionChange(AjaxRequestTarget target,+ WhitespaceOption whitespaceOption) {}};diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/compare/HistoryState.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/compare/HistoryState.javaindex 518bbbf049..4e68486fcb 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/compare/HistoryState.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/compare/HistoryState.java@@ -2,6 +2,8 @@ package com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.compare;import java.io.Serializable;+import com.pmease.commons.git.WhitespaceOption;+class HistoryState implements Serializable {private static final long serialVersionUID = 1L;@@ -10,7 +12,8 @@ class HistoryState implements Serializable {public String newRev;- public String path;+ public WhitespaceOption whitespaceOption = WhitespaceOption.DEFAULT;++ public String pathFilter;- public Long commentId;}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/compare/RequestComparePage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/compare/RequestComparePage.htmlindex 8a4449e617..e5d177201c 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/compare/RequestComparePage.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/compare/RequestComparePage.html@@ -13,7 +13,6 @@<i class="fa fa-ext fa-commit"></i> <span wicket:id="label"></span> <i class="caret"></i></span></div>- <div wicket:id="diffOption" class="pull-right"></div></div><div class="alerts"><div wicket:id="outdatedAlert" class="outdated alert alert-warning">@@ -24,7 +23,7 @@<div wicket:id="noIntegrationPreviewAlert" class="no-integration-preview alert alert-warning"></div></div></div>- <div wicket:id="compareResult" class="body"></div>+ <div wicket:id="revisionDiff" class="body"></div></div><wicket:fragment wicket:id="commitChoiceFrag"><ul class="commit-choice list-unstyled">diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/compare/RequestComparePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/compare/RequestComparePage.javaindex cd21914a96..c988976e60 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/compare/RequestComparePage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/compare/RequestComparePage.java@@ -36,6 +36,7 @@ import org.apache.wicket.request.resource.CssResourceReference;import com.pmease.commons.git.Commit;import com.pmease.commons.git.GitUtils;+import com.pmease.commons.git.WhitespaceOption;import com.pmease.commons.wicket.ajaxlistener.ConfirmLeaveListener;import com.pmease.commons.wicket.ajaxlistener.IndicateLoadingListener;import com.pmease.commons.wicket.behavior.StickyBehavior;@@ -44,14 +45,11 @@ import com.pmease.commons.wicket.component.floating.AlignPlacement;import com.pmease.commons.wicket.component.floating.FloatingPanel;import com.pmease.commons.wicket.component.menu.MenuItem;import com.pmease.commons.wicket.component.menu.MenuLink;-import com.pmease.gitplex.core.entity.CodeComment;import com.pmease.gitplex.core.entity.Depot;import com.pmease.gitplex.core.entity.PullRequest;import com.pmease.gitplex.core.entity.PullRequestUpdate;import com.pmease.gitplex.core.entity.component.IntegrationPreview;-import com.pmease.gitplex.web.component.comment.event.CommentRemoved;import com.pmease.gitplex.web.component.diff.revision.RevisionDiffPanel;-import com.pmease.gitplex.web.component.diff.revision.option.DiffOptionPanel;import com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.RequestDetailPage;import com.pmease.gitplex.web.page.depot.pullrequest.requestlist.RequestListPage;import com.pmease.gitplex.web.websocket.PullRequestChanged;@@ -59,13 +57,13 @@ import com.pmease.gitplex.web.websocket.PullRequestChanged;@SuppressWarnings("serial")public class RequestComparePage extends RequestDetailPage {- private static final String PARAM_COMMENT = "comment";+ private static final String PARAM_OLD_REV = "old-rev";- private static final String PARAM_OLD_REV = "oldRev";+ private static final String PARAM_NEW_REV = "new-rev";- private static final String PARAM_NEW_REV = "newRev";+ private static final String PARAM_WHITESPACE_OPTION = "whitespace-option";- private static final String PARAM_PATH = "path";+ private static final String PARAM_PATH_FILTER = "path-filter";public static final String REV_BASE = "base";@@ -89,13 +87,13 @@ public class RequestComparePage extends RequestDetailPage {private String newCommitHash;- private String path;+ private WhitespaceOption whitespaceOption = WhitespaceOption.DEFAULT;- private WebMarkupContainer compareHead;+ private String pathFilter;- private DiffOptionPanel diffOption;+ private WebMarkupContainer compareHead;- private Component compareResult;+ private Component revisionDiff;private final IModel<Map<String, CommitDescription>> commitsModel =new LoadableDetachableModel<Map<String, CommitDescription>>() {@@ -145,10 +143,10 @@ public class RequestComparePage extends RequestDetailPage {public RequestComparePage(PageParameters params) {super(params);- state.commentId = params.get(PARAM_COMMENT).toOptionalLong();state.oldRev = params.get(PARAM_OLD_REV).toString();state.newRev = params.get(PARAM_NEW_REV).toString();- state.path = params.get(PARAM_PATH).toString();+ state.pathFilter = params.get(PARAM_PATH_FILTER).toString();+ state.whitespaceOption = WhitespaceOption.of(params.get(PARAM_WHITESPACE_OPTION).toString());initFromState(state);}@@ -156,7 +154,8 @@ public class RequestComparePage extends RequestDetailPage {private void initFromState(HistoryState state) {oldCommitHash = getCommitHash(state.oldRev);newCommitHash = getCommitHash(state.newRev);- path = state.path;+ whitespaceOption = state.whitespaceOption;+ pathFilter = state.pathFilter;}private String getRevision(String commitHash) {@@ -243,7 +242,6 @@ public class RequestComparePage extends RequestDetailPage {@Overrideprotected void onSelect(AjaxRequestTarget target, String commitHash) {oldCommitHash = commitHash;- state.commentId = null;state.oldRev = getRevision(oldCommitHash);state.newRev = getRevision(newCommitHash);close();@@ -288,7 +286,6 @@ public class RequestComparePage extends RequestDetailPage {@Overrideprotected void onSelect(AjaxRequestTarget target, String commitHash) {newCommitHash = commitHash;- state.commentId = null;state.oldRev = getRevision(oldCommitHash);state.newRev = getRevision(newCommitHash);close();@@ -331,7 +328,6 @@ public class RequestComparePage extends RequestDetailPage {protected void onSelect(AjaxRequestTarget target) {close();- state.commentId = null;state.oldRev = REV_BASE;state.newRev = REV_LAST_UPDATE_PREFIX + "1";initFromState(state);@@ -350,7 +346,6 @@ public class RequestComparePage extends RequestDetailPage {protected void onSelect(AjaxRequestTarget target) {close();- state.commentId = null;state.oldRev = REV_TARGET_BRANCH;state.newRev = REV_INTEGRATION_PREVIEW;initFromState(state);@@ -376,7 +371,6 @@ public class RequestComparePage extends RequestDetailPage {protected void onSelect(AjaxRequestTarget target) {close();- state.commentId = null;state.oldRev = REV_UPDATE_PREFIX + (updateNo-1);state.newRev = REV_UPDATE_PREFIX + updateNo;initFromState(state);@@ -391,37 +385,6 @@ public class RequestComparePage extends RequestDetailPage {});- compareHead.add(diffOption = new DiffOptionPanel("diffOption", depotModel, newCommitHash) {-- @Override- protected void onSelectPath(AjaxRequestTarget target, String path) {- RequestComparePage.this.path = state.path = path;- if (state.commentId != null) {- state.commentId = null;- state.oldRev = getRevision(oldCommitHash);- state.newRev = getRevision(newCommitHash);- }- newCompareResult(target);- pushState(target);- }-- @Override- protected void onLineProcessorChange(AjaxRequestTarget target) {- newCompareResult(target);- }-- @Override- protected void onDiffModeChange(AjaxRequestTarget target) {- newCompareResult(target);- }-- @Override- protected Component getDirtyContainer() {- return compareResult;- }-- });-compareHead.add(new WebMarkupContainer("outdatedAlert") {@Override@@ -434,14 +397,12 @@ public class RequestComparePage extends RequestDetailPage {PullRequest.Event requestEvent = requestChanged.getEvent();boolean outdated = false;- if (state.commentId == null) {- if (requestEvent == INTEGRATION_PREVIEW_CALCULATED) {- outdated = state.oldRev.equals(REV_INTEGRATION_PREVIEW)- || state.newRev.equals(REV_INTEGRATION_PREVIEW);- } else if (requestEvent == UPDATED) {- outdated = !GitUtils.isHash(state.oldRev) && state.oldRev.startsWith(REV_LAST_UPDATE_PREFIX)- || !GitUtils.isHash(state.newRev) && state.newRev.startsWith(REV_LAST_UPDATE_PREFIX);- }+ if (requestEvent == INTEGRATION_PREVIEW_CALCULATED) {+ outdated = state.oldRev.equals(REV_INTEGRATION_PREVIEW)+ || state.newRev.equals(REV_INTEGRATION_PREVIEW);+ } else if (requestEvent == UPDATED) {+ outdated = !GitUtils.isHash(state.oldRev) && state.oldRev.startsWith(REV_LAST_UPDATE_PREFIX)+ || !GitUtils.isHash(state.newRev) && state.newRev.startsWith(REV_LAST_UPDATE_PREFIX);}if (outdated)@@ -508,48 +469,24 @@ public class RequestComparePage extends RequestDetailPage {}public static PageParameters paramsOf(PullRequest request, String oldRev, String newRev) {- return paramsOf(request, oldRev, newRev, null);- }-- public static PageParameters paramsOf(PullRequest request, String oldRev, String newRev,- @Nullable String path) {- return paramsOf(request, null, oldRev, newRev, path);+ return paramsOf(request, oldRev, newRev, WhitespaceOption.DEFAULT, null);}- private static PageParameters paramsOf(PullRequest request, @Nullable Long commentId,- @Nullable String oldRev, @Nullable String newRev, @Nullable String path) {+ public static PageParameters paramsOf(PullRequest request, @Nullable String oldRev, @Nullable String newRev,+ WhitespaceOption whitespaceOption, @Nullable String pathFilter) {PageParameters params = RequestDetailPage.paramsOf(request);- if (commentId != null)- params.set(PARAM_COMMENT, commentId);if (oldRev != null)params.set(PARAM_OLD_REV, oldRev);if (newRev != null)params.set(PARAM_NEW_REV, newRev);- if (path != null)- params.set(PARAM_PATH, path);+ if (whitespaceOption != WhitespaceOption.DEFAULT)+ params.set(PARAM_WHITESPACE_OPTION, whitespaceOption.name());+ if (pathFilter != null)+ params.set(PARAM_PATH_FILTER, pathFilter);return params;}- @Override- public void onEvent(IEvent<?> event) {- super.onEvent(event);-- if (event.getPayload() instanceof CommentRemoved) {- CommentRemoved commentRemoved = (CommentRemoved) event.getPayload();- CodeComment comment = (CodeComment) commentRemoved.getComment();-- // compare identifier instead of comment object as comment may have been deleted- // to cause LazyInitializationException- if (CodeComment.idOf(comment).equals(state.commentId)) {- state.commentId = null;- state.oldRev = getRevision(oldCommitHash);- state.newRev = getRevision(newCommitHash);- onStateChange(commentRemoved.getPartialPageRequestHandler());- }- }- }-private static class CommitDescription implements Serializable {private final String name;@@ -606,7 +543,7 @@ public class RequestComparePage extends RequestDetailPage {protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {super.updateAjaxAttributes(attributes);attributes.getAjaxCallListeners().add(new IndicateLoadingListener());- attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(compareResult));+ attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(revisionDiff));}@Override@@ -659,7 +596,7 @@ public class RequestComparePage extends RequestDetailPage {protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {super.updateAjaxAttributes(attributes);attributes.getAjaxCallListeners().add(new IndicateLoadingListener());- attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(compareResult));+ attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(revisionDiff));}@Override@@ -690,8 +627,8 @@ public class RequestComparePage extends RequestDetailPage {}private void pushState(IPartialPageRequestHandler partialPageRequestHandler) {- PageParameters params = paramsOf(getPullRequest(), state.commentId,- state.oldRev, state.newRev, state.path);+ PageParameters params = paramsOf(getPullRequest(), state.oldRev, state.newRev,+ state.whitespaceOption, state.pathFilter);CharSequence url = RequestCycle.get().urlFor(RequestComparePage.class, params);pushState(partialPageRequestHandler, url.toString(), state);}@@ -704,29 +641,30 @@ public class RequestComparePage extends RequestDetailPage {}private void newCompareResult(@Nullable IPartialPageRequestHandler partialPageRequestHandler) {- compareResult = new RevisionDiffPanel("compareResult", depotModel,- requestModel, oldCommitHash, newCommitHash, path,- diffOption.getLineProcessor(), diffOption.getDiffMode()) {+ revisionDiff = new RevisionDiffPanel("revisionDiff", depotModel,+ requestModel, oldCommitHash, newCommitHash, pathFilter,+ whitespaceOption) {@Override- protected void onClearPath(AjaxRequestTarget target) {- path = state.path = null;- if (state.commentId != null) {- state.commentId = null;- state.oldRev = getRevision(oldCommitHash);- state.newRev = getRevision(newCommitHash);- }- newCompareResult(target);+ protected void onPathFilterChange(AjaxRequestTarget target, String pathFilter) {+ pathFilter = state.pathFilter = pathFilter;+ pushState(target);+ }++ @Override+ protected void onWhitespaceOptionChange(AjaxRequestTarget target,+ WhitespaceOption whitespaceOption) {+ whitespaceOption = state.whitespaceOption = whitespaceOption;pushState(target);}};- compareResult.setOutputMarkupId(true);+ revisionDiff.setOutputMarkupId(true);if (partialPageRequestHandler != null) {- replace(compareResult);- partialPageRequestHandler.add(compareResult);+ replace(revisionDiff);+ partialPageRequestHandler.add(revisionDiff);} else {- add(compareResult);+ add(revisionDiff);}}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/SinceChangesLink.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/SinceChangesLink.javaindex 6f4fd567e0..c2b90e354a 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/SinceChangesLink.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/SinceChangesLink.java@@ -11,6 +11,7 @@ import org.apache.wicket.model.IModel;import org.apache.wicket.model.LoadableDetachableModel;import org.apache.wicket.request.mapper.parameter.PageParameters;+import com.pmease.commons.git.WhitespaceOption;import com.pmease.gitplex.core.entity.PullRequest;import com.pmease.gitplex.core.entity.PullRequestUpdate;import com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.compare.RequestComparePage;@@ -61,7 +62,7 @@ class SinceChangesLink extends Panel {public void onClick() {PullRequest request = requestModel.getObject();PageParameters params = RequestComparePage.paramsOf(request, oldRevModel.getObject(),- RequestComparePage.REV_LAST_UPDATE_PREFIX+1, null);+ RequestComparePage.REV_LAST_UPDATE_PREFIX+1, WhitespaceOption.DEFAULT, null);setResponsePage(RequestComparePage.class, params);}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/tags/DepotTagsPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/tags/DepotTagsPage.javaindex 76917521c8..2ebc683ab4 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/tags/DepotTagsPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/tags/DepotTagsPage.java@@ -41,6 +41,7 @@ import org.eclipse.jgit.revwalk.RevWalk;import org.eclipse.jgit.revwalk.filter.RevFilter;import com.pmease.commons.git.GitUtils;+import com.pmease.commons.git.WhitespaceOption;import com.pmease.commons.util.StringUtils;import com.pmease.commons.wicket.ajaxlistener.ConfirmListener;import com.pmease.commons.wicket.behavior.OnTypingDoneBehavior;@@ -336,7 +337,8 @@ public class DepotTagsPage extends DepotPage {}DepotAndRevision source = new DepotAndRevision(getDepot(),GitUtils.ref2tag(item.getModelObject().getName()));- PageParameters params = RevisionComparePage.paramsOf(getDepot(), target, source, true, "");+ PageParameters params = RevisionComparePage.paramsOf(getDepot(), target, source, true,+ WhitespaceOption.DEFAULT, "");setResponsePage(RevisionComparePage.class, params);} catch (IOException e) {throw new RuntimeException(e);