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 |