Mercurial > hg
view mercurial/fancyopts.py @ 529:aace5b681fe9
Attempt to fix negative revision count from pull
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Attempt to fix negative revision count from pull
manifest hash: 4e8881037d545f4bf76d2c1b06f685b2467cd3a8
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCw4yUywK+sNU5EO8RApUkAKCCYTpBG3Wpu15aVeG0iBWE612S5wCgnSBi
PEfXF4NI2O9AqWijOMBq6aM=
=AyGw
-----END PGP SIGNATURE-----
author | mpm@selenic.com |
---|---|
date | Wed, 29 Jun 2005 22:09:24 -0800 |
parents | 03f27b1381f9 |
children | f9ad1a2c72eb |
line wrap: on
line source
import sys, os, getopt def fancyopts(args, options, state, syntax='', minlen = 0): 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) if os.environ.has_key("HG_OPTS"): args = os.environ["HG_OPTS"].split() + args 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