comparison mercurial/color.py @ 37664:483cafc3762a

py3: make sure curses.tigetstr() first argument is a str Differential Revision: https://phab.mercurial-scm.org/D3325
author Pulkit Goyal <7895pulkit@gmail.com>
date Sat, 14 Apr 2018 02:00:43 +0530
parents 5340daa85c62
children 35632d392279
comparison
equal deleted inserted replaced
37663:fc114a16a484 37664:483cafc3762a
169 return 169 return
170 170
171 for key, (b, e, c) in ui._terminfoparams.copy().items(): 171 for key, (b, e, c) in ui._terminfoparams.copy().items():
172 if not b: 172 if not b:
173 continue 173 continue
174 if not c and not curses.tigetstr(e): 174 if not c and not curses.tigetstr(pycompat.sysstr(e)):
175 # Most terminals don't support dim, invis, etc, so don't be 175 # Most terminals don't support dim, invis, etc, so don't be
176 # noisy and use ui.debug(). 176 # noisy and use ui.debug().
177 ui.debug("no terminfo entry for %s\n" % e) 177 ui.debug("no terminfo entry for %s\n" % e)
178 del ui._terminfoparams[key] 178 del ui._terminfoparams[key]
179 if not curses.tigetstr('setaf') or not curses.tigetstr('setab'): 179 if not curses.tigetstr(r'setaf') or not curses.tigetstr(r'setab'):
180 # Only warn about missing terminfo entries if we explicitly asked for 180 # Only warn about missing terminfo entries if we explicitly asked for
181 # terminfo mode and we're in a formatted terminal. 181 # terminfo mode and we're in a formatted terminal.
182 if mode == "terminfo" and formatted: 182 if mode == "terminfo" and formatted:
183 ui.warn(_("no terminfo entry for setab/setaf: reverting to " 183 ui.warn(_("no terminfo entry for setab/setaf: reverting to "
184 "ECMA-48 color\n")) 184 "ECMA-48 color\n"))
323 return '' 323 return ''
324 if attr: 324 if attr:
325 if termcode: 325 if termcode:
326 return termcode 326 return termcode
327 else: 327 else:
328 return curses.tigetstr(val) 328 return curses.tigetstr(pycompat.sysstr(val))
329 elif bg: 329 elif bg:
330 return curses.tparm(curses.tigetstr('setab'), val) 330 return curses.tparm(curses.tigetstr(r'setab'), val)
331 else: 331 else:
332 return curses.tparm(curses.tigetstr('setaf'), val) 332 return curses.tparm(curses.tigetstr(r'setaf'), val)
333 333
334 def _mergeeffects(text, start, stop): 334 def _mergeeffects(text, start, stop):
335 """Insert start sequence at every occurrence of stop sequence 335 """Insert start sequence at every occurrence of stop sequence
336 336
337 >>> s = _mergeeffects(b'cyan', b'[C]', b'|') 337 >>> s = _mergeeffects(b'cyan', b'[C]', b'|')