helix icon indicating copy to clipboard operation
helix copied to clipboard

feat: Add Jujutsu diff handling to Helix

Open poliorcetics opened this issue 1 year ago • 5 comments

Jujutsu (jj) is a new change-based VCS (whereas git is branch-based).

In this PR, I add the ability for helix to get the diffs and current head, behind a feature called jujutsu that is active by default. That makes it the first editor I know off that handles such that VCS!

To handle all current, future and private backends (Google already has one I believe), I instead made it so Helix can behave as a diff tool for Jujutsu and then use that as a subcommand to get the diff base.

For the head, I simply used the templating system to extract all relevant informations.

Jujutsu has a library, called jj-lib but it's not ready for use in third party programs and wouldn't fix the issue of custom backends anyway.

Testing

Since testing needs jj installed, I haven't written any for Helix yet to discuss how to do it:

  1. Ignore the issue. I don't like it much, but it doesn't cost CI time and doesn't need any change. For a feature that probably won't be used much yet, that's probably ok for a time
  2. Install jj in CI and use it to test the new feature

poliorcetics avatar Feb 16 '24 16:02 poliorcetics

would be cool to automatically run some jj command every save, so jj records the working copy. then we can run jj undo to revert a save

maan2003 avatar Feb 29 '24 09:02 maan2003

I like the idea, but probably for another MR ? It's more involved and would need some configuration changes to ensure people not using jj are not paying the cost on each save

A more general "run X on save" could be very nice.


Note: jj already supports watchman (https://martinvonz.github.io/jj/v0.14.0/config/#watchman), you can use that instead for now

poliorcetics avatar Feb 29 '24 09:02 poliorcetics

Am I right in understanding this lets us navigate between changes in jj repositories that aren't colocated with a Git repository

ocharles avatar Feb 29 '24 10:02 ocharles

It would be nice if the Jujutsu provider was tried before Git, so that it was used instead of Git when using a colocated repository. Right now, I find the Jujutsu provider is only used for non-colocated repos.

mjm avatar Jul 17 '24 15:07 mjm

It would be nice if the Jujutsu provider was tried before Git, so that it was used instead of Git when using a colocated repository. Right now, I find the Jujutsu provider is only used for non-colocated repos.

IMO no, at least no by default, the idea being people not using JJ shouldn't be paying the cost for it on each opened file.

I have https://github.com/helix-editor/helix/pull/9951 open instead and the plan is to make the diff source discovery order configurable, so that people using JJ can put it first without impacting anyone else :)

poliorcetics avatar Jul 21 '24 11:07 poliorcetics