annotate unixSoft/bin/hgimp @ 377:117e3c11d953

zprofile: introduce zprofile use El Capitan (OS X 10.11) introduces a system-level /etc/zprofile which uses a path_helper thing to mangle $PATH. Unfortunately, the way path_helper works, it forces /usr/local/bin and /usr/bin to the *start* of the PATH variable, which means that any PATH mutations I want have to run after /etc/zprofile calls path_helper. As such, move my path insertions into .zprofile{,-machine} rather than .zshenv{,-machine} so that I can still ensure my path entries are at the start of PATH rather than the end. This works because: > Commands are then read from $ZDOTDIR/.zshenv. If the shell is a > login shell, commands are read from /etc/zprofile and then > $ZDOTDIR/.zprofile. Then, if the shell is interactive, commands > are read from /etc/zshrc and then $ZDOTDIR/.zshrc. Finally, if the > shell is a login shell, /etc/zlogin and $ZDOTDIR/.zlogin are read. This means that non-login shells no longer pick up my custom PATH entries, but as I only use OS X as a desktop OS that seems like a workable tradeoff for now.
author Augie Fackler <raf@durin42.com>
date Sun, 31 Jan 2016 20:46:29 -0500
parents 2ac43cd7bbf7
children 24d75bc4a3a1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
343
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
1 #!/usr/bin/env python
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
2 import argparse
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
3 import os
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
4 import subprocess
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
5 import sys
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
6
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
7 _MAP = {
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
8 'hg': '~/Programming/hg/crew',
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
9 'hgsubversion': '~/Programming/hg/hgsubversion',
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
10 'hg-git': '~/Programming/hg/hg-git',
364
2ac43cd7bbf7 hgimp: add location of topic repo
Augie Fackler <raf@durin42.com>
parents: 343
diff changeset
11 'topics': '~/Programming/hg/topic',
343
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
12 }
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
13
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
14
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
15 def main(argv):
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
16 p = argparse.ArgumentParser('import patches')
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
17 p.add_argument('repo', type=str, nargs=1,
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
18 help='repo name to apply patches to')
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
19 args = p.parse_args(argv[1:])
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
20 name, = args.repo
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
21 if name in _MAP:
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
22 repo = _MAP[name]
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
23 else:
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
24 c = []
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
25 for n in _MAP:
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
26 if n.startswith(name):
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
27 c.append(n)
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
28 if not c:
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
29 print 'abort: no repo named %s' % name
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
30 sys.exit(1)
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
31 elif len(c) != 1:
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
32 print 'abort: ambiguous repo name %s matches %s' % (
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
33 name, ', '.join(c))
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
34 sys.exit(1)
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
35 repo = _MAP[c[0]]
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
36 hg = subprocess.Popen(['hg', '-R', repo, 'import', '--obsolete', '-'],
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
37 stdin=subprocess.PIPE)
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
38 hg.stdin.write(sys.stdin.read())
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
39 hg.stdin.close()
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
40 hg.wait()
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
41 sys.exit(hg.returncode)
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
42
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
43
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
44 if __name__ == '__main__':
70e76c545606 hgimp: utility to make importing hg patches from mutt easier
Augie Fackler <raf@durin42.com>
parents:
diff changeset
45 main(argv=sys.argv)