-
-
Notifications
You must be signed in to change notification settings - Fork 983
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
Mercurial support? #313
Comments
Unfortunately Pure does not support mercurial. I personally don't use mercurial at all, nor do I have enough knowledge about it to implement it in Pure. One thing you could try is: autoload -Uz promptinit; promptinit
prompt pure
zstyle ':vcs_info:*' enable git hg
zstyle ':vcs_info:hg*' check-for-changes true
zstyle ':vcs_info:hg*' stagedstr '*'
zstyle ':vcs_info:hg*' unstagedstr '*'
zstyle ':vcs_info:hg*' formats '%b%c%u' '%R'
zstyle ':vcs_info:hg*' actionformats '%b|%a%c%u' '%R' I'm uncertain if this will work, but it should show you branch name and dirty status. Here Generally Pure doesn't rely on vcs_info much and for dirty, fetch, and arrows Pure calls All this being said, I would not be opposed to supporting mercurial in Pure, given a well thought-out PR that takes performance into consideration. |
PS. For more information about |
Your solution shows the branch name (without space, directly next to directory name) but no dirty status. Oh well, thanks anyway. |
Too bad =/, I hadn't actually tested this, just wrote it down based on documentation. I believe if you play around with the I'll keep your request for mercurial support in mind for the future. |
OK, I've got basic Mercurial support over on my fork with async dirty checking. Will try figuring out the incoming/outgoing stuff later. I know next to nothing about shell scripting so it's tough-going. |
Awesome! One tip, you can use zstyle ':vcs_info:*' max-exports 3
zstyle ':vcs_info:*' formats ' %b' 'x%R' '%s' This will insert either Let me know if you need any help and feel free to open up a PR when you feel it's a good time to discuss it further! |
Thanks @mafredri. I have some question about this
In Mercurial, you can use I'm trying to decide if I should throttle the "hg incoming" check or not, and whether or not I should automatically pull changes. I feel like I shouldn't pull the changes, just check if they exist. Pulling won't mess with your working directory, but it does modify your local copy repo. The other thing I'm trying to figure out is what a down arrow should mean:
Thoughts? |
Yay, this is the kind of Mercurial know-how that's needed to implement this in Pure, glad you're putting in the effort @mnpenner!
I don't see any reason to implement nr. 3 for mercurial unless it becomes a problem (and even then I'm planning on removing the feature in favor of disabling the VCS features on a per-folder basis).
Mercurial seems a bit more flexible than Git in this regard. The reason Pure issues But personally I'm a big fan of Pure automatically fetching in the background, and that's partly because e.g. issuing
I'd say no to throttling, but maybe to pulling changes (I like it for Git). I'll trust your Mercurial expertise on this though, as I don't know what the benefits / downsides are. As a general rule though, if pulling speeds up checking for remote changes, then that might be preferable.
To match Git behaviour, it should be limited to the current branch (1). With regards to (3), I assume multiple heads in this instance means your local head and the remote head? In that case, Pure would show both (down/up) arrows simultaneously (for Git). Did that answer all the open questions? If not, feel free to ask some more =)! |
No, you can have multiple local heads. These are usually caused by someone else pushing a commit to the branch you're working on, but not necessarily. If you 'update' back one revision, for example, make some changes and then commit again you will created an 'unnamed branch' which is effectively two heads on the same 'named branch'. You can create as many heads/unnamed branches as you want (where a "head" is just the latest changeset on a branch). If you try to push, and pushing will create a new head/branch then Mercurial warns you that you should merge first so as to not create another head. However, you can
I think I agree. I don't see any downsides of
I think Git and Hg differ a bit here. By "incoming" I mean there are changesets that were pushed to the remote repo that you have not yet
Let's say you're working on a named (feature) branch. You commit and push rev 100, then make some more changes and push rev 101. Then your co-worker pulls your changes, updates to the then-latest rev 101, fixes some bugs, and pushes 102. Meanwhile, you're still working away. When you're done, you commit rev 103. Now when you try to push, hg is going to complain that this will create a new head, and you should merge first. If you do so, it will look like this:
i.e., "104" will be a merge changeset. After you merge, you can commit and push without warnings. But let's take a step back to before 104 was created. If we In this scenario, I reckon a down arrow should appear because there's a changeset waiting to merged in, but a down arrow is a little misleading -- here it doesn't mean that you need to download anything, nor does it mean that you're down/behind the remote -- you've simply diverged. Lastly, what if you created both 102 and 103 for some reason? Maybe you made a bunch of changes and committed, but then realized that code was no good, so you updated back to 101 and decided to try again from a clean slate? In Mercurial, you generally can't erase history after you've pushed, so if 102 was bad, what you would do instead and 'close' that [unnamed] branch. If a branch is closed, Mercurial won't ask you to merge it in. So really, I don't think a down arrow makes sense to mean anything other than "there are new remote changesets that you haven't downloaded yet". This is complimentary to what the up arrow means. However, if we're always pulling, then the down arrow isn't needed at all. Thus, I think what I should do instead is display number of [unclosed] heads on the current branch if there's more than one. This is a really useful thing to know because generally you want to merge those changes in as quickly as possible otherwise you will have lots of conflicts later. What do you think? Should I display the number of heads, plus an up arrow if there are unpushed commits? Or I could display the number of unpushed commits too. Or we could choose a different 'icon' to mean 2+ heads and not display the number (it's more important know that there are unmerged heads than to know how many there are -- more than two has been pretty rare in my experience, but maybe not with larger teams). |
Thanks for the thorough explanation, it was insightful. After a bit of consideration, it seems to me that hg and git behavior is quite similar in many ways, for the exception that mercurial supports multiple heads for a branch. From what I can gather, the down arrow for both git and mercurial could be nearly the same thing.
The biggest difference as I see it, is that diverging in git means you must either merge, rebase (apply your commits onto remote) or reset (delete your local commits) your branch to be able to push new changes to the remote (alternatively overwriting the remote with --force). There cannot be multiple heads as with mercurial. With this in mind, I see the down arrow more as "there are new changes not yet in this branch". Applying this thinking to mercurial, do you think it would make sense to keep it as an indicator of unmerged changes, considering we are already downloading those changes from the remote? Of course, it would be great if what pure displays could feel intuitive to a mercurial user, at least after a short hint in the readme. Personally I would love to simply keep the up/down arrows around and not introduce new concepts. Then again concepts between git/hg don't align 1:1. I also feel numbers are a distraction (and away from simplicity) but while they are not useful for git, maybe they give valuable information for mercurial users, idk. |
I'm not really sure what other prompts are doing for Mercurial, so I can't really say what would be intuitive to Hg users. The few that I've found don't display up or down arrows. A quick poll from my co-workers: they think the down arrow means "gotta get down on Friday" or "all below" (really helpful guys!) Of the two serious answers I got, they thought it meant they should pull, which is what I would think too. I don't mind using a down arrow to mean "you should merge" but I think it will cause confusion. I suspect people will try pulling a few times and wonder why the arrow isn't going away. Unfortunately, I do think we need to introduce something new to represent this idea. Historically, I usually wouldn't know there's another head until I try to push and Mercurial yells at me. Knowing beforehand would definitely be a nice perk, but it's not something I've seen before. Suggestions for other icons: ⤩ ⛙ ↯ ⥈ ⇊☺☻ |
Thanks for doing a poll, it's definitely helpful to know what others think. Ultimately I think you're right. Git get's away with the down arrow because The biggest question mark is what indication to use, in my opinion there aren't many good icons / arrows to indicate this. Here's what I came up with: PS. I merged quite a big change into Pure today, 4cdd0cf. I hope this does not discourage you from working on your fork! If you wish to continue working on your current fork without rebasing / merging, I'd be happy to help port it over once it's ready. |
When I finish it up I'll attempt to merge in your changes, if it doesn't work out I might ask for help 😄 Thanks. One more consideration: if you're sitting on a branch, in a clean state (no modified files, and no unpushed changes), and someone pushes a change to your branch, then you will be behind, but there won't be an additional head. This is different from the scenario I outlined above because it means you should Another possible one for merge if you want to stick with arrows: |
Sorry to revive an old issue but I'm finding myself in need of Mercurial support for Pure. (I'm something of a beginner so this thread has been extraordinarily helpful - thanks!) @mnpenner - is this something you're still interested in doing? Can I be of assistance? I work with fairly massive git and hg repositories - Pure's async has been a lifesaver - so I'm happy to do anything I can to get clean, performant, hg support into Pure. (Fwiw an informal poll of folks around me claim |
Hey @abl, I haven't been able to work on this lately. I've been using the prompt on my fork for a few months now, but it still just has incoming and dirty flags. Even just that has been better than the other prompts out there. If you would like to take over, that would be fantastic! I think mafredri said he made some big changes since I started my fork. I'd start by merging that in; hopefully it's not too painful. |
Yep I'd agree!
Sounds good. |
Merged in https://github.com/abl/pure - I've got some testing to do and will propose a PR when ready but feedback is always appreciated. :) |
@abl Tried with zplug abl/pure, use:pure.zsh, from:github, as:theme Got parse error:
Let me know when it's patched up and I'll give it another whirl. |
Resolved! The merge loads but doesn't work - I'll do a proper three-way reading and refactoring next week. |
I've been tinkering with it in my spare time but mostly I've been blocked; |
Cool, happy to know this is still being worked on. Feel free to write here if you want to throw around ideas, I'd be happy to help where I can. I'm curious what performance issues there are without |
It's probably an artifact of the repos I'm using (and the necessary plugins including NarrowHG) but individual status commands can take 2-3 seconds to execute. I'm trying to come up with a solution that works as well as Pure's Git support does but at the moment I've got a small cluster of plugins and Google-specific code; compounding everything is that I still don't have a great feel for how to translate Mercurial concepts to Git concepts. :) |
Any updates on this? I would be willing to help if no one is working on it. |
I think this would be better implemented as a plugin after #460 is done. Mercurial is not that common and it's not something I would want to maintain here. |
Closing in favor of #460. |
General information
I have:
Problem description
Any chance of adding Mercurial support? I would like the same indicators that you have for Git. i.e., I want to know what branch I'm currently on, when the repo is dirty, and ideally when there is incoming or outgoing changesets.
Reproduction steps
cd
into a Mercurial repo (with.hg
directory in it)My
.zshrc
:The text was updated successfully, but these errors were encountered: