-
-
Notifications
You must be signed in to change notification settings - Fork 175
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
Legit closify remove global vcs #1538
Merged
vindarel
merged 50 commits into
lem-project:main
from
vindarel:legit-closify-remove-global-vcs
Sep 24, 2024
Merged
Legit closify remove global vcs #1538
vindarel
merged 50 commits into
lem-project:main
from
vindarel:legit-closify-remove-global-vcs
Sep 24, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Yes, Emacs makes extensive use of dynamic bindings/scope: that's not a reason we should do the same. Common Lisp supports lexical scoping, unlike Elisp when it started out, and in my opinion we should really, *really*, try to avoid dynamic binds where a function parameter would do. Yes, this adds the need to plumb an extra parameter around. That's well worth the cost: we can always package/split function parameters as needed and as they make sense, whereas dynamic bindings may prove to be a *huge* pain point in the future if Lem starts making use of paralellism. The Emacs documentation itself puts it succinctly [1] > Lexical binding opens up many more opportunities for optimization, > so programs using it are likely to run faster in future Emacs versions. > Lexical binding is also more compatible with concurrency, Now, focusing on Legit itself: much of the in lem/porcelain uses the pattern ``` (defun some-legit-function (vcs) (case vcs (:git (git-fn)) (:hg (hg-fn)) (:t (fallthrough)))) ``` There's no reason to have all of this dispatch logic done manually: this is a textbook case for using generic functions. Now, the thing is that generic functions need something to dispatch *on*. And it's pretty clear that the VCS parameter (representing, really, the repository [2]) is the perfect thing for that. By switching all the `legit-function`s to be generic functions, the implementation for each VCS can also define their `vcs` objects to contain whatever data they might find useful: whether that's some sort of legit-side cache for commits, FFI handles (will be useful for libgit2 support for instance), etc. [1] https://www.gnu.org/software/emacs/manual/html_node/elisp/Lexical-Binding.html [2] Might be worth a rename, but I don't want to clutter this particular change.
It doesn't do anything: the one place it's actually called, we know that we're in a git project already. The equivalent hg and fossil callsites actually call the bespoke functions directly
The variable is unused, according to grep
The system is loaded by default now.
More flexible
Also, update some of the :documentation for the porcelain functions
the failed CI is
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Legit's code base is now a little OO and the VCS logic is split into their own files.
The goal that is now achieved without bugs is that we can have more than 1 interactive rebase in process, without re-inventing an OO with too many global variables and manual dispatch.
I tested the best I can, specialy the interactive rebase, for git and other VCSs (which must show a message, not fail).
replaces #1451