Show More
@@ -58,6 +58,45 b" testedwith = 'internal'" | |||||
58 |
|
58 | |||
59 | _log = commandserver.log |
|
59 | _log = commandserver.log | |
60 |
|
60 | |||
|
61 | def _hashlist(items): | |||
|
62 | """return sha1 hexdigest for a list""" | |||
|
63 | return util.sha1(str(items)).hexdigest() | |||
|
64 | ||||
|
65 | # sensitive config sections affecting confighash | |||
|
66 | _configsections = ['extensions'] | |||
|
67 | ||||
|
68 | # sensitive environment variables affecting confighash | |||
|
69 | _envre = re.compile(r'''\A(?: | |||
|
70 | CHGHG | |||
|
71 | |HG.* | |||
|
72 | |LANG(?:UAGE)? | |||
|
73 | |LC_.* | |||
|
74 | |LD_.* | |||
|
75 | |PATH | |||
|
76 | |PYTHON.* | |||
|
77 | |TERM(?:INFO)? | |||
|
78 | |TZ | |||
|
79 | )\Z''', re.X) | |||
|
80 | ||||
|
81 | def _confighash(ui): | |||
|
82 | """return a quick hash for detecting config/env changes | |||
|
83 | ||||
|
84 | confighash is the hash of sensitive config items and environment variables. | |||
|
85 | ||||
|
86 | for chgserver, it is designed that once confighash changes, the server is | |||
|
87 | not qualified to serve its client and should redirect the client to a new | |||
|
88 | server. different from mtimehash, confighash change will not mark the | |||
|
89 | server outdated and exit since the user can have different configs at the | |||
|
90 | same time. | |||
|
91 | """ | |||
|
92 | sectionitems = [] | |||
|
93 | for section in _configsections: | |||
|
94 | sectionitems.append(ui.configitems(section)) | |||
|
95 | sectionhash = _hashlist(sectionitems) | |||
|
96 | envitems = [(k, v) for k, v in os.environ.iteritems() if _envre.match(k)] | |||
|
97 | envhash = _hashlist(sorted(envitems)) | |||
|
98 | return sectionhash[:6] + envhash[:6] | |||
|
99 | ||||
61 | # copied from hgext/pager.py:uisetup() |
|
100 | # copied from hgext/pager.py:uisetup() | |
62 | def _setuppagercmd(ui, options, cmd): |
|
101 | def _setuppagercmd(ui, options, cmd): | |
63 | if not ui.formatted(): |
|
102 | if not ui.formatted(): |
General Comments 0
You need to be logged in to leave comments.
Login now