Skip to content

Make Mercurial command configurable by an environment variable #1144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

manueljacob
Copy link
Contributor

No description provided.

This makes it consistent with the other invocations in this file and makes it easier to parametrize the Mercurial command in the future.
@manueljacob
Copy link
Contributor Author

Of course, I’m not quite happy with reloading the modules in the test. But it allows the non-test code to stay simple. Another possibility would be to monkey-patch the module-level constants, but I prefer testing the code like it is used by the user (who sets the environment variable) instead of depending on implementation details.

@manueljacob manueljacob force-pushed the hg_command branch 2 times, most recently from 881801b to 0c7a203 Compare June 11, 2025 23:57
@RonnyPfannschmidt
Copy link
Contributor

Why is it necessary to set a different hg command?

I need a surrounding context

@manueljacob manueljacob force-pushed the hg_command branch 2 times, most recently from 8b26570 to 02472ab Compare June 12, 2025 09:51
@manueljacob
Copy link
Contributor Author

See the commit messages.

I’ll usually put motivations and other long explanations in the commit message for long-term record. If the pull request contains more than one commit, GitHub won’t automatically copy the commit message to the pull request description.

@RonnyPfannschmidt
Copy link
Contributor

Let's add a changelog entry for this and a example in the docs so users can quickly grasp it

@manueljacob
Copy link
Contributor Author

Okay, I will push a changelog entry. BTW, it was not obvious to me what the format of changelog entries in changelog.d is, until I happened to come across the changelog entry “introduce scriv for changelog management”.

What would be a good example for the docs? I think developing Mercurial extensions is a bit too specific, so I guess it should be using chg to speed things up?

@RonnyPfannschmidt
Copy link
Contributor

In case of doubt ignore scriv i messed up correctly using it the last few releases

I'll need a release prep bot to get that out of the door correctly

@manueljacob
Copy link
Contributor Author

I'll need a release prep bot to get that out of the door correctly

You automated package version generation. Shouldn’t be too hard? ;)

@RonnyPfannschmidt
Copy link
Contributor

With github actions its a pain in the neck

Like multiple 3rd party actions due to platform shortcomings

At least its not gitlab

@manueljacob
Copy link
Contributor Author

What would be a good example for the docs? I think developing Mercurial extensions is a bit too specific, so I guess it should be using chg to speed things up?

@RonnyPfannschmidt Any opinion on the example? Otherwise, I’ll go ahead with the chg one.

@RonnyPfannschmidt
Copy link
Contributor

Chg is probably the best example

Hevk it may make sense to use it as default if avaliable (with development caveats)

This is useful when e.g. developing Mercurial or Mercurial extensions. Previously, the first ``hg`` binary in PATH was used. If the Mercurial in the current virtual environment was broken, it was impossible to install anything that uses setuptools-scm to determine a version from Mercurial. With this change, it is possible to set the SETUPTOOLS_SCM_HG_COMMAND environment variable to the standard system-wide Mercurial executable.

Also, it makes it possible to make setuptools-scm use chg, a variant of Mercurial that uses a daemon to save start-up overhead. Using it, the time of running ``uv pip install`` of a small-to-medium-size package decreased from 8.826s to 2.965s (a 3x reduction).

If the environment variable is not set, the behavior remains unchanged.
@manueljacob
Copy link
Contributor Author

I pushed the updated documentation, adding a short motivation.

We can separately discuss using chg by default.

Copy link
Contributor

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@@ -11,6 +11,7 @@
from ._run_cmd import CompletedProcess as _CompletedProcess
from ._run_cmd import run as _run
from .git import GitWorkdir
from .hg import HG_COMMAND
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's turn this into a module import to ease test instrumentation

hg_exe: str,
) -> None:
wd = repositories_hg_git[0]
with monkeypatch.context() as m:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of reloading rhe modules lets turn the logic into a function the test can call

@RonnyPfannschmidt
Copy link
Contributor

I plan to merge Monday as I'm mid travel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants