Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/ui.py @ 5751:bc475d1f74ca
prompt: kill matchflags
Python already lets one to embed RE flags directly in a regex, which
is a much nicer way to do things:
(?iLmsux)
(One or more letters from the set "i", "L", "m", "s", "u", "x".)
...
matchflags was introduced in 67afecb8d6cc, and the record extension is the only
user. I've killed matchflag, and adjusted record code appropriately.
author | Kirill Smelkov <kirr@mns.spb.ru> |
---|---|
date | Fri, 28 Dec 2007 00:03:55 -0600 |
parents | 9dc26941020b |
children | ffaf2419de44 |
comparison
equal
deleted
inserted
replaced
5750:206b44764340 | 5751:bc475d1f74ca |
---|---|
408 # raw_input() to emit an extra trailing carriage return | 408 # raw_input() to emit an extra trailing carriage return |
409 if os.linesep == '\r\n' and line and line[-1] == '\r': | 409 if os.linesep == '\r\n' and line and line[-1] == '\r': |
410 line = line[:-1] | 410 line = line[:-1] |
411 return line | 411 return line |
412 | 412 |
413 def prompt(self, msg, pat=None, default="y", matchflags=0): | 413 def prompt(self, msg, pat=None, default="y"): |
414 """Prompt user with msg, read response, and ensure it matches pat | |
415 | |
416 If not interactive -- the default is returned | |
417 """ | |
414 if not self.interactive: return default | 418 if not self.interactive: return default |
415 while True: | 419 while True: |
416 try: | 420 try: |
417 r = self._readline(msg + ' ') | 421 r = self._readline(msg + ' ') |
418 if not r: | 422 if not r: |
419 return default | 423 return default |
420 if not pat or re.match(pat, r, matchflags): | 424 if not pat or re.match(pat, r): |
421 return r | 425 return r |
422 else: | 426 else: |
423 self.write(_("unrecognized response\n")) | 427 self.write(_("unrecognized response\n")) |
424 except EOFError: | 428 except EOFError: |
425 raise util.Abort(_('response expected')) | 429 raise util.Abort(_('response expected')) |