def show_doc(ui): def bold(s, text=""): ui.write("%s\n%s\n%s\n" % (s, "=" * len(s), text)) def underlined(s, text=""): ui.write("%s\n%s\n%s\n" % (s, "-" * len(s), text)) # print options underlined(_("OPTIONS")) for optstr, desc in get_opts(globalopts): ui.write("%s::\n %s\n\n" % (optstr, desc)) # print cmds underlined(_("COMMANDS")) h = {} for c, attr in table.items(): f = c.split("|")[0] f = f.lstrip("^") h[f] = c cmds = h.keys() cmds.sort() for f in cmds: if f.startswith("debug"): continue d = get_cmd(h[f]) # synopsis ui.write("[[%s]]\n" % d['cmd']) ui.write("%s::\n" % d['synopsis'].replace("hg ", "", 1)) # description ui.write("%s\n\n" % d['desc'][1]) # options opt_output = list(d['opts']) if opt_output: opts_len = max([len(line[0]) for line in opt_output]) ui.write(_(" options:\n")) for optstr, desc in opt_output: if desc: s = "%-*s %s" % (opts_len, optstr, desc) else: s = optstr s = textwrap.fill(s, initial_indent=4 * " ", subsequent_indent=(6 + opts_len) * " ") ui.write("%s\n" % s) ui.write("\n") # aliases if d['aliases']: ui.write(_(" aliases: %s\n\n") % " ".join(d['aliases'])) # print topics for names, section, doc in helptable: underlined(gettext(section).upper()) if callable(doc): doc = doc() else: doc = gettext(doc) ui.write(doc) ui.write("\n")
def show_doc(ui): def bold(s, text=""): ui.write("%s\n%s\n%s\n" % (s, "="*len(s), text)) def underlined(s, text=""): ui.write("%s\n%s\n%s\n" % (s, "-"*len(s), text)) # print options underlined(_("OPTIONS")) for optstr, desc in get_opts(globalopts): ui.write("%s::\n %s\n\n" % (optstr, desc)) # print cmds underlined(_("COMMANDS")) h = {} for c, attr in table.items(): f = c.split("|")[0] f = f.lstrip("^") h[f] = c cmds = h.keys() cmds.sort() for f in cmds: if f.startswith("debug"): continue d = get_cmd(h[f]) # synopsis ui.write("[[%s]]\n" % d['cmd']) ui.write("%s::\n" % d['synopsis'].replace("hg ","", 1)) # description ui.write("%s\n\n" % d['desc'][1]) # options opt_output = list(d['opts']) if opt_output: opts_len = max([len(line[0]) for line in opt_output]) ui.write(_(" options:\n")) for optstr, desc in opt_output: if desc: s = "%-*s %s" % (opts_len, optstr, desc) else: s = optstr s = textwrap.fill(s, initial_indent=4 * " ", subsequent_indent=(6 + opts_len) * " ") ui.write("%s\n" % s) ui.write("\n") # aliases if d['aliases']: ui.write(_(" aliases: %s\n\n") % " ".join(d['aliases'])) # print topics for names, section, doc in helptable: underlined(gettext(section).upper()) if callable(doc): doc = doc() else: doc = gettext(doc) ui.write(doc) ui.write("\n")
def extendCommand(commandName, newFunction, moreOptions, moreSyntax): """Attempt to add options and syntax to an existing mercurial command. commandName - string name of existing mercurial command newFunction - function that will handle that command now. This function must accept a named argument, "original" which will contain the function Mercurial would normally call for the command. moreOptions - additional options formatted like the normal command-table options lists moreSyntax - additional syntax help string, with a %s where old syntax will be inserted """ def findCmd(cmdName): keys = [(k, v) for k, v in commands.table.items() if k.lstrip("^").startswith(cmdName)] if not keys: util.Abort( _("Unable to find existing command to extend: %s.") % cmdName) if len(keys) > 1: util.Abort( _("Ambiguous command requested for extension: %s.") % cmdName) return keys[0] def allopts(opts): # set of all short and long options for a command return set([x[0] for x in opts] + [x[1] for x in opts]) #look up existing command table entry fullNames, oldCmd = findCmd(commandName) oldFunc, oldOpts, oldSyntax = oldCmd #make sure none of our additional options conflict if allopts(oldOpts) & allopts(moreOptions): msg = _( "Extension trying to add conflicting options to %s") % commandName util.Abort(msg) #create a replacement command tableentry that calls our function instead def wrapper(ui, repo, *args, **opts): cleanOpts = opts.copy() for opt in moreOptions: #remove our added options from passthrough key = opt[1].replace("-", "_") del cleanOpts[key] def callOriginal(): return oldFunc(ui, repo, *args, **cleanOpts) return newFunction(ui, repo, original=callOriginal, *args, **opts) options = oldOpts + moreOptions syntax = moreSyntax % oldSyntax # the functionn doc string is called by 'hg help' # we just follow the pattern and add our extension help wrapper.__doc__ = gettext(oldFunc.__doc__) + "\n\n" + gettext( newFunction.__doc__) # replace the commad table entry with our own commands.table[fullNames] = (wrapper, options, syntax)
def showdoc(ui): # print options ui.write(minirst.section(_("Options"))) for optstr, desc in get_opts(globalopts): ui.write("%s\n %s\n\n" % (optstr, desc)) # print cmds ui.write(minirst.section(_("Commands"))) commandprinter(ui, table, minirst.subsection) # print help topics # The config help topic is included in the hgrc.5 man page. helpprinter(ui, helptable, minirst.section, exclude=['config']) ui.write(minirst.section(_("Extensions"))) ui.write( _("This section contains help for extensions that are " "distributed together with Mercurial. Help for other " "extensions is available in the help system.")) ui.write("\n\n" ".. contents::\n" " :class: htmlonly\n" " :local:\n" " :depth: 1\n\n") for extensionname in sorted(allextensionnames()): mod = extensions.load(None, extensionname, None) ui.write(minirst.subsection(extensionname)) ui.write("%s\n\n" % gettext(mod.__doc__)) cmdtable = getattr(mod, 'cmdtable', None) if cmdtable: ui.write(minirst.subsubsection(_('Commands'))) commandprinter(ui, cmdtable, minirst.subsubsubsection)
def showdoc(ui): # print options ui.write(minirst.section(_("Options"))) for optstr, desc in get_opts(globalopts): ui.write("%s\n %s\n\n" % (optstr, desc)) # print cmds ui.write(minirst.section(_("Commands"))) commandprinter(ui, table, minirst.subsection) # print help topics # The config help topic is included in the hgrc.5 man page. helpprinter(ui, helptable, minirst.section, exclude=['config']) ui.write(minirst.section(_("Extensions"))) ui.write(_("This section contains help for extensions that are " "distributed together with Mercurial. Help for other " "extensions is available in the help system.")) ui.write("\n\n" ".. contents::\n" " :class: htmlonly\n" " :local:\n" " :depth: 1\n\n") for extensionname in sorted(allextensionnames()): mod = extensions.load(None, extensionname, None) ui.write(minirst.subsection(extensionname)) ui.write("%s\n\n" % gettext(mod.__doc__)) cmdtable = getattr(mod, 'cmdtable', None) if cmdtable: ui.write(minirst.subsubsection(_('Commands'))) commandprinter(ui, cmdtable, minirst.subsubsubsection)
def extendCommand( commandName, newFunction, moreOptions, moreSyntax): """Attempt to add options and syntax to an existing mercurial command. commandName - string name of existing mercurial command newFunction - function that will handle that command now. This function must accept a named argument, "original" which will contain the function Mercurial would normally call for the command. moreOptions - additional options formatted like the normal command-table options lists moreSyntax - additional syntax help string, with a %s where old syntax will be inserted """ def findCmd( cmdName): keys = [(k,v) for k,v in commands.table.items() if k.lstrip("^").startswith(cmdName)] if not keys: util.Abort( _("Unable to find existing command to extend: %s.") % cmdName) if len(keys)> 1: util.Abort( _("Ambiguous command requested for extension: %s.") % cmdName) return keys[0] def allopts( opts):# set of all short and long options for a command return set( [x[0] for x in opts] + [x[1] for x in opts]) #look up existing command table entry fullNames, oldCmd = findCmd( commandName) oldFunc, oldOpts, oldSyntax = oldCmd #make sure none of our additional options conflict if allopts(oldOpts) & allopts(moreOptions): msg = _("Extension trying to add conflicting options to %s") % commandName util.Abort(msg) #create a replacement command tableentry that calls our function instead def wrapper( ui, repo, *args, **opts): cleanOpts = opts.copy() for opt in moreOptions: #remove our added options from passthrough key= opt[1].replace("-","_") del cleanOpts[key] def callOriginal(): return oldFunc( ui, repo, *args, **cleanOpts) return newFunction( ui, repo, original=callOriginal, *args, **opts) options = oldOpts + moreOptions syntax = moreSyntax % oldSyntax # the functionn doc string is called by 'hg help' # we just follow the pattern and add our extension help wrapper.__doc__ = gettext(oldFunc.__doc__) + "\n\n" + gettext(newFunction.__doc__) # replace the commad table entry with our own commands.table[fullNames] = (wrapper, options, syntax)
def prompt(query): """prompt query, and process base inputs - y/n for the rest of file - y/n for the rest - ? (help) - q (quit) else, input is returned to the caller. """ if resp_all[0] is not None: return resp_all[0] if resp_file[0] is not None: return resp_file[0] while True: resps = _("[Ynsfdaq?]") choices = ( _("&Yes, record this change"), _("&No, skip this change"), _("&Skip remaining changes to this file"), _("Record remaining changes to this &file"), _("&Done, skip remaining changes and files"), _("Record &all changes to all remaining files"), _("&Quit, recording no changes"), _("&?"), ) r = ui.promptchoice("%s %s " % (query, resps), choices) if r == 7: # ? doc = gettext(record.__doc__) c = doc.find(_("y - record this change")) for l in doc[c:].splitlines(): if l: ui.write(l.strip(), "\n") continue elif r == 0: # yes ret = "y" elif r == 1: # no ret = "n" elif r == 2: # Skip ret = resp_file[0] = "n" elif r == 3: # file (Record remaining) ret = resp_file[0] = "y" elif r == 4: # done, skip remaining ret = resp_all[0] = "n" elif r == 5: # all ret = resp_all[0] = "y" elif r == 6: # quit raise util.Abort(_("user quit")) return ret
def prompt(skipfile, skipall, query): """prompt query, and process base inputs - y/n for the rest of file - y/n for the rest - ? (help) - q (quit) Return True/False and possibly updated skipfile and skipall. """ if skipall is not None: return skipall, skipfile, skipall if skipfile is not None: return skipfile, skipfile, skipall while True: resps = _('[Ynsfdaq?]' '$$ &Yes, shelve this change' '$$ &No, skip this change' '$$ &Skip remaining changes to this file' '$$ Shelve remaining changes to this &file' '$$ &Done, skip remaining changes and files' '$$ Shelve &all changes to all remaining files' '$$ &Quit, shelving no changes' '$$ &?' ) r = ui.promptchoice("%s %s" % (query, resps)) ui.write("\n") if r == 7: # ? doc = gettext(shelve.__doc__) c = doc.find('::') + 2 for l in doc[c:].splitlines(): if l.startswith(' '): ui.write(l.strip(), '\n') continue elif r == 0: # yes ret = True elif r == 1: # no ret = False elif r == 2: # Skip ret = skipfile = False elif r == 3: # file (shelve remaining) ret = skipfile = True elif r == 4: # done, skip remaining ret = skipall = False elif r == 5: # all ret = skipall = True elif r == 6: # quit raise util.Abort(_('user quit')) return ret, skipfile, skipall
def prompt(query): """prompt query, and process base inputs - y/n for the rest of file - y/n for the rest - ? (help) - q (quit) Returns True/False and sets reps_all and resp_file as appropriate. """ if resp_all[0] is not None: return resp_all[0] if resp_file[0] is not None: return resp_file[0] while True: resps = _('[Ynsfdaq?]') choices = (_('&Yes, record this change'), _('&No, skip this change'), _('&Skip remaining changes to this file'), _('Record remaining changes to this &file'), _('&Done, skip remaining changes and files'), _('Record &all changes to all remaining files'), _('&Quit, recording no changes'), _('&?')) r = ui.promptchoice("%s %s" % (query, resps), choices) ui.write("\n") if r == 7: # ? doc = gettext(record.__doc__) c = doc.find('::') + 2 for l in doc[c:].splitlines(): if l.startswith(' '): ui.write(l.strip(), '\n') continue elif r == 0: # yes ret = True elif r == 1: # no ret = False elif r == 2: # Skip ret = resp_file[0] = False elif r == 3: # file (Record remaining) ret = resp_file[0] = True elif r == 4: # done, skip remaining ret = resp_all[0] = False elif r == 5: # all ret = resp_all[0] = True elif r == 6: # quit raise util.Abort(_('user quit')) return ret
def prompt(skipfile, skipall, query): """prompt query, and process base inputs - y/n for the rest of file - y/n for the rest - ? (help) - q (quit) Return True/False and possibly updated skipfile and skipall. """ if skipall is not None: return skipall, skipfile, skipall if skipfile is not None: return skipfile, skipfile, skipall while True: resps = _('[Ynsfdaq?]' '$$ &Yes, shelve this change' '$$ &No, skip this change' '$$ &Skip remaining changes to this file' '$$ Shelve remaining changes to this &file' '$$ &Done, skip remaining changes and files' '$$ Shelve &all changes to all remaining files' '$$ &Quit, shelving no changes' '$$ &?') r = ui.promptchoice("%s %s" % (query, resps)) ui.write("\n") if r == 7: # ? doc = gettext(shelve.__doc__) c = doc.find('::') + 2 for l in doc[c:].splitlines(): if l.startswith(' '): ui.write(l.strip(), '\n') continue elif r == 0: # yes ret = True elif r == 1: # no ret = False elif r == 2: # Skip ret = skipfile = False elif r == 3: # file (shelve remaining) ret = skipfile = True elif r == 4: # done, skip remaining ret = skipall = False elif r == 5: # all ret = skipall = True elif r == 6: # quit raise util.Abort(_('user quit')) return ret, skipfile, skipall
def prompt(query): """prompt query, and process base inputs - y/n for the rest of file - y/n for the rest - ? (help) - q (quit) Returns True/False and sets reps_all and resp_file as appropriate. """ if resp_all[0] is not None: return resp_all[0] if resp_file[0] is not None: return resp_file[0] while True: resps = _('[Ynsfdaq?]') choices = (_('&Yes, record this change'), _('&No, skip this change'), _('&Skip remaining changes to this file'), _('Record remaining changes to this &file'), _('&Done, skip remaining changes and files'), _('Record &all changes to all remaining files'), _('&Quit, recording no changes'), _('&?')) r = ui.promptchoice("%s %s" % (query, resps), choices) if r == 7: # ? doc = gettext(record.__doc__) c = doc.find(_('y - record this change')) for l in doc[c:].splitlines(): if l: ui.write(l.strip(), '\n') continue elif r == 0: # yes ret = True elif r == 1: # no ret = False elif r == 2: # Skip ret = resp_file[0] = False elif r == 3: # file (Record remaining) ret = resp_file[0] = True elif r == 4: # done, skip remaining ret = resp_all[0] = False elif r == 5: # all ret = resp_all[0] = True elif r == 6: # quit raise util.Abort(_('user quit')) return ret
def get_cmd(cmd, cmdtable): d = {} attr = cmdtable[cmd] cmds = cmd.lstrip("^").split("|") d['cmd'] = cmds[0] d['aliases'] = cmd.split("|")[1:] d['desc'] = get_desc(gettext(attr[0].__doc__)) d['opts'] = list(get_opts(attr[1])) s = 'hg ' + cmds[0] if len(attr) > 2: if not attr[2].startswith('hg'): s += ' ' + attr[2] else: s = attr[2] d['synopsis'] = s.strip() return d
def get_cmd(cmd, cmdtable): d = {} attr = cmdtable[cmd] cmds = cmd.lstrip("^").split("|") d['cmd'] = cmds[0] d['aliases'] = cmd.split("|")[1:] d['desc'] = get_desc(gettext(attr[0].__doc__)) d['opts'] = list(get_opts(attr[1])) s = 'hg ' + cmds[0] if len(attr) > 2: if not attr[2].startswith('hg'): s += ' ' + attr[2] else: s = attr[2] d['synopsis'] = s.strip() return d
def prompt(query): """prompt query, and process base inputs - y/n for the rest of file - y/n for the rest - ? (help) - q (quit) else, input is returned to the caller. """ if resp_all[0] is not None: return resp_all[0] if resp_file[0] is not None: return resp_file[0] while True: resps = _('[Ynsfdaq?]') choices = (_('&Yes, record this change'), _('&No, skip this change'), _('&Skip remaining changes to this file'), _('Record remaining changes to this &file'), _('&Done, skip remaining changes and files'), _('Record &all changes to all remaining files'), _('&Quit, recording no changes'), _('&?')) r = (ui.prompt("%s %s " % (query, resps), choices) or _('y')).lower() if r == _('?'): doc = gettext(record.__doc__) c = doc.find(_('y - record this change')) for l in doc[c:].splitlines(): if l: ui.write(l.strip(), '\n') continue elif r == _('s'): r = resp_file[0] = 'n' elif r == _('f'): r = resp_file[0] = 'y' elif r == _('d'): r = resp_all[0] = 'n' elif r == _('a'): r = resp_all[0] = 'y' elif r == _('q'): raise util.Abort(_('user quit')) return r
def prompt(query): """prompt query, and process base inputs - y/n for the rest of file - y/n for the rest - ? (help) - q (quit) else, input is returned to the caller. """ if resp_all[0] is not None: return resp_all[0] if resp_file[0] is not None: return resp_file[0] while True: resps = _('[Ynsfdaq?]') choices = (_('&Yes, record this change'), _('&No, skip this change'), _('&Skip remaining changes to this file'), _('Record remaining changes to this &file'), _('&Done, skip remaining changes and files'), _('Record &all changes to all remaining files'), _('&Quit, recording no changes'), _('&?')) r = (ui.prompt("%s %s " % (query, resps), choices) or _('y')).lower() if r == _('?'): doc = gettext(record.__doc__) c = doc.find(_('y - record this change')) for l in doc[c:].splitlines(): if l: ui.write(l.strip(), '\n') continue elif r == _('s'): r = resp_file[0] = 'n' elif r == _('f'): r = resp_file[0] = 'y' elif r == _('d'): r = resp_all[0] = 'n' elif r == _('a'): r = resp_all[0] = 'y' elif r == _('q'): raise util.Abort(_('user quit')) return r
def prompt(skipfile, skipall, query, chunk): """prompt query, and process base inputs - y/n for the rest of file - y/n for the rest - ? (help) - q (quit) Return True/False and possibly updated skipfile and skipall. """ newpatches = None if skipall is not None: return skipall, skipfile, skipall, newpatches if skipfile is not None: return skipfile, skipfile, skipall, newpatches while True: resps = _( "[Ynesfdaq?]" "$$ &Yes, record this change" "$$ &No, skip this change" "$$ &Edit the change manually" "$$ &Skip remaining changes to this file" "$$ Record remaining changes to this &file" "$$ &Done, skip remaining changes and files" "$$ Record &all changes to all remaining files" "$$ &Quit, recording no changes" "$$ &?" ) r = ui.promptchoice("%s %s" % (query, resps)) ui.write("\n") if r == 8: # ? doc = gettext(record.__doc__) c = doc.find("::") + 2 for l in doc[c:].splitlines(): if l.startswith(" "): ui.write(l.strip(), "\n") continue elif r == 0: # yes ret = True elif r == 1: # no ret = False elif r == 2: # Edit patch if chunk is None: ui.write(_("cannot edit patch for whole file")) ui.write("\n") continue if chunk.header.binary(): ui.write(_("cannot edit patch for binary file")) ui.write("\n") continue # Patch comment based on the Git one (based on comment at end of # http://mercurial.selenic.com/wiki/RecordExtension) phelp = "---" + _( """ To remove '-' lines, make them ' ' lines (context). To remove '+' lines, delete them. Lines starting with # will be removed from the patch. If the patch applies cleanly, the edited hunk will immediately be added to the record list. If it does not apply cleanly, a rejects file will be generated: you can use that when you try again. If all lines of the hunk are removed, then the edit is aborted and the hunk is left unchanged. """ ) (patchfd, patchfn) = tempfile.mkstemp(prefix="hg-editor-", suffix=".diff", text=True) ncpatchfp = None try: # Write the initial patch f = os.fdopen(patchfd, "w") chunk.header.write(f) chunk.write(f) f.write("\n".join(["# " + i for i in phelp.splitlines()])) f.close() # Start the editor and wait for it to complete editor = ui.geteditor() util.system( '%s "%s"' % (editor, patchfn), environ={"HGUSER": ui.username()}, onerr=util.Abort, errprefix=_("edit failed"), out=ui.fout, ) # Remove comment lines patchfp = open(patchfn) ncpatchfp = cStringIO.StringIO() for line in patchfp: if not line.startswith("#"): ncpatchfp.write(line) patchfp.close() ncpatchfp.seek(0) newpatches = parsepatch(ncpatchfp) finally: os.unlink(patchfn) del ncpatchfp # Signal that the chunk shouldn't be applied as-is, but # provide the new patch to be used instead. ret = False elif r == 3: # Skip ret = skipfile = False elif r == 4: # file (Record remaining) ret = skipfile = True elif r == 5: # done, skip remaining ret = skipall = False elif r == 6: # all ret = skipall = True elif r == 7: # quit raise util.Abort(_("user quit")) return ret, skipfile, skipall, newpatches
def prompt(skipfile, skipall, query, chunk): """prompt query, and process base inputs - y/n for the rest of file - y/n for the rest - ? (help) - q (quit) Return True/False and possibly updated skipfile and skipall. """ newpatches = None if skipall is not None: return skipall, skipfile, skipall, newpatches if skipfile is not None: return skipfile, skipfile, skipall, newpatches while True: resps = _('[Ynesfdaq?]') choices = (_('&Yes, record this change'), _('&No, skip this change'), _('&Edit the change manually'), _('&Skip remaining changes to this file'), _('Record remaining changes to this &file'), _('&Done, skip remaining changes and files'), _('Record &all changes to all remaining files'), _('&Quit, recording no changes'), _('&?')) r = ui.promptchoice("%s %s" % (query, resps), choices) ui.write("\n") if r == 8: # ? doc = gettext(record.__doc__) c = doc.find('::') + 2 for l in doc[c:].splitlines(): if l.startswith(' '): ui.write(l.strip(), '\n') continue elif r == 0: # yes ret = True elif r == 1: # no ret = False elif r == 2: # Edit patch if chunk is None: ui.write(_('cannot edit patch for whole file')) ui.write("\n") continue if chunk.header.binary(): ui.write(_('cannot edit patch for binary file')) ui.write("\n") continue # Patch comment based on the Git one (based on comment at end of # http://mercurial.selenic.com/wiki/RecordExtension) phelp = '---' + _(""" To remove '-' lines, make them ' ' lines (context). To remove '+' lines, delete them. Lines starting with # will be removed from the patch. If the patch applies cleanly, the edited hunk will immediately be added to the record list. If it does not apply cleanly, a rejects file will be generated: you can use that when you try again. If all lines of the hunk are removed, then the edit is aborted and the hunk is left unchanged. """) (patchfd, patchfn) = tempfile.mkstemp(prefix="hg-editor-", suffix=".diff", text=True) ncpatchfp = None try: # Write the initial patch f = os.fdopen(patchfd, "w") chunk.header.write(f) chunk.write(f) f.write('\n'.join(['# ' + i for i in phelp.splitlines()])) f.close() # Start the editor and wait for it to complete editor = ui.geteditor() util.system("%s \"%s\"" % (editor, patchfn), environ={'HGUSER': ui.username()}, onerr=util.Abort, errprefix=_("edit failed"), out=ui.fout) # Remove comment lines patchfp = open(patchfn) ncpatchfp = cStringIO.StringIO() for line in patchfp: if not line.startswith('#'): ncpatchfp.write(line) patchfp.close() ncpatchfp.seek(0) newpatches = parsepatch(ncpatchfp) finally: os.unlink(patchfn) del ncpatchfp # Signal that the chunk shouldn't be applied as-is, but # provide the new patch to be used instead. ret = False elif r == 3: # Skip ret = skipfile = False elif r == 4: # file (Record remaining) ret = skipfile = True elif r == 5: # done, skip remaining ret = skipall = False elif r == 6: # all ret = skipall = True elif r == 7: # quit raise util.Abort(_('user quit')) return ret, skipfile, skipall, newpatches
def mimport(ui, repo, *patterns, **opts): """qimport patches from mailboxes You will be prompted for whether to qimport items from every patch group found in configured mailboxes (see 'hg help mbox' for details). If patterns are passed they will be used to filter out patch groups not matching either of them. Group duplicates (based on group or first patch title and sender) are ignored too. For each query, the following responses are possible: n - skip this patch group y - qimport this patch group d - done, import selected patches and quit q - quit, importing nothing ? - display help """ if opts['mbox']: paths = [opts['mbox']] else: paths = ui.config('mbox', 'paths', '').split(os.pathsep) paths = [p.strip() for p in paths if p] if not paths: raise util.Abort(_('no mailbox path configured')) patchmessages = getpatchmessages(paths) matcher = makematcher(patterns) selecteds = [] stop = False datefn = util.always if opts.get('date'): datefn = util.matchdate(opts.get('date')) orphans = opts.get('all') groups = filter(matcher, getgroups(patchmessages, datefn, orphans)) def cmpgroup(a, b): return -cmp(a[1][0].date(), b[1][0].date()) groups.sort(cmpgroup) groups = removeduplicates(groups) for intro, patches in groups: if intro: ui.status('%s\n' % intro.subject) for p in patches: ui.status(' %s\n' % p.subject) else: ui.status('%s\n' % patches[0].subject) while 1: allowed = _('[Nydq?]') choices = [_('&No'), _('&Yes'), _('&Done'), _('&Quit'), _('&?')] r = ui.promptchoice(_('import this group? %s ') % allowed, choices) if r == 4: doc = gettext(mimport.__doc__) c = doc.find(_('n - skip this patch group')) for l in doc[c:].splitlines(): if l: ui.write(l.strip(), '\n') continue elif r == 1: selecteds.append(patches) elif r == 2: stop = True elif r == 3: raise util.Abort(_('user quit')) break if stop: break ui.status('\n') importpatches(ui, repo, selecteds)