[PATCH 1 of 2 V3] chgserver: add utilities to calculate mtimehash
Yuya Nishihara
yuya at tcha.org
Sun Feb 28 10:20:09 EST 2016
On Sun, 28 Feb 2016 12:17:25 +0000, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1456498779 0
> # Fri Feb 26 14:59:39 2016 +0000
> # Node ID 94fd1cecd935b7ce05a5b435ddb82a1eb610ec85
> # Parent 10eaae94523c790d7b77c52a4cb4bfcf406021ef
> chgserver: add utilities to calculate mtimehash
Pushed modified version to the clowncopter, thanks!
> +def _getmtimepaths(ui):
> + """get a list of paths that should be checked to detect change
> +
> + The list will include:
> + - extensions (will not cover all files for complex extensions)
> + - mercurial/__version__.py
> + - hg binary
> + - python binary
> + """
> + modules = [m for n, m in extensions.extensions(ui)]
> + try:
> + from mercurial import __version__
> + modules.append(__version__)
> + except ImportError:
> + pass
> + files = [sys.executable, util.hgcmd()]
> + for m in modules:
> + try:
> + files.append(inspect.getabsfile(m))
> + except TypeError:
> + pass
> + return sorted(set(files))
I've removed util.hgcmd() because
a) we have __version__.py
b) util.hgcmd() returns a list of command args, which isn't hashable
(e.g. ['/usr/bin/hg'] on Unix, and ['python', '\\path\\to\\hg'] on Windows)
I noticed that inspect.getabsfile() is undocumented. But using getabsfile()
won't cause problems, since it exists in Python 2.6, 2.7, and 3.5.
https://bugs.python.org/issue12317
More information about the Mercurial-devel
mailing list