-
Notifications
You must be signed in to change notification settings - Fork 261
feat(diff): add support for mercurial #1878
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
base: main
Are you sure you want to change the base?
Conversation
the final idea is to add support for `mercurial`, that has a similar structure to git's. Parameterizing these functions makes the addition of mercurial trivial. The patch renames those functions as `s/git_/dvcs_/` to reflect their more generic nature.
so that next time we try to use `dvcs_cache`, we can start from scratch. This is important when other `gen_sources` are using `dvcs_cache` as well.
This reverts commit 0270aa8.
I think you mean that I could implement my own source in my Instead, this patch parameterize the three things that are different between Git and Mercurial and then makes it trivial to implement the mercurial side. All we need to implement the mercurial diff is: local watch_index_opts = {
command = 'hg',
dvcs_dir_cmd_args = { 'root', '--template', '{reporoot}/.hg' },
index_name = 'dirstate',
dvcs_file_test_spawn_args_fn = function(local_path)
local basename = vim.fn.fnamemodify(local_path, ':t')
return { 'cat', basename }
end
}
H.dvcs_start_watching_index(buf_id, path, watch_index_opts) We can now reuse the code to diff with Git which is well tested. The patch looks large because there are a lot of renaming to reflect the fact that some things are more generic now and also because I formatted the file with |
Thanks for the PR! Adding built-in support for Mercurial, Jujutsu, and maybe Fossil is indeed planned. The problem here is that I don't use any of these, but I would like to be able to personally verify that the solution works. It requires some time investment from my side to understand how they work and how to test them. So at least a set of commands that are verified from the actual user of the VCS is highly appreciated! As for the PR, I don't really agree with several refactoring choices, in particular naming (I'd prefer Formatting of the project is done with 'StyLua' (which is both documented and could be inferred from the fact that affected lines are mostly the ones that have Also, before making a PR, please create an issue/discussion about adding particular functionality, so that we can discuss it first. This usually saves time of both parties. What I'd suggest is the best approach going forward is to ask you (as evidently a Mercurial user) to help me with a testing setup (like, a set of commands to initiate a testing repo) and a set of commands for basic actions:
My understanding from the PR is the following:
|
in particular, this patch fixes: 1. `s/watch_index_opts/opts/` 2. `s/dvcs/vcs/` 3. `s/hg/mercurial/` 4. Format with `stylua`
Thank you for taking a look.
I'm happy to help.
I made the changes you mentioned here. Let me know if I need to change anything else.
Code formatted with
Sounds good for next time.
To create a fresh repository, similar to git, you would do As for what's necessary to monitor the repository, the commands you wrote are the ones I identified to monitor the mercurial repository. Those are the ones I'm using in the patch.
What do you mean by thise? |
By the way, looking at Jujutsu structure, it seems like we can use the structure that I put in place with the following parameters:
This was a 5 minutes search, so take it with a grain of salt. But it looks possible. |
The source (if possible and makes sense) should also supply |
As far as I know, staging pieces of the patch in an index before creating a commit is something pretty unique to Git. In mercurial, you are able to commit pieces of the outstanding changes with For jujutsu, we can discuss it in more detail when we implement that. But, IIRC, jujutsu takes any opportunity it has (every time |
That's a shame. I'll need to do more research then to see the best way to utilize |
Mercurial follows a very similar patter to Git: (1) It has an index pointing to the latest changes in the repo (
dirstate
) and (2) we are able tocat
the file content of files in the repository.This patch does
threetwo things:Formatdiff.lua
withlua_ls
. If this is not ok, I can add a revert of it.index
, command to find the repo directory, and command to get files in the repo. Methods are renameds/git_/dvcs_/
to make it clear that they are more generic now.