hgBrowseCommand resolves Branches as Revision for BrowseResult

This commit is contained in:
Eduard Heimbuch
2019-10-29 10:40:10 +01:00
parent f4b1bf289a
commit 730646f4a8

View File

@@ -35,6 +35,8 @@ package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import com.aragost.javahg.Changeset;
import com.aragost.javahg.commands.LogCommand;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import sonia.scm.repository.BrowserResult;
@@ -72,10 +74,10 @@ public class HgBrowseCommand extends AbstractCommand implements BrowseCommand
public BrowserResult getBrowserResult(BrowseCommandRequest request) throws IOException {
HgFileviewCommand cmd = HgFileviewCommand.on(open());
if (!Strings.isNullOrEmpty(request.getRevision()))
{
cmd.rev(request.getRevision());
}
String revision = MoreObjects.firstNonNull(request.getRevision(), "tip");
Changeset c = LogCommand.on(getContext().open()).rev(revision).limit(1).single();
cmd.rev(c.getNode());
if (!Strings.isNullOrEmpty(request.getPath()))
{
@@ -98,6 +100,6 @@ public class HgBrowseCommand extends AbstractCommand implements BrowseCommand
}
FileObject file = cmd.execute();
return new BrowserResult(MoreObjects.firstNonNull(request.getRevision(), "tip"), file);
return new BrowserResult(c.getNode(), file);
}
}