#970 added option to enable the experimental httppostargs protocol of mercurial

This commit is contained in:
Sebastian Sdorra
2018-03-29 22:14:28 +02:00
parent 8aaa67cd6a
commit a34acd8ed4
4 changed files with 45 additions and 11 deletions

View File

@@ -127,6 +127,10 @@ public class HgConfig extends SimpleRepositoryConfig
return disableHookSSLValidation;
}
public boolean isEnableHttpPostArgs() {
return enableHttpPostArgs;
}
/**
* Method description
*
@@ -197,6 +201,10 @@ public class HgConfig extends SimpleRepositoryConfig
this.showRevisionInId = showRevisionInId;
}
public void setEnableHttpPostArgs(boolean enableHttpPostArgs) {
this.enableHttpPostArgs = enableHttpPostArgs;
}
/**
* Method description
*
@@ -232,6 +240,8 @@ public class HgConfig extends SimpleRepositoryConfig
/** Field description */
private boolean showRevisionInId = false;
private boolean enableHttpPostArgs = false;
/**
* disable validation of ssl certificates for mercurial hook
* @see <a href="https://goo.gl/zH5eY8">Issue 959</a>

View File

@@ -87,6 +87,8 @@ public class HgCGIServlet extends HttpServlet
/** Field description */
public static final String ENV_REPOSITORY_PATH = "SCM_REPOSITORY_PATH";
private static final String ENV_HTTP_POST_ARGS = "SCM_HTTP_POST_ARGS";
/** Field description */
public static final String ENV_SESSION_PREFIX = "SCM_";
@@ -278,11 +280,15 @@ public class HgCGIServlet extends HttpServlet
environment.put(ENV_PYTHON_HTTPS_VERIFY, "0");
}
// enable experimental httppostargs protocol of mercurial
// Issue 970: https://goo.gl/poascp
environment.put(ENV_HTTP_POST_ARGS, String.valueOf(handler.getConfig().isEnableHttpPostArgs()));
//J-
HgEnvironment.prepareEnvironment(
environment,
handler,
hookManager,
hookManager,
request
);
//J+

View File

@@ -48,6 +48,7 @@ Sonia.hg.ConfigPanel = Ext.extend(Sonia.config.ConfigForm, {
showRevisionInIdText: 'Show Revision',
// TODO: i18n
disableHookSSLValidationText: 'Disable SSL Validation on Hooks',
enableHttpPostArgsText: 'Enable HttpPostArgs Protocol',
// helpText
hgBinaryHelpText: 'Location of Mercurial binary.',
@@ -63,6 +64,8 @@ Sonia.hg.ConfigPanel = Ext.extend(Sonia.config.ConfigForm, {
// TODO: i18n
disableHookSSLValidationHelpText: 'Disables the validation of ssl certificates for the mercurial hook, which forwards the repository changes back to scm-manager. \n\
This option should only be used, if SCM-Manager uses a self signed certificate.',
// TODO explain it
enableHttpPostArgsHelpText: 'Enables the experimental HttpPostArgs Protocol.',
initComponent: function(){
@@ -115,12 +118,18 @@ Sonia.hg.ConfigPanel = Ext.extend(Sonia.config.ConfigForm, {
fieldLabel: this.disableHookSSLValidationText,
inputValue: 'true',
helpText: this.disableHookSSLValidationHelpText
},{
xtype: 'checkbox',
name: 'enableHttpPostArgs',
fieldLabel: this.enableHttpPostArgsText,
inputValue: 'true',
helpText: this.enableHttpPostArgsHelpText
},{
xtype: 'checkbox',
name: 'disabled',
fieldLabel: this.disabledText,
inputValue: 'true',
helpText: this.disabledHelpText
helpText: this.disabledHelpText
},{
xtype: 'button',
text: this.configWizardText,
@@ -260,11 +269,11 @@ Sonia.repository.typeIcons['hg'] = 'resources/images/icons/16x16/mercurial.png';
// override ChangesetViewerGrid to render changeset id's with revisions
Ext.override(Sonia.repository.ChangesetViewerGrid, {
isMercurialRepository: function(){
return this.repository.type === 'hg';
},
getChangesetId: function(id, record){
if ( this.isMercurialRepository() ){
var rev = Sonia.util.getProperty(record.get('properties'), 'hg.rev');
@@ -274,7 +283,7 @@ Ext.override(Sonia.repository.ChangesetViewerGrid, {
}
return id;
},
getParentIds: function(id, record){
var parents = record.get('parents');
if ( this.isMercurialRepository() ){
@@ -285,7 +294,7 @@ Ext.override(Sonia.repository.ChangesetViewerGrid, {
parents[0] = rev + ':' + parents[0];
}
if ( parents.length > 1 ){
rev = Sonia.util.getProperty(properties, 'hg.p2.rev');
rev = Sonia.util.getProperty(properties, 'hg.p2.rev');
if (rev){
parents[1] = rev + ':' + parents[1];
}
@@ -294,5 +303,5 @@ Ext.override(Sonia.repository.ChangesetViewerGrid, {
}
return parents;
}
});

View File

@@ -31,12 +31,21 @@
import os
from mercurial import demandimport
from mercurial import demandimport, ui as uimod, hg
from mercurial.hgweb import hgweb, wsgicgi
repositoryPath = os.environ['SCM_REPOSITORY_PATH']
demandimport.enable()
application = hgweb(repositoryPath)
u = uimod.ui.load()
# pass SCM_HTTP_POST_ARGS to enable experimental httppostargs protocol of mercurial
# SCM_HTTP_POST_ARGS is set by HgCGIServlet
# Issue 970: https://goo.gl/poascp
u.setconfig('experimental', 'httppostargs', os.environ['SCM_HTTP_POST_ARGS'])
# open repository
# SCM_REPOSITORY_PATH contains the repository path and is set by HgCGIServlet
r = hg.repository(u, os.environ['SCM_REPOSITORY_PATH'])
application = hgweb(r)
wsgicgi.launch(application)