diff -r 7ce0ba3a1c32 -r 5b569d512fbd mercurial/pycompat.py --- a/mercurial/pycompat.py Thu Nov 23 23:18:56 2017 +0900 +++ b/mercurial/pycompat.py Fri Nov 24 01:09:00 2017 +0900 @@ -214,7 +214,7 @@ def open(name, mode='r', buffering=-1): return builtins.open(name, sysstr(mode), buffering) - def getoptb(args, shortlist, namelist): + def _getoptbwrapper(orig, args, shortlist, namelist): """ Takes bytes arguments, converts them to unicode, pass them to getopt.getopt(), convert the returned values back to bytes and then @@ -224,7 +224,7 @@ args = [a.decode('latin-1') for a in args] shortlist = shortlist.decode('latin-1') namelist = [a.decode('latin-1') for a in namelist] - opts, args = getopt.getopt(args, shortlist, namelist) + opts, args = orig(args, shortlist, namelist) opts = [(a[0].encode('latin-1'), a[1].encode('latin-1')) for a in opts] args = [a.encode('latin-1') for a in args] @@ -291,8 +291,8 @@ def getdoc(obj): return getattr(obj, '__doc__', None) - def getoptb(args, shortlist, namelist): - return getopt.getopt(args, shortlist, namelist) + def _getoptbwrapper(orig, args, shortlist, namelist): + return orig(args, shortlist, namelist) strkwargs = identity byteskwargs = identity @@ -320,3 +320,9 @@ isdarwin = sysplatform == 'darwin' isposix = osname == 'posix' iswindows = osname == 'nt' + +def getoptb(args, shortlist, namelist): + return _getoptbwrapper(getopt.getopt, args, shortlist, namelist) + +def gnugetoptb(args, shortlist, namelist): + return _getoptbwrapper(getopt.gnu_getopt, args, shortlist, namelist)