mercurial/ui.py
changeset 33714 d880a6bcef2f
parent 33687 6294654453ee
child 33736 86aca74a063b
equal deleted inserted replaced
33713:888f24810ea2 33714:d880a6bcef2f
  1267         # choices containing spaces, ASCII, or basically anything
  1267         # choices containing spaces, ASCII, or basically anything
  1268         # except an ampersand followed by a character.
  1268         # except an ampersand followed by a character.
  1269         m = re.match(br'(?s)(.+?)\$\$([^\$]*&[^ \$].*)', prompt)
  1269         m = re.match(br'(?s)(.+?)\$\$([^\$]*&[^ \$].*)', prompt)
  1270         msg = m.group(1)
  1270         msg = m.group(1)
  1271         choices = [p.strip(' ') for p in m.group(2).split('$$')]
  1271         choices = [p.strip(' ') for p in m.group(2).split('$$')]
  1272         return (msg,
  1272         def choicetuple(s):
  1273                 [(s[s.index('&') + 1].lower(), s.replace('&', '', 1))
  1273             ampidx = s.index('&')
  1274                  for s in choices])
  1274             return s[ampidx + 1:ampidx + 2].lower(), s.replace('&', '', 1)
       
  1275         return (msg, [choicetuple(s) for s in choices])
  1275 
  1276 
  1276     def promptchoice(self, prompt, default=0):
  1277     def promptchoice(self, prompt, default=0):
  1277         """Prompt user with a message, read response, and ensure it matches
  1278         """Prompt user with a message, read response, and ensure it matches
  1278         one of the provided choices. The prompt is formatted as follows:
  1279         one of the provided choices. The prompt is formatted as follows:
  1279 
  1280