Mercurial > hg
comparison mercurial/ui.py @ 40542:d8997c5ce2ff
ui: label prompt and echo messages
I'm going to add a dedicated command-server channel for status messages,
which carries metadata alongside a message text. 'ui.*' label provides a
hint how message text should be processed.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 18 Jan 2015 17:42:53 +0900 |
parents | c2aea007130b |
children | 7bffbbe03e90 |
comparison
equal
deleted
inserted
replaced
40541:c2aea007130b | 40542:d8997c5ce2ff |
---|---|
1338 def prompt(self, msg, default="y"): | 1338 def prompt(self, msg, default="y"): |
1339 """Prompt user with msg, read response. | 1339 """Prompt user with msg, read response. |
1340 If ui is not interactive, the default is returned. | 1340 If ui is not interactive, the default is returned. |
1341 """ | 1341 """ |
1342 if not self.interactive(): | 1342 if not self.interactive(): |
1343 self.write(msg, ' ', default or '', "\n") | 1343 self.write(msg, ' ', label='ui.prompt') |
1344 self.write(default or '', "\n", label='ui.promptecho') | |
1344 return default | 1345 return default |
1345 self._writenobuf(self.fout, msg, label='ui.prompt') | 1346 self._writenobuf(self.fout, msg, label='ui.prompt') |
1346 self.flush() | 1347 self.flush() |
1347 try: | 1348 try: |
1348 r = self._readline() | 1349 r = self._readline() |
1349 if not r: | 1350 if not r: |
1350 r = default | 1351 r = default |
1351 if self.configbool('ui', 'promptecho'): | 1352 if self.configbool('ui', 'promptecho'): |
1352 self.write(r, "\n") | 1353 self.write(r, "\n", label='ui.promptecho') |
1353 return r | 1354 return r |
1354 except EOFError: | 1355 except EOFError: |
1355 raise error.ResponseExpected() | 1356 raise error.ResponseExpected() |
1356 | 1357 |
1357 @staticmethod | 1358 @staticmethod |