Add debug-sync option

This is basically just so a developer can turn down the chatty
sync operations that are normally going on and just see the
minimum interactive sync operations.  It's not something that
should be used normally (reviews may not be uploaded, etc).

Change-Id: I9b891366783a18c2896ac759ed4cb855beff906b
This commit is contained in:
James E. Blair 2016-02-06 09:07:02 -08:00
parent 4eef0452d5
commit 068e83b9ed
2 changed files with 12 additions and 10 deletions

View File

@ -206,9 +206,11 @@ class ProjectCache(object):
class App(object):
simple_change_search = re.compile('^(\d+|I[a-fA-F0-9]{40})$')
def __init__(self, server=None, palette='default', keymap='default',
debug=False, verbose=False, disable_sync=False,
fetch_missing_refs=False, path=config.DEFAULT_CONFIG_PATH):
def __init__(self, server=None, palette='default',
keymap='default', debug=False, verbose=False,
disable_sync=False, disable_background_sync=False,
fetch_missing_refs=False,
path=config.DEFAULT_CONFIG_PATH):
self.server = server
self.config = config.Config(server, palette, keymap, path)
if debug:
@ -243,7 +245,7 @@ class App(object):
self.config.keymap.updateCommandMap()
self.search = search.SearchCompiler(self.config.username)
self.db = db.Database(self, self.config.dburi, self.search)
self.sync = sync.Sync(self)
self.sync = sync.Sync(self, disable_background_sync)
self.screens = []
self.status = StatusHeader(self)
@ -800,6 +802,8 @@ def main():
help='enable debug logging')
parser.add_argument('--no-sync', dest='no_sync', action='store_true',
help='disable remote syncing')
parser.add_argument('--debug-sync', dest='debug_sync', action='store_true',
help='disable most background sync tasks for debugging')
parser.add_argument('--fetch-missing-refs', dest='fetch_missing_refs',
action='store_true',
help='fetch any refs missing from local repos')
@ -821,7 +825,7 @@ def main():
help='the server to use (as specified in config file)')
args = parser.parse_args()
g = App(args.server, args.palette, args.keymap, args.debug, args.verbose,
args.no_sync, args.fetch_missing_refs, args.path)
args.no_sync, args.debug_sync, args.fetch_missing_refs, args.path)
g.run()

View File

@ -1292,9 +1292,7 @@ class VacuumDatabaseTask(Task):
session.vacuum()
class Sync(object):
_quiet_debug_mode = False
def __init__(self, app):
def __init__(self, app, disable_background_sync):
self.user_agent = 'Gertty/%s %s' % (gertty.version.version_info.release_string(),
requests.utils.default_user_agent())
self.version = (0, 0, 0)
@ -1312,8 +1310,8 @@ class Sync(object):
self.auth = authclass(
self.app.config.username, self.app.config.password)
self.submitTask(GetVersionTask(HIGH_PRIORITY))
if not self._quiet_debug_mode:
self.submitTask(SyncOwnAccountTask(HIGH_PRIORITY))
self.submitTask(SyncOwnAccountTask(HIGH_PRIORITY))
if not disable_background_sync:
self.submitTask(CheckReposTask(HIGH_PRIORITY))
self.submitTask(UploadReviewsTask(HIGH_PRIORITY))
self.submitTask(SyncProjectListTask(HIGH_PRIORITY))