One of the most important aspects of a completion system is its speed, so 1
call to hg is definitely better than 4.
Sorting by rev (descending) is to preserve the same order as in hg heads
output.
While at it, declare branches as an array too.
spectral | |
pulkit |
hg-reviewers |
One of the most important aspects of a completion system is its speed, so 1
call to hg is definitely better than 4.
Sorting by rev (descending) is to preserve the same order as in hg heads
output.
While at it, declare branches as an array too.
Lint Skipped |
Unit Tests Skipped |
Would it make sense to combine this into one hg invocation? I think it wouldn't be that hard (hmm, not as trivial as I thought, but.. not the worst thing ever? :))
allheads=(${(f)"$(_hg_cmd log -r 'sort(head(), -rev)' --template '{ifcontains(rev, revset(\".\"), \"T\", \"F\")}:{rev}:{branch}\n')"}) # Extract current revision from allheads, remove "[TF]:" prefix from each item selfentry=(${${allheads:#F*}/#T:/}) heads=(${${allheads:#T*}/#F:/}) # Remove "{rev}:" prefix from each item in heads to get just branch names branches=(${(S)heads/#*:/}) # Remove branches that match the one we're currently on selfbranch=(${(S)selfentry/#*:/}) branches=(${branches:#$selfbranch})
It probably would make sense, but you don't need to exclude current branch, because hg merge my-current-branch works when you have more than one branch head (except when you stand on the newest head, unfortunately: "abort: merging with a working directory ancestor has no effect").
Now it's only one call to hg. All possible branches included, even if hg merge that-branch would complain (see my comment above), because in completions it's better to give extra suggestions than to miss some.
But this "revision numbers + branch names" got me thinking, maybe it should also suggest hashes, since some people prefer them? Specifically, {node|shortest}, so that they don't take too much space.