mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-07-08 11:21:50 +02:00
#970 added option to enable the experimental httppostargs protocol of mercurial
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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+
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user