fixes python module path detection

This commit is contained in:
Sebastian Sdorra
2020-07-01 15:28:37 +02:00
parent 17d31b80e0
commit 2bb865bf5c
3 changed files with 15 additions and 3 deletions

View File

@@ -123,7 +123,9 @@ public class UnixAutoConfigurator implements AutoConfigurator {
int end = line.indexOf(")");
Path modulePath = Paths.get(line.substring(start + 1, end));
if (Files.exists(modulePath)) {
return Optional.of(modulePath);
// installed modules contains the path to the mercurial module,
// but we need the parent for the python path
return Optional.of(modulePath.getParent());
} else {
LOG.warn("could not find module path at {}", modulePath);
}

View File

@@ -143,7 +143,14 @@ public class HgRepositoryHandler
if (autoConfigurator.isPresent()) {
config = autoConfigurator.get().configure();
}
doAutoConfiguration(config != null ? config : new HgConfig());
if (config != null && config.isValid()) {
this.config = config;
storeConfig();
} else {
// do the old configuration
doAutoConfiguration(config != null ? config : new HgConfig());
}
}
}

View File

@@ -144,12 +144,15 @@ class UnixAutoConfiguratorTest {
Path modules = directory.resolve("modules");
Files.createDirectories(modules);
Path mercurialModule = modules.resolve("mercurial");
Files.createDirectories(mercurialModule);
UnixAutoConfigurator configurator = create(directory);
configurator.setExecutor((Path binary, String... args) -> {
String content = String.join("\n",
"checking Python executable (/python3.8)",
"checking Python lib (/python3.8)...",
"checking installed modules (" + modules.toString() + ")...",
"checking installed modules (" + mercurialModule.toString() + ")...",
"checking templates (/mercurial/templates)...",
"checking default template (/mercurial/templates/map-cmdline.default))"
);