D352: chgserver: special handle __version__ in mtimehash (issue5653)
quark (Jun Wu)
phabricator at mercurial-scm.org
Fri Aug 11 18:27:35 UTC 2017
quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
It seems __version__.py may have content change without mtime change. Since
reading __version__.py is usually cheap, check its content instead of
stating it. This should make chg able to detect version change when the
package manager upgrades files with mtime preserved and size happens to be
unchanged.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D352
AFFECTED FILES
mercurial/chgserver.py
CHANGE DETAILS
diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -147,9 +147,14 @@
"""
def trystat(path):
try:
- st = os.stat(path)
- return (st.st_mtime, st.st_size)
- except OSError:
+ # sometimes __version__.py may change without stat change
+ # (issue5653), check its content instead.
+ if '__version__' in path:
+ return util.readfile(path)
+ else:
+ st = os.stat(path)
+ return (st.st_mtime, st.st_size)
+ except (OSError, IOError):
# could be ENOENT, EPERM etc. not fatal in any case
pass
return _hashlist(map(trystat, paths))[:12]
To: quark, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list