tortoisehg: Cherry-pick patch for compatibility with mercurial >=7

Resolves #5512.
This commit is contained in:
Joey Riches 2025-04-23 23:46:41 +01:00
parent 1078ff70e4
commit e866c8bdc1
4 changed files with 71 additions and 3 deletions

View file

@ -0,0 +1,62 @@
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1735114105 18000
# Wed Dec 25 03:08:25 2024 -0500
# Branch stable
# Node ID 51422b882ab10948043ba531e85a02b2b43a404c
# Parent ae2a656dc16741b44e253eaa4a879ecb87f24291
hglib: handle moving `mercurial.rcutil` to `mercurial.configuration.rcutil`
The goofy definition stub is so that pytype doesn't merge an unknown with the
function signature that it sees in the new module, and type it as `Any`. If the
real definition changes, it should type the symbol as a union of the two
signatures, and hopefully that's good enough to notice the change.
diff --git a/tortoisehg/util/hglib.py b/tortoisehg/util/hglib.py
--- a/tortoisehg/util/hglib.py
+++ b/tortoisehg/util/hglib.py
@@ -14,6 +14,7 @@
import shlex
import sys
import time
+import typing
from typing import (
cast,
@@ -39,7 +40,6 @@
patch as patchmod,
pathutil,
pycompat,
- rcutil,
revset as revsetmod,
revsetlang,
scmutil,
@@ -64,6 +64,20 @@
ngettext as _ngettext,
)
+# pytype: disable=import-error
+try:
+ from mercurial.configuration import rcutil
+ userrcpath = rcutil.userrcpath # defeat demandimport
+except (ImportError, AttributeError):
+ # hg < 7.0 (0a81f3ef054c)
+ from mercurial import rcutil
+ userrcpath = rcutil.userrcpath
+
+ if typing.TYPE_CHECKING:
+ def userrcpath() -> list[bytes]:
+ raise NotImplementedError
+# pytype: enable=import-error
+
TYPE_CHECKING = getattr(pycompat, 'TYPE_CHECKING', False)
if TYPE_CHECKING:
@@ -102,7 +116,6 @@
extractpatch = patchmod.extract
tokenizerevspec = revsetlang.tokenize
-userrcpath = rcutil.userrcpath
# TODO: use unicode version globally
def _(message: str, context: str = '') -> bytes:

View file

@ -0,0 +1,5 @@
releases:
id: 4994
rss: ~
security:
cpe: ~ # Last checked 2025-04-23

View file

@ -1,6 +1,6 @@
name : tortoisehg
version : 6.6.3
release : 15
release : 16
source :
- https://www.mercurial-scm.org/release/tortoisehg/targz/tortoisehg-6.6.3.tar.gz : f69835379ba3d596990809b837cb684707d51e67bb9c0b0d319917491805bdeb
homepage : https://tortoisehg.bitbucket.io/
@ -18,6 +18,7 @@ rundeps :
- python-qscintilla
setup : |
sed -i "s|#!/usr/bin/env python|&3|" thg
%patch -p1 -i $pkgfiles/fix-rcutil-import.patch
build : |
%python3_setup
install : |

View file

@ -516,8 +516,8 @@
</Files>
</Package>
<History>
<Update release="15">
<Date>2024-03-23</Date>
<Update release="16">
<Date>2025-04-23</Date>
<Version>6.6.3</Version>
<Comment>Packaging update</Comment>
<Name>Joey Riches</Name>