The Unified and Autonomous Development Platform
midwork
robin shine6237da4b63c5
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/BlobViewPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/BlobViewPanel.javaindex 70ba02b100..1a6afea814 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/BlobViewPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/BlobViewPanel.java@@ -18,9 +18,10 @@ import org.apache.wicket.request.resource.CssResourceReference;import org.apache.wicket.request.resource.JavaScriptResourceReference;import com.google.common.base.Preconditions;+import com.pmease.commons.git.Blob;+import com.pmease.commons.git.BlobIdent;import com.pmease.commons.git.Git;import com.pmease.commons.wicket.assets.closestdescendant.ClosestDescendantResourceReference;-import com.pmease.gitplex.web.page.repository.file.HistoryState;import com.pmease.gitplex.web.resource.BlobResource;import com.pmease.gitplex.web.resource.BlobResourceReference;@@ -32,13 +33,17 @@ public abstract class BlobViewPanel extends Panel {public BlobViewPanel(String id, BlobViewContext context) {super(id);- HistoryState state = context.getState();- Preconditions.checkArgument(state.file.revision != null- && state.file.path != null && state.file.mode != null);+ BlobIdent blobIdent = context.getBlobIdent();+ Preconditions.checkArgument(blobIdent.revision != null+ && blobIdent.path != null && blobIdent.mode != null);this.context = context;}+ private Blob getBlob() {+ return context.getRepository().getBlob(context.getBlobIdent());+ }+@Overrideprotected void onInitialize() {super.onInitialize();@@ -47,7 +52,7 @@ public abstract class BlobViewPanel extends Panel {@Overridepublic String getObject() {- return context.getBlob().getText().getLines().size() + " lines";+ return getBlob().getText().getLines().size() + " lines";}}) {@@ -56,7 +61,7 @@ public abstract class BlobViewPanel extends Panel {protected void onConfigure() {super.onConfigure();- setVisible(context.getBlob().getText() != null);+ setVisible(getBlob().getText() != null);}});@@ -65,7 +70,7 @@ public abstract class BlobViewPanel extends Panel {@Overridepublic String getObject() {- return context.getBlob().getText().getCharset().displayName();+ return getBlob().getText().getCharset().displayName();}}) {@@ -74,15 +79,15 @@ public abstract class BlobViewPanel extends Panel {protected void onConfigure() {super.onConfigure();- setVisible(context.getBlob().getText() != null);+ setVisible(getBlob().getText() != null);}});- add(new Label("size", FileUtils.byteCountToDisplaySize(context.getBlob().getSize())));+ add(new Label("size", FileUtils.byteCountToDisplaySize(getBlob().getSize())));add(new ResourceLink<Void>("raw", new BlobResourceReference(),- BlobResource.paramsOf(context.getRepository(), context.getState().file)));+ BlobResource.paramsOf(context.getRepository(), context.getBlobIdent())));add(new AjaxLink<Void>("blame") {@@ -94,7 +99,7 @@ public abstract class BlobViewPanel extends Panel {@Overridepublic String getObject() {- if (context.getState().blame)+ if (context.isBlame())return " active";elsereturn " ";@@ -107,7 +112,6 @@ public abstract class BlobViewPanel extends Panel {@Overridepublic void onClick(AjaxRequestTarget target) {- context.getState().blame = !context.getState().blame;context.onBlameChange(target);// this blob view panel might be replaced with another panel@@ -121,7 +125,7 @@ public abstract class BlobViewPanel extends Panel {protected void onConfigure() {super.onConfigure();- setVisible(context.getBlob().getText() != null);+ setVisible(getBlob().getText() != null);}});@@ -141,7 +145,7 @@ public abstract class BlobViewPanel extends Panel {protected void onComponentTag(ComponentTag tag) {super.onComponentTag(tag);- if (!context.getRepository().getRefs(Git.REFS_HEADS).containsKey(context.getState().file.revision))+ if (!context.getRepository().getRefs(Git.REFS_HEADS).containsKey(context.getBlobIdent().revision))tag.put("title", "Must on a branch to change or propose change of this file");}@@ -154,14 +158,14 @@ public abstract class BlobViewPanel extends Panel {protected void onConfigure() {super.onConfigure();- setVisible(context.getBlob().getText() != null);+ setVisible(getBlob().getText() != null);}@Overrideprotected void onComponentTag(ComponentTag tag) {super.onComponentTag(tag);- if (!context.getRepository().getRefs(Git.REFS_HEADS).containsKey(context.getState().file.revision))+ if (!context.getRepository().getRefs(Git.REFS_HEADS).containsKey(context.getBlobIdent().revision))tag.put("disabled", "disabled");}@@ -178,7 +182,7 @@ public abstract class BlobViewPanel extends Panel {protected void onComponentTag(ComponentTag tag) {super.onComponentTag(tag);- if (!context.getRepository().getRefs(Git.REFS_HEADS).containsKey(context.getState().file.revision))+ if (!context.getRepository().getRefs(Git.REFS_HEADS).containsKey(context.getBlobIdent().revision))tag.put("disabled", "disabled");}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/binary/BinaryRenderer.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/binary/BinaryRenderer.javaindex 41c7860a9f..5e45782797 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/binary/BinaryRenderer.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/binary/BinaryRenderer.java@@ -1,5 +1,6 @@package com.pmease.gitplex.web.component.repofile.blobview.binary;+import com.pmease.commons.git.Blob;import com.pmease.gitplex.web.component.repofile.blobview.BlobRenderer;import com.pmease.gitplex.web.component.repofile.blobview.BlobViewContext;import com.pmease.gitplex.web.component.repofile.blobview.BlobViewPanel;@@ -8,8 +9,10 @@ public class BinaryRenderer implements BlobRenderer {@Overridepublic BlobViewPanel render(String panelId, BlobViewContext context) {- if (context.getBlob().getText() == null- && !context.getBlob().getMediaType().getType().equalsIgnoreCase("image")) {+ Blob blob = context.getRepository().getBlob(context.getBlobIdent());++ if (blob.getText() == null+ && !blob.getMediaType().getType().equalsIgnoreCase("image")) {return new BinaryViewPanel(panelId, context);} else {return null;diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/gitlink/GitLinkPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/gitlink/GitLinkPanel.javaindex 73aaed2ed1..d45f096f0b 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/gitlink/GitLinkPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/gitlink/GitLinkPanel.java@@ -8,6 +8,7 @@ import org.apache.wicket.markup.html.basic.Label;import org.apache.wicket.markup.html.link.Link;import org.apache.wicket.request.resource.CssResourceReference;+import com.pmease.commons.git.Blob;import com.pmease.commons.git.Submodule;import com.pmease.gitplex.core.GitPlex;import com.pmease.gitplex.core.manager.ConfigManager;@@ -20,12 +21,13 @@ public class GitLinkPanel extends BlobViewPanel {public GitLinkPanel(String id, BlobViewContext context) {super(id, context);}-+@Overrideprotected void onInitialize() {super.onInitialize();- Submodule submodule = Submodule.fromString(context.getBlob().getText().getContent());+ Blob blob = context.getRepository().getBlob(context.getBlobIdent());+ Submodule submodule = Submodule.fromString(blob.getText().getContent());WebMarkupContainer link;ConfigManager configManager = GitPlex.getInstance(ConfigManager.class);if (submodule.getUrl().startsWith(configManager.getSystemSetting().getServerUrl() + "/")) {diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/gitlink/GitLinkRenderer.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/gitlink/GitLinkRenderer.javaindex 49375d2d37..ef1d8d6bde 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/gitlink/GitLinkRenderer.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/gitlink/GitLinkRenderer.java@@ -8,7 +8,7 @@ public class GitLinkRenderer implements BlobRenderer {@Overridepublic BlobViewPanel render(String panelId, BlobViewContext context) {- if (context.getState().file.isGitLink())+ if (context.getBlobIdent().isGitLink())return new GitLinkPanel(panelId, context);elsereturn null;diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/image/ImageRenderer.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/image/ImageRenderer.javaindex ee17bfb718..93e5f356fc 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/image/ImageRenderer.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/image/ImageRenderer.java@@ -1,5 +1,6 @@package com.pmease.gitplex.web.component.repofile.blobview.image;+import com.pmease.commons.git.Blob;import com.pmease.gitplex.web.component.repofile.blobview.BlobRenderer;import com.pmease.gitplex.web.component.repofile.blobview.BlobViewContext;import com.pmease.gitplex.web.component.repofile.blobview.BlobViewPanel;@@ -8,7 +9,8 @@ public class ImageRenderer implements BlobRenderer {@Overridepublic BlobViewPanel render(String panelId, BlobViewContext context) {- if (context.getBlob().getMediaType().getType().equalsIgnoreCase("image"))+ Blob blob = context.getRepository().getBlob(context.getBlobIdent());+ if (blob.getMediaType().getType().equalsIgnoreCase("image"))return new ImageViewPanel(panelId, context);elsereturn null;diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/image/ImageViewPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/image/ImageViewPanel.javaindex 3ee8350d33..8ca0fcaf65 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/image/ImageViewPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/image/ImageViewPanel.java@@ -22,7 +22,7 @@ public class ImageViewPanel extends BlobViewPanel {super.onInitialize();add(new Image("img", new BlobResourceReference(),- BlobResource.paramsOf(context.getRepository(), context.getState().file)));+ BlobResource.paramsOf(context.getRepository(), context.getBlobIdent())));}@Overridediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/markdown/MarkdownRenderer.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/markdown/MarkdownRenderer.javaindex 813789a132..872ea2f8c5 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/markdown/MarkdownRenderer.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/markdown/MarkdownRenderer.java@@ -1,5 +1,6 @@package com.pmease.gitplex.web.component.repofile.blobview.markdown;+import com.pmease.commons.git.Blob;import com.pmease.gitplex.web.component.repofile.blobview.BlobRenderer;import com.pmease.gitplex.web.component.repofile.blobview.BlobViewContext;import com.pmease.gitplex.web.component.repofile.blobview.BlobViewPanel;@@ -9,10 +10,11 @@ public class MarkdownRenderer implements BlobRenderer {@Overridepublic BlobViewPanel render(String panelId, BlobViewContext context) {- if (context.getState().file.isFile()- && context.getBlob().getText() != null- && context.getState().file.path.endsWith(".md")) {- if (context.getState().tokenPos != null || context.getState().blame)+ Blob blob = context.getRepository().getBlob(context.getBlobIdent());+ if (context.getBlobIdent().isFile()+ && blob.getText() != null+ && context.getBlobIdent().path.endsWith(".md")) {+ if (context.getTokenPos() != null || context.isBlame())return new SourceViewPanel(panelId, context);elsereturn new MarkdownViewPanel(panelId, context);diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/markdown/MarkdownViewPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/markdown/MarkdownViewPanel.javaindex ea578204c0..f7fa4ddb54 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/markdown/MarkdownViewPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/markdown/MarkdownViewPanel.java@@ -5,6 +5,7 @@ import org.apache.wicket.markup.head.IHeaderResponse;import org.apache.wicket.model.Model;import org.apache.wicket.request.resource.CssResourceReference;+import com.pmease.commons.git.Blob;import com.pmease.commons.wicket.component.markdown.MarkdownPanel;import com.pmease.gitplex.web.component.repofile.blobview.BlobViewContext;import com.pmease.gitplex.web.component.repofile.blobview.BlobViewPanel;@@ -20,7 +21,8 @@ public class MarkdownViewPanel extends BlobViewPanel {protected void onInitialize() {super.onInitialize();- add(new MarkdownPanel("markdown", Model.of(context.getBlob().getText().getContent())));+ Blob blob = context.getRepository().getBlob(context.getBlobIdent());+ add(new MarkdownPanel("markdown", Model.of(blob.getText().getContent())));}@Overridediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/SourceRenderer.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/SourceRenderer.javaindex 639e85b3d6..b94b273787 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/SourceRenderer.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/SourceRenderer.java@@ -1,5 +1,6 @@package com.pmease.gitplex.web.component.repofile.blobview.source;+import com.pmease.commons.git.Blob;import com.pmease.gitplex.web.component.repofile.blobview.BlobRenderer;import com.pmease.gitplex.web.component.repofile.blobview.BlobViewContext;import com.pmease.gitplex.web.component.repofile.blobview.BlobViewPanel;@@ -8,9 +9,10 @@ public class SourceRenderer implements BlobRenderer {@Overridepublic BlobViewPanel render(String panelId, BlobViewContext context) {- if (context.getState().file.isFile()- && context.getBlob().getText() != null- && !context.getState().file.path.endsWith(".md")) {+ Blob blob = context.getRepository().getBlob(context.getBlobIdent());+ if (context.getBlobIdent().isFile()+ && blob.getText() != null+ && !context.getBlobIdent().path.endsWith(".md")) {return new SourceViewPanel(panelId, context);} else {return null;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 717d614f9f..d87e1add2c 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@@ -37,6 +37,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;import com.fasterxml.jackson.databind.ObjectMapper;import com.google.common.base.Preconditions;import com.pmease.commons.git.Blame;+import com.pmease.commons.git.Blob;import com.pmease.commons.git.BlobIdent;import com.pmease.commons.git.GitUtils;import com.pmease.commons.lang.extractors.ExtractException;@@ -81,14 +82,15 @@ public class SourceViewPanel extends BlobViewPanel {public SourceViewPanel(String id, BlobViewContext context) {super(id, context);- Preconditions.checkArgument(context.getBlob().getText() != null);+ Blob blob = context.getRepository().getBlob(context.getBlobIdent());+ Preconditions.checkArgument(blob.getText() != null);- Extractor extractor = GitPlex.getInstance(Extractors.class).getExtractor(context.getState().file.path);+ Extractor extractor = GitPlex.getInstance(Extractors.class).getExtractor(context.getBlobIdent().path);if (extractor != null) {try {- symbols.addAll(extractor.extract(context.getBlob().getText().getContent()));+ symbols.addAll(extractor.extract(blob.getText().getContent()));} catch (ExtractException e) {- logger.debug("Error extracting symbols from blob: " + context.getState().file, e);+ logger.debug("Error extracting symbols from blob: " + context.getBlobIdent(), e);}}}@@ -164,7 +166,7 @@ public class SourceViewPanel extends BlobViewPanel {codeContainer.getMarkupId());target.prependJavaScript(script);BlobIdent blobIdent = new BlobIdent(- context.getState().file.revision,+ context.getBlobIdent().revision,hit.getBlobPath(),FileMode.REGULAR_FILE.getBits());context.onSelect(target, blobIdent, hit.getTokenPos());@@ -202,7 +204,7 @@ public class SourceViewPanel extends BlobViewPanel {try {SearchManager searchManager = GitPlex.getInstance(SearchManager.class);List<QueryHit> hits = searchManager.search(context.getRepository(),- context.getState().file.revision, query);+ context.getBlobIdent().revision, query);String script = String.format("$('#%s .CodeMirror')[0].CodeMirror.hideTokenHover();",codeContainer.getMarkupId());@@ -235,11 +237,11 @@ public class SourceViewPanel extends BlobViewPanel {try {SymbolQuery query = new SymbolQuery(symbol, true, true, null, null, QUERY_ENTRIES);SearchManager searchManager = GitPlex.getInstance(SearchManager.class);- symbolHits = searchManager.search(context.getRepository(), context.getState().file.revision, query);+ symbolHits = searchManager.search(context.getRepository(), context.getBlobIdent().revision, query);if (symbolHits.size() < QUERY_ENTRIES) {query = new SymbolQuery(symbol, false, true, null, null, QUERY_ENTRIES - symbolHits.size());symbolHits.addAll(searchManager.search(context.getRepository(),- context.getState().file.revision, query));+ context.getBlobIdent().revision, query));}} catch (InterruptedException e) {throw new RuntimeException(e);@@ -264,15 +266,16 @@ public class SourceViewPanel extends BlobViewPanel {String highlightToken;try {- highlightToken = GitPlex.getInstance(ObjectMapper.class).writeValueAsString(context.getState().tokenPos);+ highlightToken = GitPlex.getInstance(ObjectMapper.class).writeValueAsString(context.getTokenPos());} catch (JsonProcessingException e) {throw new RuntimeException(e);}ResourceReference ajaxIndicator = new PackageResourceReference(SourceViewPanel.class, "ajax-indicator.gif");+ Blob blob = context.getRepository().getBlob(context.getBlobIdent());String script = String.format("gitplex.sourceview.init('%s', '%s', '%s', %s, '%s', %s, %s);",codeContainer.getMarkupId(),- StringEscapeUtils.escapeEcmaScript(context.getBlob().getText().getContent()),- context.getState().file.path,+ StringEscapeUtils.escapeEcmaScript(blob.getText().getContent()),+ context.getBlobIdent().path,highlightToken,RequestCycle.get().urlFor(ajaxIndicator, new PageParameters()),getCallbackFunction(CallbackParameter.explicit("symbol")),@@ -292,12 +295,12 @@ public class SourceViewPanel extends BlobViewPanel {}private String getBlameCommits() {- if (context.getState().blame) {+ if (context.isBlame()) {List<BlameCommit> commits = new ArrayList<>();- String commitHash = context.getRepository().getObjectId(context.getState().file.revision).name();+ String commitHash = context.getRepository().getObjectId(context.getBlobIdent().revision).name();- for (Blame blame: context.getRepository().git().blame(commitHash, context.getState().file.path).values()) {+ for (Blame blame: context.getRepository().git().blame(commitHash, context.getBlobIdent().path).values()) {BlameCommit commit = new BlameCommit();commit.authorDate = DateUtils.formatDate(blame.getCommit().getAuthor().getWhen());commit.authorName = StringEscapeUtils.escapeHtml4(blame.getCommit().getAuthor().getName());diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/symbollink/SymbolLinkPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/symbollink/SymbolLinkPanel.javaindex 4451d660fe..1b2a514e53 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/symbollink/SymbolLinkPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/symbollink/SymbolLinkPanel.java@@ -18,6 +18,7 @@ import org.eclipse.jgit.revwalk.RevTree;import org.eclipse.jgit.revwalk.RevWalk;import org.eclipse.jgit.treewalk.TreeWalk;+import com.pmease.commons.git.Blob;import com.pmease.gitplex.web.component.repofile.blobview.BlobViewContext;import com.pmease.gitplex.web.component.repofile.blobview.BlobViewPanel;import com.pmease.gitplex.web.page.repository.file.RepoFilePage;@@ -33,16 +34,17 @@ public class SymbolLinkPanel extends BlobViewPanel {protected void onInitialize() {super.onInitialize();+ Blob blob = context.getRepository().getBlob(context.getBlobIdent());String targetPath = FilenameUtils.normalize(- Paths.get(context.getState().file.path).resolveSibling(- context.getBlob().getText().getContent()).toString(), true);+ Paths.get(context.getBlobIdent().path).resolveSibling(+ blob.getText().getContent()).toString(), true);if (targetPath != null && (targetPath.startsWith("/") || new File(targetPath).isAbsolute()))targetPath = null;if (targetPath != null) {try ( FileRepository jgitRepo = context.getRepository().openAsJGitRepo();RevWalk revWalk = new RevWalk(jgitRepo)) {- ObjectId commitId = context.getRepository().getObjectId(context.getState().file.revision);+ ObjectId commitId = context.getRepository().getObjectId(context.getBlobIdent().revision);RevTree revTree = revWalk.parseCommit(commitId).getTree();TreeWalk treeWalk = TreeWalk.forPath(jgitRepo, targetPath, revTree);if (treeWalk == null)@@ -64,9 +66,9 @@ public class SymbolLinkPanel extends BlobViewPanel {link.setEnabled(false);} else {link = new BookmarkablePageLink<Void>("link", RepoFilePage.class,- RepoFilePage.paramsOf(context.getRepository(), context.getState().file.revision, targetPath));+ RepoFilePage.paramsOf(context.getRepository(), context.getBlobIdent().revision, targetPath));}- link.add(new Label("label", context.getBlob().getText().getContent()));+ link.add(new Label("label", blob.getText().getContent()));add(link);}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/symbollink/SymbolLinkRenderer.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/symbollink/SymbolLinkRenderer.javaindex 13e652dcf2..8cf3ea67e9 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/symbollink/SymbolLinkRenderer.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/symbollink/SymbolLinkRenderer.java@@ -8,7 +8,7 @@ public class SymbolLinkRenderer implements BlobRenderer {@Overridepublic BlobViewPanel render(String panelId, BlobViewContext context) {- if (context.getState().file.isSymbolLink())+ if (context.getBlobIdent().isSymbolLink())return new SymbolLinkPanel(panelId, context);elsereturn null;diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/RepoFilePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/RepoFilePage.javaindex c677e69544..43c026252f 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/RepoFilePage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/RepoFilePage.java@@ -62,6 +62,7 @@ import com.pmease.gitplex.web.component.repofile.blobsearch.advanced.AdvancedSeaimport com.pmease.gitplex.web.component.repofile.blobsearch.instant.InstantSearchPanel;import com.pmease.gitplex.web.component.repofile.blobsearch.result.SearchResultPanel;import com.pmease.gitplex.web.component.repofile.blobview.BlobNameChangeCallback;+import com.pmease.gitplex.web.component.repofile.blobview.BlobRenderer;import com.pmease.gitplex.web.component.repofile.blobview.BlobViewContext;import com.pmease.gitplex.web.component.repofile.blobview.BlobViewPanel;import com.pmease.gitplex.web.component.repofile.blobview.source.SourceViewPanel;@@ -131,7 +132,7 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {}};- private BlobIdent file = new BlobIdent();+ private BlobIdent blobIdent = new BlobIdent();private TokenPosition tokenPos;@@ -156,27 +157,27 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {throw new RestartResponseException(NoCommitsPage.class, paramsOf(getRepository()));trait.repoId = getRepository().getId();- file.revision = GitUtils.normalizePath(params.get(PARAM_REVISION).toString());- if (file.revision == null)- file.revision = getRepository().getDefaultBranch();- trait.revision = file.revision;+ blobIdent.revision = GitUtils.normalizePath(params.get(PARAM_REVISION).toString());+ if (blobIdent.revision == null)+ blobIdent.revision = getRepository().getDefaultBranch();+ trait.revision = blobIdent.revision;- file.path = GitUtils.normalizePath(params.get(PARAM_PATH).toString());- if (file.path != null) {+ blobIdent.path = GitUtils.normalizePath(params.get(PARAM_PATH).toString());+ if (blobIdent.path != null) {try ( FileRepository jgitRepo = getRepository().openAsJGitRepo();RevWalk revWalk = new RevWalk(jgitRepo)) {RevTree revTree = revWalk.parseCommit(getCommitId()).getTree();- TreeWalk treeWalk = TreeWalk.forPath(jgitRepo, file.path, revTree);+ TreeWalk treeWalk = TreeWalk.forPath(jgitRepo, blobIdent.path, revTree);if (treeWalk == null) {- throw new ObjectNotExistException("Unable to find blob path '" + file.path- + "' in revision '" + file.revision + "'");+ throw new ObjectNotExistException("Unable to find blob path '" + blobIdent.path+ + "' in revision '" + blobIdent.revision + "'");}- file.mode = treeWalk.getRawMode(0);+ blobIdent.mode = treeWalk.getRawMode(0);} catch (IOException e) {throw new RuntimeException(e);}} else {- file.mode = FileMode.TREE.getBits();+ blobIdent.mode = FileMode.TREE.getBits();}blame = params.get(PARAM_BLAME).toBoolean(false);@@ -185,7 +186,7 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {}private ObjectId getCommitId() {- return getRepository().getObjectId(file.revision);+ return getRepository().getObjectId(blobIdent.revision);}@Override@@ -202,16 +203,16 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {@Overridepublic String getObject() {- return file.revision;+ return blobIdent.revision;}}) {@Overrideprotected void onSelect(AjaxRequestTarget target, QueryHit hit) {- BlobIdent blobIdent = new BlobIdent(file.revision, hit.getBlobPath(),+ BlobIdent selected = new BlobIdent(blobIdent.revision, hit.getBlobPath(),FileMode.REGULAR_FILE.getBits());- RepoFilePage.this.onSelect(target, blobIdent, hit.getTokenPos());+ RepoFilePage.this.onSelect(target, selected, hit.getTokenPos());}@Override@@ -229,7 +230,7 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {@Overridepublic String getObject() {- return file.revision;+ return blobIdent.revision;}}) {@@ -247,7 +248,7 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {@Overrideprotected BlobIdent getCurrentBlob() {- return file;+ return blobIdent;}};@@ -271,14 +272,14 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {super.onConfigure();IndexManager indexManager = GitPlex.getInstance(IndexManager.class);- if (!indexManager.isIndexed(getRepository(), file.revision)) {+ if (!indexManager.isIndexed(getRepository(), blobIdent.revision)) {final Long repoId = getRepository().getId();GitPlex.getInstance(UnitOfWork.class).asyncCall(new Runnable() {@Overridepublic void run() {Repository repo = GitPlex.getInstance(Dao.class).load(Repository.class, repoId);- GitPlex.getInstance(IndexManager.class).index(repo, file.revision);+ GitPlex.getInstance(IndexManager.class).index(repo, blobIdent.revision);}});@@ -320,24 +321,24 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {}private void newRevisionSelector(@Nullable AjaxRequestTarget target) {- revisionSelector = new RevisionSelector(REVISION_SELECTOR_ID, repoModel, file.revision) {+ revisionSelector = new RevisionSelector(REVISION_SELECTOR_ID, repoModel, blobIdent.revision) {@Overrideprotected void onSelect(AjaxRequestTarget target, String revision) {- BlobIdent blobIdent = new BlobIdent();- blobIdent.revision = revision;- blobIdent.mode = FileMode.TREE.getBits();+ BlobIdent selected = new BlobIdent();+ selected.revision = revision;+ selected.mode = FileMode.TREE.getBits();trait.revision = revision;- if (file.path != null) {+ if (selected.path != null) {try ( FileRepository jgitRepo = getRepository().openAsJGitRepo();RevWalk revWalk = new RevWalk(jgitRepo)) {RevTree revTree = revWalk.parseCommit(getCommitId()).getTree();- TreeWalk treeWalk = TreeWalk.forPath(jgitRepo, file.path, revTree);+ TreeWalk treeWalk = TreeWalk.forPath(jgitRepo, selected.path, revTree);if (treeWalk != null) {- blobIdent.path = file.path;- blobIdent.mode = treeWalk.getRawMode(0);+ selected.path = blobIdent.path;+ selected.mode = treeWalk.getRawMode(0);}} catch (IOException e) {throw new RuntimeException(e);@@ -346,7 +347,7 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {requestId = null;commentId = null;- RepoFilePage.this.onSelect(target, blobIdent, null);+ RepoFilePage.this.onSelect(target, selected, null);newRevisionSelector(target);newCommentContext(target);target.add(revisionIndexing);@@ -401,7 +402,7 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {}private void newFileNavigator(@Nullable AjaxRequestTarget target, @Nullable BlobNameChangeCallback callback) {- fileNavigator = new FileNavigator(FILE_NAVIGATOR_ID, repoModel, file, callback) {+ fileNavigator = new FileNavigator(FILE_NAVIGATOR_ID, repoModel, blobIdent, callback) {@Overrideprotected void onSelect(AjaxRequestTarget target, BlobIdent file) {@@ -423,24 +424,24 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {}private void onAddOrEditFile(AjaxRequestTarget target) {- ObjectId commitId = getRepository().getObjectId(file.revision);+ ObjectId commitId = getRepository().getObjectId(blobIdent.revision);- String refName = Git.REFS_HEADS + file.revision;+ String refName = Git.REFS_HEADS + blobIdent.revision;- final AtomicReference<String> newPathRef = new AtomicReference<>(file.isTree()?null:file.path);+ final AtomicReference<String> newPathRef = new AtomicReference<>(blobIdent.isTree()?null:blobIdent.path);fileViewer = new FileEditPanel(FILE_VIEWER_ID, repoModel, refName,- file.isTree()?null:file.path,- file.isTree()?"":getRepository().getBlob(file).getText().getContent(),+ blobIdent.isTree()?null:blobIdent.path,+ blobIdent.isTree()?"":getRepository().getBlob(blobIdent).getText().getContent(),commitId) {@Overrideprotected void onCommitted(AjaxRequestTarget target, ObjectId newCommitId) {- getRepository().cacheObjectId(file.revision, newCommitId);- BlobIdent blobIdent = new BlobIdent(- file.revision, newPathRef.get(), FileMode.REGULAR_FILE.getBits());- onSelect(target, blobIdent, null);+ getRepository().cacheObjectId(blobIdent.revision, newCommitId);+ BlobIdent committed = new BlobIdent(+ blobIdent.revision, newPathRef.get(), FileMode.REGULAR_FILE.getBits());+ onSelect(target, committed, null);}@Override@@ -457,14 +458,14 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {@Overridepublic void onChange(AjaxRequestTarget target, String blobName) {String newPath;- if (file.isTree()) {- if (file.path != null)- newPath = file.path + "/" + blobName;+ if (blobIdent.isTree()) {+ if (blobIdent.path != null)+ newPath = blobIdent.path + "/" + blobName;elsenewPath = blobName;} else {- if (file.path.contains("/"))- newPath = StringUtils.substringBeforeLast(file.path, "/") + "/" + blobName;+ if (blobIdent.path.contains("/"))+ newPath = StringUtils.substringBeforeLast(blobIdent.path, "/") + "/" + blobName;elsenewPath = blobName;}@@ -499,7 +500,7 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {@Overridepublic Component getLazyLoadComponent(String markupId) {- return new LastCommitPanel(markupId, repoModel, file);+ return new LastCommitPanel(markupId, repoModel, blobIdent);}};lastCommit.setOutputMarkupPlaceholderTag(true);@@ -511,9 +512,19 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {}}+ private BlobViewPanel renderBlobViewer(String panelId) {+ for (BlobRenderer renderer: GitPlex.getExtensions(BlobRenderer.class)) {+ BlobViewPanel panel = renderer.render(panelId, this);+ if (panel != null)+ return panel;+ }++ throw new IllegalStateException("No applicable blob renderer found.");+ }+private void newFileViewer(@Nullable AjaxRequestTarget target) {- if (file.path == null || file.isTree()) {- fileViewer = new FileListPanel(FILE_VIEWER_ID, repoModel, file) {+ if (blobIdent.path == null || blobIdent.isTree()) {+ fileViewer = new FileListPanel(FILE_VIEWER_ID, repoModel, blobIdent) {@Overrideprotected void onSelect(AjaxRequestTarget target, BlobIdent file) {@@ -522,7 +533,7 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {};} else {- fileViewer = newBlobViewContext().render(FILE_VIEWER_ID);+ fileViewer = renderBlobViewer(FILE_VIEWER_ID);}if (target != null) {@@ -535,13 +546,14 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {}private void pushState(AjaxRequestTarget target) {- PageParameters params = paramsOf(getRepository(), state);+ PageParameters params = paramsOf(getRepository(), blobIdent.revision, blobIdent.path,+ blame, commentId, requestId);CharSequence url = RequestCycle.get().urlFor(RepoFilePage.class, params);HistoryState state = new HistoryState();state.blame = blame;state.commentId = commentId;state.requestId = requestId;- state.file = file;+ state.file = blobIdent;state.tokenPos = tokenPos;pushState(target, url.toString(), state);}@@ -608,15 +620,13 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {@Overrideprotected void onSelect(AjaxRequestTarget target, QueryHit hit) {- if (hit.getBlobPath().equals(file.path) && fileViewer instanceof SourceViewPanel) {+ if (hit.getBlobPath().equals(blobIdent.path) && fileViewer instanceof SourceViewPanel) {tokenPos = hit.getTokenPos();SourceViewPanel sourceViewer = (SourceViewPanel) fileViewer;- BlobViewContext context = sourceViewer.getContext();- context.getState().tokenPos = tokenPos;if (tokenPos != null || blame) {sourceViewer.highlightToken(target, tokenPos);} else {- BlobViewPanel blobViewer = sourceViewer.getContext().render(FILE_VIEWER_ID);+ BlobViewPanel blobViewer = renderBlobViewer(FILE_VIEWER_ID);if (blobViewer instanceof SourceViewPanel) {sourceViewer.highlightToken(target, tokenPos);} else {@@ -628,9 +638,9 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {}pushState(target);} else {- BlobIdent blobIdent = new BlobIdent(file.revision, hit.getBlobPath(),+ BlobIdent selected = new BlobIdent(blobIdent.revision, hit.getBlobPath(),FileMode.REGULAR_FILE.getBits());- RepoFilePage.this.onSelect(target, blobIdent, hit.getTokenPos());+ RepoFilePage.this.onSelect(target, selected, hit.getTokenPos());}}@@ -651,13 +661,13 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {super.onPopState(target, data);HistoryState state = (HistoryState) data;- file = state.file;+ blobIdent = state.file;blame = state.blame;commentId = state.commentId;requestId = state.requestId;tokenPos = state.tokenPos;- trait.revision = file.revision;+ trait.revision = blobIdent.revision;target.add(revisionIndexing);newRevisionSelector(target);@@ -714,7 +724,7 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {@Overridepublic BlobIdent getBlobIdent() {- return file;+ return blobIdent;}@Override@@ -729,7 +739,7 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {@Overridepublic void onSelect(AjaxRequestTarget target, BlobIdent blobIdent, TokenPosition tokenPos) {- file = blobIdent;+ this.blobIdent = blobIdent;this.tokenPos = tokenPos;blame = false;@@ -747,14 +757,14 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {@Overridepublic void onBlameChange(AjaxRequestTarget target) {- blame = getState().blame;+ blame = !blame;if (fileViewer instanceof SourceViewPanel) {SourceViewPanel sourceViewer = (SourceViewPanel) fileViewer;if (blame || tokenPos != null) {sourceViewer.onBlameChange(target);} else {- BlobViewPanel blobViewer = sourceViewer.getContext().render(FILE_VIEWER_ID);+ BlobViewPanel blobViewer = renderBlobViewer(FILE_VIEWER_ID);if (blobViewer instanceof SourceViewPanel) {sourceViewer.onBlameChange(target);} else {@@ -773,9 +783,9 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {@Overridepublic void onDelete(AjaxRequestTarget target) {- ObjectId commitId = getRepository().getObjectId(getState().file.revision);+ ObjectId commitId = getRepository().getObjectId(blobIdent.revision);- String refName = Git.REFS_HEADS + file.revision;+ String refName = Git.REFS_HEADS + blobIdent.revision;CancelListener cancelListener = new CancelListener() {@@ -787,16 +797,16 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {}};- fileViewer = new EditSavePanel(FILE_VIEWER_ID, repoModel, refName, file.path,+ fileViewer = new EditSavePanel(FILE_VIEWER_ID, repoModel, refName, blobIdent.path,null, commitId, cancelListener) {@Overrideprotected void onCommitted(AjaxRequestTarget target, ObjectId newCommitId) {- getRepository().cacheObjectId(file.revision, newCommitId);+ getRepository().cacheObjectId(blobIdent.revision, newCommitId);try ( FileRepository jgitRepo = getRepository().openAsJGitRepo();RevWalk revWalk = new RevWalk(jgitRepo)) {RevTree revTree = revWalk.parseCommit(newCommitId).getTree();- String parentPath = StringUtils.substringBeforeLast(file.path, "/");+ String parentPath = StringUtils.substringBeforeLast(blobIdent.path, "/");while (TreeWalk.forPath(jgitRepo, parentPath, revTree) == null) {if (parentPath.contains("/")) {parentPath = StringUtils.substringBeforeLast(parentPath, "/");@@ -805,7 +815,8 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {break;}}- BlobIdent parentBlobIdent = new BlobIdent(file.revision, parentPath, FileMode.TREE.getBits());+ BlobIdent parentBlobIdent = new BlobIdent(blobIdent.revision, parentPath,+ FileMode.TREE.getBits());onSelect(target, parentBlobIdent, null);} catch (IOException e) {throw new RuntimeException(e);diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/HistoryState.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/HistoryState.javanew file mode 100644index 0000000000..dfd8ed17c7--- /dev/null+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/HistoryState.java@@ -0,0 +1,18 @@+package com.pmease.gitplex.web.page.repository.pullrequest.requestdetail.compare;++import java.io.Serializable;++class HistoryState implements Serializable {++ private static final long serialVersionUID = 1L;++ public String oldCommitHash;++ public String newCommitHash;++ public String path;++ public String comparePath;++ public Long commentId;+}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/RequestComparePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/RequestComparePage.javaindex f29e7a9322..cfe60e73b7 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/RequestComparePage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/RequestComparePage.java@@ -87,6 +87,8 @@ public class RequestComparePage extends RequestDetailPage {private static final String PARAM_COMPARE_PATH = "comparePath";+ private HistoryState state = new HistoryState();+private String oldCommitHash;private String newCommitHash;@@ -97,6 +99,18 @@ public class RequestComparePage extends RequestDetailPage {private Long commentId;+ private final IModel<PullRequestComment> commentModel = new LoadableDetachableModel<PullRequestComment>() {++ @Override+ protected PullRequestComment load() {+ if (commentId != null)+ return GitPlex.getInstance(Dao.class).load(PullRequestComment.class, commentId);+ else+ return null;+ }++ };+private WebMarkupContainer compareOptions;private DiffOptionPanel diffOption;@@ -147,9 +161,36 @@ public class RequestComparePage extends RequestDetailPage {};- public RequestComparePage(final PageParameters params) {+ public RequestComparePage(PageParameters params) {super(params);- initState(params);++ state.commentId = params.get(PARAM_COMMENT).toOptionalLong();+ state.oldCommitHash = params.get(PARAM_OLD_COMMIT).toString();+ state.newCommitHash = params.get(PARAM_NEW_COMMIT).toString();+ state.path = params.get(PARAM_PATH).toString();+ state.comparePath = params.get(PARAM_COMPARE_PATH).toString();++ initWithState(state);+ }++ private void initWithState(HistoryState state) {+ commentId = state.commentId;+ PullRequestComment comment = commentModel.getObject();+ if (comment != null) {+ oldCommitHash = comment.getOldCommitHash();+ newCommitHash = comment.getNewCommitHash();+ path = comment.getBlobIdent().path;+ comparePath = comment.getCompareWith().path;+ } else {+ oldCommitHash = state.oldCommitHash;+ newCommitHash = state.newCommitHash;+ path = state.path;+ comparePath = state.comparePath;+ if (oldCommitHash == null)+ oldCommitHash = getPullRequest().getBaseCommitHash();+ if (newCommitHash == null)+ newCommitHash = getPullRequest().getLatestUpdate().getHeadCommitHash();+ }}@Override@@ -359,8 +400,8 @@ public class RequestComparePage extends RequestDetailPage {if (commentId != null) {detachComment();} else {- getPageParameters().set(PARAM_PATH, path);- getPageParameters().remove(PARAM_COMPARE_PATH);+ state.path = path;+ state.comparePath = null;}newCompareResult(target);pushState(target);@@ -390,8 +431,7 @@ public class RequestComparePage extends RequestDetailPage {super.onEvent(event);if (event.getPayload() instanceof PullRequestChanged) {- PageParameters params = getPageParameters();- if (params.get(PARAM_NEW_COMMIT).toString() == null) {+ if (state.newCommitHash == null) {setVisible(true);PullRequestChanged pullRequestChanged = (PullRequestChanged) event.getPayload();pullRequestChanged.getTarget().add(this);@@ -415,16 +455,16 @@ public class RequestComparePage extends RequestDetailPage {private void detachComment() {commentId = null;- PageParameters params = getPageParameters();- params.set(PARAM_OLD_COMMIT, oldCommitHash);- params.set(PARAM_NEW_COMMIT, newCommitHash);- params.set(PARAM_PATH, path);- params.set(PARAM_COMPARE_PATH, comparePath);- params.remove(PARAM_COMMENT);+ state.oldCommitHash = oldCommitHash;+ state.newCommitHash = newCommitHash;+ state.path = path;+ state.comparePath = comparePath;+ state.commentId = null;}@Overridepublic void onDetach() {+ commentModel.detach();commitsModel.detach();super.onDetach();@@ -437,8 +477,19 @@ public class RequestComparePage extends RequestDetailPage {return params;}+ public static PageParameters paramsOf(PullRequest request, @Nullable String oldCommitHash,+ @Nullable String newCommitHash) {+ return paramsOf(request, oldCommitHash, newCommitHash, null);+ }+public static PageParameters paramsOf(PullRequest request, @Nullable String oldCommitHash,@Nullable String newCommitHash, @Nullable String path) {+ return paramsOf(request, oldCommitHash, newCommitHash, path, null, null);+ }++ public static PageParameters paramsOf(PullRequest request, @Nullable String oldCommitHash,+ @Nullable String newCommitHash, @Nullable String path, @Nullable String comparePath,+ @Nullable Long commentId) {PageParameters params = RequestDetailPage.paramsOf(request);if (oldCommitHash != null)@@ -447,7 +498,10 @@ public class RequestComparePage extends RequestDetailPage {params.set(PARAM_NEW_COMMIT, newCommitHash);if (path != null)params.set(PARAM_PATH, path);-+ if (comparePath != null)+ params.set(PARAM_COMPARE_PATH, path);+ if (commentId != null)+ params.set(PARAM_COMMENT, commentId);return params;}@@ -591,32 +645,12 @@ public class RequestComparePage extends RequestDetailPage {}}- private void initState(PageParameters params) {- commentId = params.get(PARAM_COMMENT).toOptionalLong();- PullRequestComment comment = getComment();- if (comment != null) {- oldCommitHash = comment.getOldCommitHash();- newCommitHash = comment.getNewCommitHash();- path = comment.getBlobIdent().path;- comparePath = comment.getCompareWith().path;- } else {- oldCommitHash = params.get(PARAM_OLD_COMMIT).toString();- newCommitHash = params.get(PARAM_NEW_COMMIT).toString();- path = params.get(PARAM_PATH).toString();- comparePath = params.get(PARAM_COMPARE_PATH).toString();- if (oldCommitHash == null)- oldCommitHash = getPullRequest().getBaseCommitHash();- if (newCommitHash == null)- newCommitHash = getPullRequest().getLatestUpdate().getHeadCommitHash();- }- }-@Overrideprotected void onPopState(AjaxRequestTarget target, Serializable data) {super.onPopState(target, data);- initState((PageParameters) data);- getPageParameters().+ HistoryState state = (HistoryState) data;+ initWithState(state);target.add(compareOptions);newCompareResult(target);@@ -628,9 +662,10 @@ public class RequestComparePage extends RequestDetailPage {}private void pushState(AjaxRequestTarget target) {- PageParameters params = getPageParameters();+ PageParameters params = paramsOf(getPullRequest(), state.oldCommitHash, state.newCommitHash,+ state.path, state.comparePath, state.commentId);CharSequence url = RequestCycle.get().urlFor(RequestComparePage.class, params);- pushState(target, url.toString(), params);+ pushState(target, url.toString(), state);}private void onStateChange(AjaxRequestTarget target) {@@ -669,7 +704,7 @@ public class RequestComparePage extends RequestDetailPage {@Overridepublic InlineComment getConcernedComment() {- return getComment();+ return commentModel.getObject();}@Override@@ -714,8 +749,8 @@ public class RequestComparePage extends RequestDetailPage {if (commentId != null) {detachComment();} else {- getPageParameters().remove(PARAM_PATH);- getPageParameters().remove(PARAM_COMPARE_PATH);+ state.path = null;+ state.comparePath = null;}newCompareResult(target);pushState(target);@@ -738,11 +773,4 @@ public class RequestComparePage extends RequestDetailPage {new CssResourceReference(RequestComparePage.class, "request-compare.css")));}- private PullRequestComment getComment() {- if (commentId != null)- return GitPlex.getInstance(Dao.class).load(PullRequestComment.class, commentId);- else- return null;- }-}