Skip to content

Commit

Permalink
Fix broken mercurial http post args configuration (#1532)
Browse files Browse the repository at this point in the history
Fixes a regression which was introduced with #1416. In #1416 we have reimplemented the way configuration is passed to the mercurial cgi handler. Before #1416 we used environment variables which are picked up by hgweb.py, after #1416 we pass mercurial configurations as command line parameters directly in the HgCGIServlet. But sadly the configuration option for httppostargs uses still an environment variable, which is not picked up by anyone.

See #1525
  • Loading branch information
sdorra committed Feb 9, 2021
1 parent e6f237e commit 7c50fd9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 2 additions & 0 deletions gradle/changelog/fix_hg_httppostargs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- type: fixed
description: Fix broken mercurial http post args configuration ([#1532](https://github.com/scm-manager/scm-manager/issues/1532))
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ public class DefaultHgEnvironmentBuilder implements HgEnvironmentBuilder {
@VisibleForTesting
static final String ENV_REPOSITORY_ID = "SCM_REPOSITORY_ID";
@VisibleForTesting
static final String ENV_HTTP_POST_ARGS = "SCM_HTTP_POST_ARGS";
@VisibleForTesting
static final String ENV_TRANSACTION_ID = "SCM_TRANSACTION_ID";

private final AccessTokenBuilderFactory accessTokenBuilderFactory;
Expand Down Expand Up @@ -103,10 +101,6 @@ private void read(ImmutableMap.Builder<String, String> env, Repository repositor
env.put(ENV_REPOSITORY_NAME, repository.getNamespace() + "/" + repository.getName());
env.put(ENV_REPOSITORY_ID, repository.getId());
env.put(ENV_REPOSITORY_PATH, directory.getAbsolutePath());

// enable experimental httppostargs protocol of mercurial
// Issue 970: https://goo.gl/poascp
env.put(ENV_HTTP_POST_ARGS, String.valueOf(config.isEnableHttpPostArgs()));
}

private void write(ImmutableMap.Builder<String, String> env) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@ private void process(HttpServletRequest request,

File directory = handler.getDirectory(repository.getId());
executor.setWorkDirectory(directory);
executor.setArgs(createArgs());

HgConfig config = handler.getConfig();
executor.setArgs(createArgs(config));
executor.execute(config.getHgBinary());
}

@Nonnull
private List<String> createArgs() {
private List<String> createArgs(HgConfig config) {
List<String> args = new ArrayList<>();
config(args, "extensions.cgiserve", extension.getAbsolutePath());

Expand All @@ -161,6 +161,11 @@ private List<String> createArgs() {
config(args, "web.push_ssl", "false");
config(args, "web.allow_read", "*");
config(args, "web.allow_push", "*");

// enable experimental httppostargs protocol of mercurial
// Issue 970: https://goo.gl/poascp
config(args, "experimental.httppostargs", String.valueOf(config.isEnableHttpPostArgs()));

args.add("cgiserve");
return args;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ private void assertReadEnv(Map<String, String> env, String repositoryId) {
assertThat(env)
.containsEntry(ENV_REPOSITORY_ID, repositoryId)
.containsEntry(ENV_REPOSITORY_NAME, "hitchhiker/HeartOfGold")
.containsEntry(ENV_HTTP_POST_ARGS, "false")
.containsEntry(ENV_REPOSITORY_PATH, directory.resolve("repo").toAbsolutePath().toString());
}

Expand Down

0 comments on commit 7c50fd9

Please sign in to comment.