zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH 1/2] _hg: use revsets for suggestions for hg merge
@ 2018-08-29  0:17 Anton Shestakov
  2018-08-29  0:17 ` [PATCH 2/2] _hg: check for both -r and --rev Anton Shestakov
  0 siblings, 1 reply; 2+ messages in thread
From: Anton Shestakov @ 2018-08-29  0:17 UTC (permalink / raw)
  To: zsh-workers; +Cc: Anton Shestakov

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 2/2] _hg: check for both -r and --rev
  2018-08-29  0:17 [PATCH 1/2] _hg: use revsets for suggestions for hg merge Anton Shestakov
@ 2018-08-29  0:17 ` Anton Shestakov
  0 siblings, 0 replies; 2+ messages in thread
From: Anton Shestakov @ 2018-08-29  0:17 UTC (permalink / raw)
  To: zsh-workers; +Cc: Anton Shestakov

---
 Completion/Unix/Command/_hg | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Completion/Unix/Command/_hg b/Completion/Unix/Command/_hg
index d92112e68..7b72605b3 100644
--- a/Completion/Unix/Command/_hg
+++ b/Completion/Unix/Command/_hg
@@ -567,7 +567,7 @@ _hg_cmd_diff() {
 
   if [[ $state == 'diff_files' ]]
   then
-    if [[ -n $opt_args[-r] ]]
+    if [[ -n ${opt_args[(I)-r|--rev]} ]]
     then
       _hg_files && ret=0
     else
@@ -795,7 +795,7 @@ _hg_cmd_revert() {
 
   if [[ $state == 'diff_files' ]]
   then
-    if [[ -n $opt_args[-r] ]]
+    if [[ -n ${opt_args[(I)-r|--rev]} ]]
     then
       _hg_files && ret=0
     else
-- 
2.11.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-08-29  0:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-29  0:17 [PATCH 1/2] _hg: use revsets for suggestions for hg merge Anton Shestakov
2018-08-29  0:17 ` [PATCH 2/2] _hg: check for both -r and --rev Anton Shestakov

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).