[PATCH 0 of 1] ui: add function 'promptselection'

Ingo Proetel proetel at aicas.de
Mon Aug 8 09:50:18 CDT 2011


Hello,

This patch introduces a new function 'prompselection' which adds some functionality over 'promptchoice':
For the hg user it will provide the possible choices in an consistent way (in square brackes with the default capitalized), the sequence of commands will not change through localization, and '?' will provide verbose help.
The programmer does not need to create the possible choices by hand, can work with readable command instead of indices, and gets a help function for free.

Example usage:
    choices = (('abort',_('&Abort command')),
               ('new',_('Create &new request')),
               ('reopen',_('&Reopen request')) )
    request = ui.promptselection('now what?', choices,'new')
    if    request == 'abort':
      raise util.Abort('User aborted')
    elif  request == 'new':
      ui.status('creating new')
    else:#request == 'reopen'
      ui.status('reopen existing')
      
Best Regards,
Ingo


More information about the Mercurial-devel mailing list