zsh-workers
 help / color / mirror / code / Atom feed
From: Anton Shestakov <av6@dwimlabs.net>
To: zsh-workers@zsh.org
Cc: Anton Shestakov <av6@dwimlabs.net>
Subject: [PATCH 1/2] _hg: use revsets for suggestions for hg merge
Date: Wed, 29 Aug 2018 08:17:30 +0800	[thread overview]
Message-ID: <20180829001731.1856-1-av6@dwimlabs.net> (raw)

Using Mercurial's functional language for selecting a set of revisions
allows getting all heads minus current revision using just one call to
hg. The difference in responsiveness is definitely noticeable,
especially on larger repos. Sorting by revision (descending) is done
just to have the same ordering as hg heads, until someone figures out a
better one.
---
 Completion/Unix/Command/_hg | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/Completion/Unix/Command/_hg b/Completion/Unix/Command/_hg
index 4b88ce4ea..d92112e68 100644
--- a/Completion/Unix/Command/_hg
+++ b/Completion/Unix/Command/_hg
@@ -192,13 +192,9 @@ _hg_tags() {
 # likely merge candidates
 _hg_mergerevs() {
   typeset -a heads
-  local myrev
-
-  heads=(${(f)"$(_hg_cmd heads --template '{rev}\\n')"})
-  # exclude own revision
-  myrev=$(_hg_cmd log -r . --template '{rev}\\n')
-  heads=(${heads:#$myrev})
+  local revset='sort(head() and not ., -rev)'
 
+  heads=(${(f)"$(_hg_cmd log -r '$revset' --template '{rev}\\n')"})
   (( $#heads )) && _describe -t heads 'heads' heads
 }
 
-- 
2.11.0


             reply	other threads:[~2018-08-29  0:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-29  0:17 Anton Shestakov [this message]
2018-08-29  0:17 ` [PATCH 2/2] _hg: check for both -r and --rev Anton Shestakov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180829001731.1856-1-av6@dwimlabs.net \
    --to=av6@dwimlabs.net \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).