Patchwork osx: install bash and zsh completions by default

login
register
mail settings
Submitter Augie Fackler
Date Feb. 27, 2017, 11:12 p.m.
Message ID <514fb53d0a35229162cf.1488237164@imladris.local>
Download mbox | patch
Permalink /patch/18817/
State Accepted
Headers show

Comments

Augie Fackler - Feb. 27, 2017, 11:12 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1486412372 18000
#      Mon Feb 06 15:19:32 2017 -0500
# Node ID 514fb53d0a35229162cf58b9e6631e881e959177
# Parent  3f8f53190d6afed0aca6c6527236edad28ce785c
osx: install bash and zsh completions by default

The zsh location appears to be on the default $fpath for zsh. bash, on
the other hand, appears to have no default location for completion
scripts, so we follow the lead of Apple's Git distribution and select
a semi-arbitrary place in /usr/local for the file.
Yuya Nishihara - March 3, 2017, 1:13 p.m.
On Mon, 27 Feb 2017 18:12:44 -0500, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1486412372 18000
> #      Mon Feb 06 15:19:32 2017 -0500
> # Node ID 514fb53d0a35229162cf58b9e6631e881e959177
> # Parent  3f8f53190d6afed0aca6c6527236edad28ce785c
> osx: install bash and zsh completions by default
> 
> The zsh location appears to be on the default $fpath for zsh. bash, on
> the other hand, appears to have no default location for completion
> scripts, so we follow the lead of Apple's Git distribution and select
> a semi-arbitrary place in /usr/local for the file.

Seems fine. Queued, thanks.

Patch

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -163,6 +163,16 @@  osx:
 	  --root=build/mercurial/ --prefix=/usr/local/ \
 	  --install-lib=/Library/Python/2.7/site-packages/
 	make -C doc all install DESTDIR="$(PWD)/build/mercurial/"
+        # install zsh completions - this location appears to be
+        # searched by default as of macOS Sierra.
+	mkdir -p build/mercurial/usr/local/share/zsh/site-functions
+	cp contrib/zsh_completion build/mercurial/usr/local/share/zsh/site-functions/hg
+        # install bash completions - there doesn't appear to be a
+        # place that's searched by default for bash, so we'll follow
+        # the lead of Apple's git install and just put it in a
+        # location of our own.
+	mkdir -p build/mercurial/usr/local/hg/contrib
+	cp contrib/bash_completion build/mercurial/usr/local/hg/contrib/hg-completion.bash
 	mkdir -p $${OUTPUTDIR:-dist}
 	HGVER=$$((cat build/mercurial/Library/Python/2.7/site-packages/mercurial/__version__.py; echo 'print(version)') | python) && \
 	OSXVER=$$(sw_vers -productVersion | cut -d. -f1,2) && \
diff --git a/tests/test-mac-packages.t b/tests/test-mac-packages.t
--- a/tests/test-mac-packages.t
+++ b/tests/test-mac-packages.t
@@ -25,6 +25,10 @@  Spot-check some randomly selected files:
   ./Library/Python/2.7/site-packages/mercurial/pure/bdiff.py	100644	0/0
   ./Library/Python/2.7/site-packages/mercurial/pure/bdiff.pyc	100644	0/0
   ./Library/Python/2.7/site-packages/mercurial/pure/bdiff.pyo	100644	0/0
+  $ grep zsh/site-functions/hg boms.txt | cut -d '	' -f 1,2,3
+  ./usr/local/share/zsh/site-functions/hg	100640	0/0
+  $ grep hg-completion.bash boms.txt | cut -d '	' -f 1,2,3
+  ./usr/local/hg/contrib/hg-completion.bash	100640	0/0
   $ egrep 'man[15]' boms.txt | cut -d '	' -f 1,2,3
   ./usr/local/share/man/man1	40755	0/0
   ./usr/local/share/man/man1/hg.1	100644	0/0
@@ -40,7 +44,7 @@  Spot-check some randomly selected files:
   ./Library/Python/2.7/site-packages/mercurial/localrepo.py	100644	0/0
   ./Library/Python/2.7/site-packages/mercurial/localrepo.pyc	100644	0/0
   ./Library/Python/2.7/site-packages/mercurial/localrepo.pyo	100644	0/0
-  $ grep '/hg	' boms.txt | cut -d '	' -f 1,2,3
+  $ grep 'bin/hg	' boms.txt | cut -d '	' -f 1,2,3
   ./usr/local/bin/hg	100755	0/0
 
 Make sure the built binary uses the system Python interpreter