mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
c77de876fa
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Add username/merge/editor to .hgrc These take priority over the equivalent environment vars Deprecate HGMERGE, HGUSER, and HGEDITOR in docs Add ui section to docs Remove undocumented HG_OPTS Raise username code out of changelog class Make tests ignore ~/.hgrc manifest hash: d127ef02bc5266036b4c77a55319519e91bd475b -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCyM5NywK+sNU5EO8RAuU7AJ9zKk1TFrJXHM04jOOJJeBSp8jlTgCeP+tr qwGFd+WaNqTepZ0wun5g9Uc= =QEBu -----END PGP SIGNATURE-----
28 lines
769 B
Python
28 lines
769 B
Python
import os, getopt
|
|
|
|
def fancyopts(args, options, state):
|
|
long=[]
|
|
short=''
|
|
map={}
|
|
dt={}
|
|
|
|
for s, l, d, c in options:
|
|
map['-'+s] = map['--'+l]=l
|
|
state[l] = d
|
|
dt[l] = type(d)
|
|
if not d is None and not callable(d): s, l=s+':', l+'='
|
|
if s: short = short + s
|
|
if l: long.append(l)
|
|
|
|
opts, args = getopt.getopt(args, short, long)
|
|
|
|
for opt, arg in opts:
|
|
if dt[map[opt]] is type(fancyopts): state[map[opt]](state,map[opt],arg)
|
|
elif dt[map[opt]] is type(1): state[map[opt]] = int(arg)
|
|
elif dt[map[opt]] is type(''): state[map[opt]] = arg
|
|
elif dt[map[opt]] is type([]): state[map[opt]].append(arg)
|
|
elif dt[map[opt]] is type(None): state[map[opt]] = 1
|
|
|
|
return args
|
|
|