# HG changeset patch # User Kirill Smelkov # Date 2007-12-28 06:03:55 # Node ID bc475d1f74caf65df21b267b5b9ab58770c3a903 # Parent 206b44764340643de08603a50ce587c3efe25b1e 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. diff --git a/hgext/record.py b/hgext/record.py --- a/hgext/record.py +++ b/hgext/record.py @@ -247,8 +247,8 @@ def filterpatch(ui, chunks): if resp_file[0] is not None: return resp_file[0] while True: - r = (ui.prompt(query + _(' [Ynsfdaq?] '), '[Ynsfdaq?]?$', - matchflags=re.I) or 'y').lower() + r = (ui.prompt(query + _(' [Ynsfdaq?] '), '(?i)[Ynsfdaq?]?$') + or 'y').lower() if r == '?': c = record.__doc__.find('y - record this change') for l in record.__doc__[c:].splitlines(): diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -410,14 +410,18 @@ class ui(object): line = line[:-1] return line - def prompt(self, msg, pat=None, default="y", matchflags=0): + def prompt(self, msg, pat=None, default="y"): + """Prompt user with msg, read response, and ensure it matches pat + + If not interactive -- the default is returned + """ if not self.interactive: return default while True: try: r = self._readline(msg + ' ') if not r: return default - if not pat or re.match(pat, r, matchflags): + if not pat or re.match(pat, r): return r else: self.write(_("unrecognized response\n"))