[PATCH 4 of 4 V2] chgserver: start background preloading thread
Jun Wu
quark at fb.com
Wed Feb 22 21:16:11 EST 2017
# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1487814470 28800
# Wed Feb 22 17:47:50 2017 -0800
# Node ID 5c44925eab9a424369967e852b05f42443eac3a6
# Parent 28571825744fb4f4b424385f55afa9484532ef43
# Available At https://bitbucket.org/quark-zju/hg-draft
# hg pull https://bitbucket.org/quark-zju/hg-draft -r 5c44925eab9a
chgserver: start background preloading thread
A new boolean option chgserver.stateful is added. If set to True, chg master
will start the background repo preloading thread and becomes stateful.
diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -37,4 +37,7 @@ Config
# whether to skip config or env change checks
skiphash = False
+
+ # whether to be stateful, and preload repo state in background
+ stateful = False
"""
@@ -582,4 +585,26 @@ class chgunixservicehandler(object):
self._hashstate, self._baseaddress)
+class chgunixforkingservice(commandserver.unixforkingservice):
+ """like unixforkingservice with an optional chgcache.preloader"""
+
+ def __init__(self, ui, repo, opts, handler=None):
+ super(chgunixforkingservice, self).__init__(ui, repo, opts, handler)
+ if self.ui.configbool('chgserver', 'stateful'):
+ self._preloader = chgcache.preloader()
+ else:
+ self._preloader = None
+
+ def init(self):
+ super(chgunixforkingservice, self).init()
+ if self._preloader is not None:
+ self.ui.debug('starting background preloader\n')
+ self._preloader.start()
+
+ def _cleanup(self):
+ super(chgunixforkingservice, self)._cleanup()
+ if self._preloader is not None:
+ self.ui.debug('stopping background preloader\n')
+ self._preloader.stop()
+
def chgunixservice(ui, repo, opts):
# CHGINTERNALMARK is temporarily set by chg client to detect if chg will
@@ -592,3 +617,3 @@ def chgunixservice(ui, repo, opts):
ui.setconfig('bundle', 'mainreporoot', '', 'repo')
h = chgunixservicehandler(ui)
- return commandserver.unixforkingservice(ui, repo=None, opts=opts, handler=h)
+ return chgunixforkingservice(ui, repo=None, opts=opts, handler=h)
More information about the Mercurial-devel
mailing list