##// END OF EJS Templates
windows: continue looking at `%HOME%` for user config files with py3.8+...
windows: continue looking at `%HOME%` for user config files with py3.8+ The `%HOME%` variable is explicitly called out in `hg help config` as a location that is consulted when reading user files, but python stopped looking at it when expanding '~' in py3.8+.[1] Restore that old functionality by copying in the old implementation (and simplifying it to just use bytes). It could be simplfied further, since only '~' is passed, but I'm not sure yet if we need to make this a generic utility function on Windows. There are other uses of `os.path.expanduser()`, but this is the only case I know of that documents `%HOME%` usage. (The reason for removing it was that it typically isn't set, but it actually is set in MSYS and PowerShell, and `%HOME%` and `%USERPROFILE%` are different in MSYS. I could be convinced to just replace all uses with this as a general utility, so we don't have to think too hard about BC.) [1] https://bugs.python.org/issue36264 Differential Revision: https://phab.mercurial-scm.org/D9559

File last commit:

r44085:53607fd3 stable
r46709:224af780 default
Show More
mpatchbuild.py
40 lines | 1.0 KiB | text/x-python | PythonLexer
from __future__ import absolute_import
import cffi
import os
ffi = cffi.FFI()
mpatch_c = os.path.join(
os.path.join(os.path.dirname(__file__), '..', 'mpatch.c')
)
with open(mpatch_c) as f:
ffi.set_source(
"mercurial.cffi._mpatch", f.read(), include_dirs=["mercurial"]
)
ffi.cdef(
"""
struct mpatch_frag {
int start, end, len;
const char *data;
};
struct mpatch_flist {
struct mpatch_frag *base, *head, *tail;
};
extern "Python" struct mpatch_flist* cffi_get_next_item(void*, ssize_t);
int mpatch_decode(const char *bin, ssize_t len, struct mpatch_flist** res);
ssize_t mpatch_calcsize(size_t len, struct mpatch_flist *l);
void mpatch_lfree(struct mpatch_flist *a);
static int mpatch_apply(char *buf, const char *orig, size_t len,
struct mpatch_flist *l);
struct mpatch_flist *mpatch_fold(void *bins,
struct mpatch_flist* (*get_next_item)(void*, ssize_t),
ssize_t start, ssize_t end);
"""
)
if __name__ == '__main__':
ffi.compile()