Imply single-threaded mode with -d(ebug) command line option

All invocations of -d will imply the single-threaded mode unless one of
the debug options is "thread" (in which case it would be senseless to
force single-threaded mode).

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Sebastian Spaeth 2011-01-12 11:15:13 +01:00 committed by Nicolas Sebrecht
parent b81b7d6001
commit f7e9d9525d

View File

@ -97,21 +97,18 @@ class OfflineImap:
"%default.") "%default.")
parser.add_option("-d", dest="debugtype", metavar="type1,[type2...]", parser.add_option("-d", dest="debugtype", metavar="type1,[type2...]",
help= help="""Enables debugging for OfflineIMAP. This is useful
"Enables debugging for OfflineIMAP. This is useful " if you are to track down a malfunction or figure out what is
"if you are trying to track down a malfunction or " going on under the hood. This option requires one or more
"figure out what is going on under the hood. It is recommended " debugtypes, separated by commas. These define what exactly
"to use this with -1 in order to make the " will be debugged, and so far include two options: imap, thread,
"results more sensible. This option requires one or more " maildir or ALL. The imap option will enable IMAP protocol
"debugtypes, separated by commas. " stream and parsing debugging. Note that the output may contain
"These define what exactly will be debugged, " passwords, so take care to remove that from the debugging
"and so far include two options: imap, " output before sending it to anyone else. The maildir option
"maildir or ALL. The imap option will enable IMAP protocol " will enable debugging for certain Maildir operations.
"stream and parsing debugging. Note that the output " The use of any debug option (unless 'thread' is included),
"may contain passwords, so take care to remove that " implies the single-thread option -1.""")
"from the debugging output before sending it to anyone else. "
"The maildir option will enable debugging "
"for certain Maildir operations.")
parser.add_option("-l", dest="logfile", metavar="FILE", parser.add_option("-l", dest="logfile", metavar="FILE",
help="Log to FILE") help="Log to FILE")
@ -213,6 +210,12 @@ class OfflineImap:
if options.debugtype: if options.debugtype:
if options.debugtype.lower() == 'all': if options.debugtype.lower() == 'all':
options.debugtype = 'imap,maildir,thread' options.debugtype = 'imap,maildir,thread'
#force single threading?
if not ('thread' in options.debugtype.split(',') \
and options.singlethreading):
ui._msg("Debug mode: Forcing to singlethreaded.")
options.singlethreaded = True
for type in options.debugtype.split(','): for type in options.debugtype.split(','):
type = type.strip() type = type.strip()
ui.add_debug(type) ui.add_debug(type)