Index: src/main/java/hudson/plugins/mercurial/browser/KilnHG.java =================================================================== --- src/main/java/hudson/plugins/mercurial/browser/KilnHG.java (revision 0) +++ src/main/java/hudson/plugins/mercurial/browser/KilnHG.java (revision 0) @@ -0,0 +1,78 @@ +package hudson.plugins.mercurial.browser; + +import hudson.Extension; +import hudson.model.Descriptor; +import hudson.plugins.mercurial.MercurialChangeSet; +import hudson.scm.RepositoryBrowser; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; + +import net.sf.json.JSONObject; + +import org.kohsuke.stapler.DataBoundConstructor; +import org.kohsuke.stapler.StaplerRequest; + +/** + * Mercurial web interface served using a Kiln repository. + */ +public class KilnHG extends HgBrowser { + + @DataBoundConstructor + public KilnHG(String url) throws MalformedURLException { + super(url); + } + + /** + * {@inheritDoc} + */ + @Override + public URL getChangeSetLink(MercurialChangeSet changeSet) + throws IOException { + current = changeSet; + // http://kilnhg.com/Repo/Repositories/Group/RepoName/History/12345 + return new URL(getUrl(), "History/" + changeSet.getShortNode()); + } + + /** + * {@inheritDoc} + * + * Throws {@link IllegalStateException} when this method is called before at least one call + * to {@literal getChangeSetLink(MercurialChangeSet)}. + */ + @Override + public URL getFileLink(String path) throws MalformedURLException { + checkCurrentIsNotNull(); + // http://kilnhg.com/Repo/Repositories/Group/RepoName/File/filename?rev=12345 + return new URL(getUrl(), "File/" + path + "?rev=" + current.getShortNode()); + } + + /** + * {@inheritDoc} + * + * Throws {@link IllegalStateException} when this method is called before at least one call + * to {@literal getChangeSetLink(MercurialChangeSet)}. + */ + @Override + public URL getDiffLink(String path) throws MalformedURLException { + checkCurrentIsNotNull(); + + // http://kilnhg.com/Repo/Repositories/Group/RepoName/History/12345 + return new URL(getUrl(), "History/" + current.getShortNode()); + } + + @Extension + public static class DescriptorImpl extends Descriptor> { + public String getDisplayName() { + return "kilnhg"; + } + + public @Override KilnHG newInstance(StaplerRequest req, JSONObject json) throws FormException { + return req.bindParameters(KilnHG.class,"kilnhg."); + } + } + + private static final long serialVersionUID = 1L; + +} Index: src/main/resources/hudson/plugins/mercurial/browser/KilnHG/config.jelly =================================================================== --- src/main/resources/hudson/plugins/mercurial/browser/KilnHG/config.jelly (revision 0) +++ src/main/resources/hudson/plugins/mercurial/browser/KilnHG/config.jelly (revision 0) @@ -0,0 +1,5 @@ + + + + + Index: src/main/resources/hudson/plugins/mercurial/browser/KilnHG/help-url.html =================================================================== --- src/main/resources/hudson/plugins/mercurial/browser/KilnHG/help-url.html (revision 0) +++ src/main/resources/hudson/plugins/mercurial/browser/KilnHG/help-url.html (revision 0) @@ -0,0 +1,3 @@ +
+ Specify the root URL serving this repository (such as this.) +
\ No newline at end of file