Stop modifying and reusing the global JavaHg RepositoryConfiguration singleton

I can't point to a specific error, but modifying a singleton and reusing it is
a good way to get unexpected state.  The extension adding won't collect
additional state (it's add-if-not-present), but the underlying
`java.util.HashMap` isn't threadsafe.  Any differences in the environment map
when this is called would alter that state of anything else that still held a
configuration (and it also uses `HashMap`), and the pending changeset, encoding,
and HgBin settings would be overwritten for everybody outright.

There's only a default constructor for this class, so nothing to pass along in
the constructor.  I don't *think* this was the cause of the random auth failures
mentioned in the previous commit, but it's easy to avoid these potential
problems.
This commit is contained in:
Matt Harbison
2025-01-31 15:30:29 -05:00
parent 499f949c25
commit 0fa7ddfb9d

View File

@@ -59,7 +59,7 @@ public class HgRepositoryFactory {
HgConfig config = configResolver.resolve(repository);
File directory = config.getDirectory();
RepositoryConfiguration repoConfiguration = RepositoryConfiguration.DEFAULT;
RepositoryConfiguration repoConfiguration = new RepositoryConfiguration();
repoConfiguration.setHgrcPath(null);
repoConfiguration.getEnvironment().putAll(environment);
repoConfiguration.addExtension(HgFileviewExtension.class);