Mercurial > public > mercurial-scm > hg
diff mercurial/ui.py @ 40592:83e571ea06a9
commandserver: attach prompt default and choices to message
These attributes are important to provide a GUI prompt to user.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 04 Nov 2018 12:17:20 +0900 |
parents | 83dd8c63a0c6 |
children | 6f0941f4a184 |
line wrap: on
line diff
--- a/mercurial/ui.py Thu Nov 08 22:25:04 2018 +0900 +++ b/mercurial/ui.py Sun Nov 04 12:17:20 2018 +0900 @@ -1390,12 +1390,16 @@ """Prompt user with msg, read response. If ui is not interactive, the default is returned. """ + return self._prompt(msg, default=default) + + def _prompt(self, msg, **opts): + default = opts[r'default'] if not self.interactive(): - self._writemsg(self._fmsgout, msg, ' ', type='prompt') + self._writemsg(self._fmsgout, msg, ' ', type='prompt', **opts) self._writemsg(self._fmsgout, default or '', "\n", type='promptecho') return default - self._writemsgnobuf(self._fmsgout, msg, type='prompt') + self._writemsgnobuf(self._fmsgout, msg, type='prompt', **opts) self.flush() try: r = self._readline() @@ -1449,7 +1453,7 @@ msg, choices = self.extractchoices(prompt) resps = [r for r, t in choices] while True: - r = self.prompt(msg, resps[default]) + r = self._prompt(msg, default=resps[default], choices=choices) if r.lower() in resps: return resps.index(r.lower()) # TODO: shouldn't it be a warning?