[PATCH 7 of 9] chgserver: remove hashstate.fromui
Jun Wu
quark at fb.com
Sun Nov 13 16:55:51 EST 2016
# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1479072907 0
# Sun Nov 13 21:35:07 2016 +0000
# Node ID 27827ad1ff25161b919f46eb3e370d21172a9285
# Parent 2b3091653f9a1f5ed2caef4b7205e5e6dacdad30
chgserver: remove hashstate.fromui
Previously we have to construct a "hashstate" object using a "ui" object, by
calling "hashstate.fromui". It's actually more suitable for "__init__", and
we are depending less on "ui" (do not need to re-read config in "validate")
so drop "fromui" to make the code cleaner.
diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -132,5 +132,5 @@ def _confighash(ui):
return sectionhash[:6] + envhash[:6]
-def _getmtimepaths(ui):
+def _getmtimepaths():
"""get a list of paths that should be checked to detect change
@@ -182,17 +182,8 @@ def _mtimehash(paths):
class hashstate(object):
"""a structure storing confighash, mtimehash, paths used for mtimehash"""
- def __init__(self, confighash, mtimehash, mtimepaths):
- self.confighash = confighash
- self.mtimehash = mtimehash
- self.mtimepaths = mtimepaths
-
- @staticmethod
- def fromui(ui, mtimepaths=None):
- if mtimepaths is None:
- mtimepaths = _getmtimepaths(ui)
- confighash = _confighash(ui)
- mtimehash = _mtimehash(mtimepaths)
- _log('confighash = %s mtimehash = %s\n' % (confighash, mtimehash))
- return hashstate(confighash, mtimehash, mtimepaths)
+ def __init__(self, ui, confighash=None, mtimehash=None, mtimepaths=None):
+ self.confighash = confighash or _confighash(ui)
+ self.mtimehash = mtimehash or _getmtimepaths()
+ self.mtimepaths = mtimepaths or _mtimehash(self.mtimepaths)
def _newchgui(srcui, csystem):
@@ -427,5 +418,5 @@ class chgcmdserver(commandserver.server)
self.cresult.write('exit 255')
return
- newhash = hashstate.fromui(lui, self.hashstate.mtimepaths)
+ newhash = hashstate(ui=lui, mtimepaths=self.hashstate.mtimepaths)
insts = []
if newhash.mtimehash != self.hashstate.mtimehash:
@@ -508,5 +499,5 @@ class chgunixservicehandler(object):
self._realaddress = address
return
- self._hashstate = hashstate.fromui(self.ui)
+ self._hashstate = hashstate(ui=self.ui)
self._realaddress = _hashaddress(address, self._hashstate.confighash)
More information about the Mercurial-devel
mailing list