chgserver: add a structure for confighash and mtimehash
authorJun Wu <quark@fb.com>
Wed, 24 Feb 2016 20:45:47 +0000
changeset 28277 cdc6319f6a7d
parent 28276 b4ceadb2c439
child 28278 b1b22185c764
chgserver: add a structure for confighash and mtimehash confighash and mtimehash are often used together. This patch adds a simple structure called hashstate to store them. hashstate also has a handly method called fromui to calculate the hashes from a ui object.
hgext/chgserver.py
--- a/hgext/chgserver.py	Fri Feb 26 14:59:39 2016 +0000
+++ b/hgext/chgserver.py	Wed Feb 24 20:45:47 2016 +0000
@@ -144,6 +144,22 @@
             pass
     return _hashlist(map(trystat, paths))[:12]
 
+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)
+
 # copied from hgext/pager.py:uisetup()
 def _setuppagercmd(ui, options, cmd):
     if not ui.formatted():