Skip to content
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

Speed up the mercurial plugin for large repositories #4399

Closed
wants to merge 2 commits into from

Conversation

scottrice
Copy link

In very large repositories, certain hg commands can take a very long time. Two of those used in the mercurial plugin are particularly bad - hg status and hg summary. I removed the hg summary call by replacing it with hg root, which gives us similar information much faster.

hg status was a different beast, and since there is no "faster" replacement I ended up just mirroring the functionality of the git plugin. If you're unfamiliar, the git plugin simply shows the clean prompt if a certain config flag is set (oh-my-zsh.hide-dirty). This approach has multiple benefits, the most important being that you can configure it per-repository.

Finally, the multiple in_hg calls ended up calling hg root a lot. These were not super long calls on their own, but when we do it often we end up spending quite a bit of time calculating an answer we already know. To fix this I saved it in a local variable at the beginning of the hg_prompt_info call and remove it at the end.

…he git plugin

In some very large repositories, `hg status` can take a pretty long time. It doesn't feel great to have a multi second delay every time you run a command while you wait for hg status to complete.

Mirroring the functionality in the git plugin, this diff adds a check for a new configuration option in `hg config`. If this option is enabled we disable the `hg status` check and just show the clean marker.
…pers

The helper functions are smart only work if the user is in an hg repository. Unfortunately checking that fact can take a while for large repos, so these redundant checks are taking a while. This diff stores the result of the first call from `hg_prompt_info` in a local variable and just checks that for every other function.

This gave me a multi-second speedup locally.
@scottrice
Copy link
Author

Ping. Any chance of this going in? I've been using it locally for a while, but I'd like to bring my local checkout back in line with oh-my-zsh master.

@mcornella mcornella added the Area: plugin Issue or PR related to a plugin label Mar 24, 2019
@mcornella mcornella closed this Dec 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: plugin Issue or PR related to a plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants