comparison hgext/narrow/narrowcommands.py @ 39818:24e493ec2229

py3: rename pycompat.getcwd() to encoding.getcwd() (API) We need to avoid os.getcwdb() on Windows to avoid DeprecationWarnings, and we need encoding.strtolocal() to encode the result of os.getcwd().
author Matt Harbison <matt_harbison@yahoo.com>
date Fri, 21 Sep 2018 19:48:23 -0400
parents 9d5c919b6dc3
children d5498db5f86a
comparison
equal deleted inserted replaced
39817:94c25f694ec3 39818:24e493ec2229
67 opts = pycompat.byteskwargs(opts) 67 opts = pycompat.byteskwargs(opts)
68 wrappedextraprepare = util.nullcontextmanager() 68 wrappedextraprepare = util.nullcontextmanager()
69 narrowspecfile = opts['narrowspec'] 69 narrowspecfile = opts['narrowspec']
70 70
71 if narrowspecfile: 71 if narrowspecfile:
72 filepath = os.path.join(pycompat.getcwd(), narrowspecfile) 72 filepath = os.path.join(encoding.getcwd(), narrowspecfile)
73 ui.status(_("reading narrowspec from '%s'\n") % filepath) 73 ui.status(_("reading narrowspec from '%s'\n") % filepath)
74 try: 74 try:
75 fdata = util.readfile(filepath) 75 fdata = util.readfile(filepath)
76 except IOError as inst: 76 except IOError as inst:
77 raise error.Abort(_("cannot read narrowspecs from '%s': %s") % 77 raise error.Abort(_("cannot read narrowspecs from '%s': %s") %
347 347
348 # import rules from a file 348 # import rules from a file
349 newrules = opts.get('import_rules') 349 newrules = opts.get('import_rules')
350 if newrules: 350 if newrules:
351 try: 351 try:
352 filepath = os.path.join(pycompat.getcwd(), newrules) 352 filepath = os.path.join(encoding.getcwd(), newrules)
353 fdata = util.readfile(filepath) 353 fdata = util.readfile(filepath)
354 except IOError as inst: 354 except IOError as inst:
355 raise error.Abort(_("cannot read narrowspecs from '%s': %s") % 355 raise error.Abort(_("cannot read narrowspecs from '%s': %s") %
356 (filepath, encoding.strtolocal(inst.strerror))) 356 (filepath, encoding.strtolocal(inst.strerror)))
357 includepats, excludepats, profiles = sparse.parseconfig(ui, fdata, 357 includepats, excludepats, profiles = sparse.parseconfig(ui, fdata,