Patchwork [3,of,5,V2] chgserver: add a structure for confighash and mtimehash

login
register
mail settings
Submitter Jun Wu
Date Feb. 26, 2016, 3:36 p.m.
Message ID <0515c0cdf7b24f5db072.1456500982@x1c>
Download mbox | patch
Permalink /patch/13414/
State Superseded
Commit cdc6319f6a7d620d4157065bdf7dfe222b662f4b
Delegated to: Yuya Nishihara
Headers show

Comments

Jun Wu - Feb. 26, 2016, 3:36 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1456346747 0
#      Wed Feb 24 20:45:47 2016 +0000
# Node ID 0515c0cdf7b24f5db0727f2bc2eb4f83526e0caf
# Parent  3172be958b9c1244a98f9833235cd7d9cfdf2373
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.

Patch

diff --git a/hgext/chgserver.py b/hgext/chgserver.py
--- a/hgext/chgserver.py
+++ b/hgext/chgserver.py
@@ -139,6 +139,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():