D11728: dirstate: use a single closure for get_flags
marmoute created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY The previous code was overlooking fallback when neither symlink not exec was supported. The number of "variants" is getting too high, so I am consolidating this in a single closure that should be easier to maintains. This also ensure that fallback flags are always taken into account. (they are not user code yet, but small experimentation shown that the feature was working as intended.) A a small side effect we need to check for symlink support more lazily and this show up in the test in a couple of places. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11728 AFFECTED FILES mercurial/dirstate.py tests/test-share.t tests/test-subrepo.t CHANGE DETAILS diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t --- a/tests/test-subrepo.t +++ b/tests/test-subrepo.t @@ -1275,8 +1275,8 @@ ../shared/subrepo-2/.hg/sharedpath ../shared/subrepo-2/.hg/wcache ../shared/subrepo-2/.hg/wcache/checkisexec (execbit !) - ../shared/subrepo-2/.hg/wcache/checklink (symlink !) - ../shared/subrepo-2/.hg/wcache/checklink-target (symlink !) + ../shared/subrepo-2/.hg/wcache/checklink (symlink no-rust !) + ../shared/subrepo-2/.hg/wcache/checklink-target (symlink no-rust !) ../shared/subrepo-2/.hg/wcache/manifestfulltextcache (reporevlogstore !) ../shared/subrepo-2/file $ hg -R ../shared in diff --git a/tests/test-share.t b/tests/test-share.t --- a/tests/test-share.t +++ b/tests/test-share.t @@ -47,8 +47,8 @@ [1] $ ls -1 .hg/wcache || true checkisexec (execbit !) - checklink (symlink !) - checklink-target (symlink !) + checklink (symlink no-rust !) + checklink-target (symlink no-rust !) manifestfulltextcache (reporevlogstore !) $ ls -1 ../repo1/.hg/cache branch2-served diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -242,68 +242,52 @@ return self._rootdir + f def flagfunc(self, buildfallback): -if not (self._checklink and self._checkexec): -fallback = buildfallback() + +# small hack to cache the result of buildfallback() +fallback_func = [] -def check_both(x): -"""This platform supports symlinks and exec permissions""" +def get_flags(x): +entry = None +fallback_value = None try: st = os.lstat(self._join(x)) +except OSError: +return b'' + +if self._checklink: if util.statislink(st): return b'l' +else: +entry = self.get_entry(x) +if entry.has_fallback_symlink: +if entry.fallback_symlink: +return b'l' +else: +if not fallback_func: +fallback_func.append(buildfallback()) +fallback_value = fallback_func[0](x) +if b'l' in fallback_value: +return b'l' + +if self._checkexec: if util.statisexec(st): return b'x' -except OSError: -pass -return b'' - -def check_link(x): -"""This platform only supports symlinks""" -if os.path.islink(self._join(x)): -return b'l' -entry = self.get_entry(x) -if entry.has_fallback_exec: -if entry.fallback_exec: -return b'x' -elif b'x' in fallback(x): -return b'x' +else: +if entry is None: +entry = self.get_entry(x) +if entry.has_fallback_exec: +if entry.fallback_exec: +return b'x' +else: +if fallback_value is None: +if not fallback_func: +fallback_func.append(buildfallback()) +fallback_value = fallback_func[0](x) +if b'x' in fallback_value: +return b'x' return b'' -def check_exec(x): -"""This platform only supports exec permissions""" -if b'l' in fallback(x): -return b'l' -entry = self.get_entry(x) -if entry.has_fallback_symlink: -if entry.fallback_symlink: -return b'l' -if util.isexec(self._join(x)): -return b'x' -return b'' - -def check_fallback(x): -"""This platform supports neither symlinks nor exec permissions, so -check the fallback in the dirstate if it exists, otherwise figure it -
D11729: dirstate: make sure that status does not overlook the status flags
marmoute created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY Without this extra checks, file with fallback flags change as the only change would be overlooked. In the future we might store proper data in the dirstate and do less lookup. However, for now this will do to make sure that 6.0 is forward compatible with later version. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11729 AFFECTED FILES mercurial/dirstate.py mercurial/helptext/internals/dirstate-v2.txt CHANGE DETAILS diff --git a/mercurial/helptext/internals/dirstate-v2.txt b/mercurial/helptext/internals/dirstate-v2.txt --- a/mercurial/helptext/internals/dirstate-v2.txt +++ b/mercurial/helptext/internals/dirstate-v2.txt @@ -523,12 +523,18 @@ this indicates whether the file’s own is expected to have execute permission. +Beware that on system without fs support for this information, the value +stored in the dirstate might be wrong and should not be relied on. + `MODE_IS_SYMLINK` Must be unset if `HAS_MODE_AND_SIZE` is unset. If `HAS_MODE_AND_SIZE` is set, this indicates whether the file is expected to be a symlink as opposed to a normal file. +Beware that on system without fs support for this information, the value +stored in the dirstate might be wrong and should not be relied on. + `EXPECTED_STATE_IS_MODIFIED` Must be unset for untracked nodes. For: diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -1352,6 +1352,7 @@ mexact = match.exact dirignore = self._dirignore checkexec = self._checkexec +checklink = self._checklink copymap = self._map.copymap lastnormaltime = self._lastnormaltime @@ -1384,7 +1385,17 @@ elif t.removed: radd(fn) elif t.tracked: -if ( +if not checklink and t.has_fallback_symlink: +# If the file system does not support symlink, the mode +# might not be correctly stored in the dirstate, so do not +# trust it. +ladd(fn) +elif not checkexec and t.has_fallback_exec: +# If the file system does not support exec bits, the mode +# might not be correctly stored in the dirstate, so do not +# trust it. +ladd(fn) +elif ( size >= 0 and ( (size != st.st_size and size != st.st_size & _rangemask) To: marmoute, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Heptapod mini-sprint on Nov 5th
Dear users and developers, The next occurrence of monthly remote mini-sprints organized by Octobus, will be about Heptapod (GitLab + Mercurial). The rallying point will be https://mattermost.heptapod.net, our chat system. There is no fixed topic, you may bring your own. Of course I have a few ideas, but I don't want to force anything. Our timezone is, or rather will be, CET, or if you prefer UTC+1. Of course people from other timezones are welcome to join when they can! I'll be on leave until Nov 3rd, watching the mailing-lists only very loosely. Best, -- Georges Racinet https://octobus.net, https://heptapod.net GPG: BF5456F4DC625443849B6E58EE20CA44EF691D39, sur serveurs publics ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D11726: backout: backed out changeset f78d8b8c46d7
Alphare created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This and the following backout exist because the original patches break the Windows CI for some yet unknown reason. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11726 AFFECTED FILES setup.py CHANGE DETAILS diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -780,6 +780,9 @@ pythonlib = None +dir = os.path.dirname(self.get_ext_fullpath('dummy')) +self.hgtarget = os.path.join(dir, 'hg') + if getattr(sys, 'dllhandle', None): # Different Python installs can have different Python library # names. e.g. the official CPython distribution uses pythonXY.dll @@ -805,6 +808,35 @@ ) pythonlib = dllbasename[:-4] +# Copy the pythonXY.dll next to the binary so that it runs +# without tampering with PATH. +fsdecode = lambda x: x +if sys.version_info[0] >= 3: +fsdecode = os.fsdecode +dest = os.path.join( +os.path.dirname(self.hgtarget), +fsdecode(dllbasename), +) + +if not os.path.exists(dest): +shutil.copy(buf.value, dest) + +# Also overwrite python3.dll so that hgext.git is usable. +# TODO: also handle the MSYS flavor +if sys.version_info[0] >= 3: +python_x = os.path.join( +os.path.dirname(fsdecode(buf.value)), +"python3.dll", +) + +if os.path.exists(python_x): +dest = os.path.join( +os.path.dirname(self.hgtarget), +os.path.basename(python_x), +) + +shutil.copy(python_x, dest) + if not pythonlib: log.warn( 'could not determine Python DLL filename; assuming pythonXY' @@ -827,8 +859,6 @@ output_dir=self.build_temp, macros=macros, ) -dir = os.path.dirname(self.get_ext_fullpath('dummy')) -self.hgtarget = os.path.join(dir, 'hg') self.compiler.link_executable( objects, self.hgtarget, libraries=[], output_dir=self.build_temp ) To: Alphare, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D11727: backout: backed out changeset 67d14d4e036c
Alphare created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY Same as the previous patch, this breaks the Windows CI for some yet unknown reason. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11727 AFFECTED FILES mercurial/exewrapper.c CHANGE DETAILS diff --git a/mercurial/exewrapper.c b/mercurial/exewrapper.c --- a/mercurial/exewrapper.c +++ b/mercurial/exewrapper.c @@ -29,134 +29,6 @@ #define _countof(array) (sizeof(array) / sizeof(array[0])) #endif -#if PY_MAJOR_VERSION >= 3 - -#pragma comment(lib, "Advapi32.lib") - -/* python.org installations */ -#define CORE_PATH L"SOFTWARE\\Python\\PythonCore" - -/* Microsoft Store installations */ -#define LOOKASIDE_PATH \ - L"SOFTWARE\\Microsoft\\AppModel\\Lookaside\\user\\Software\\Python\\" \ - L"PythonCore" - -static wchar_t *_locate_python_for_key(HKEY root, LPCWSTR subkey, size_t *size) -{ - wchar_t installPathKey[512]; - wchar_t *executable = NULL; - DWORD type; - DWORD sz = 0; - HKEY ip_key; - LSTATUS status; - - _snwprintf_s(installPathKey, sizeof(installPathKey), _TRUNCATE, -L"%ls\\%d.%d\\InstallPath", subkey, PY_MAJOR_VERSION, -PY_MINOR_VERSION); - - status = - RegOpenKeyExW(root, installPathKey, 0, KEY_QUERY_VALUE, &ip_key); - - if (status != ERROR_SUCCESS) - return NULL; - - status = RegQueryValueExW(ip_key, L"ExecutablePath", NULL, &type, - (LPBYTE)executable, &sz); - if (status == ERROR_SUCCESS) { - /* Allocate extra space so path\to\python.exe can be converted -* to path\to\python39.dll + NUL. -*/ - *size = sz + sizeof(_T(HGPYTHONLIB ".dll")) + sizeof(wchar_t); - executable = malloc(*size); - - if (executable) { - status = - RegQueryValueExW(ip_key, L"ExecutablePath", NULL, -&type, (LPBYTE)executable, &sz); - - if (status != ERROR_SUCCESS) { - free(executable); - executable = NULL; - } else { - /* Not all values are stored NUL terminated */ - executable[sz] = L'\0'; - } - } - } - - RegCloseKey(ip_key); - return executable; -} - -static HMODULE load_system_py3(void) -{ - wchar_t *subkeys[] = {CORE_PATH, LOOKASIDE_PATH}; - HKEY roots[] = {HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER}; - - /* Give priority to python.org installs, because MS Store installs can -* break with user profile corruption, and also use some NTFS feature -* that MSYS doesn't understand. -*/ - for (int s = 0; s < _countof(subkeys); s++) { - for (int r = 0; r < _countof(roots); r++) { - size_t size = 0; - wchar_t *py = - _locate_python_for_key(roots[r], subkeys[s], &size); - wchar_t *cut = NULL; - HMODULE pydll; - - if (!py) { - continue; - } - - /* Cut off the python executable component */ - cut = wcsrchr(py, L'\\'); - if (cut == NULL) { - free(py); - continue; - } - *cut = 0; - - wcscat_s(py, size, _T("\\" HGPYTHONLIB ".dll")); - - pydll = LoadLibrary(py); - - /* Also load python3.dll, so we don't pick up a random -* one on PATH. We don't search {sys.prefix}\DLLs like -* python.exe because this is commented as "not been a -* normal install layout for a while", and don't search -* LOAD_LIBRARY_SEARCH_APPLICATION_DIR because it's not -* clear what the use case is. -*/ - if (pydll != NULL) { - HANDLE py3dll = NULL; - - *cut = 0; - wcscat_s(py, size, L"\\python3.dll"); - - py3dll = LoadLibrary(py); - if (py3dll == NULL) { - const char *err; - err = "failed to load python3.dll " - "for " HGPYTHONLIB ".dll"; -
D11725: windows: use raw string in test log paths
Alphare created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY Otherwise the backslashes will work as escapes on Windows and break everything. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11725 AFFECTED FILES tests/test-fix.t CHANGE DETAILS diff --git a/tests/test-fix.t b/tests/test-fix.t --- a/tests/test-fix.t +++ b/tests/test-fix.t @@ -1785,7 +1785,7 @@ $ cat >> $LOGGER < # Appends the input file's name to the log file. > import sys - > with open('$LOGFILE', 'a') as f: + > with open(r'$LOGFILE', 'a') as f: > f.write(sys.argv[1] + '\n') > sys.stdout.write(sys.stdin.read()) > EOF To: Alphare, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel