[PATCH 1 of 6] hgversion: bump required Mercurial version to 5.8

8 views
Skip to first unread message

Yuya Nishihara

unread,
Jul 11, 2021, 6:51:52 AM7/11/21
to thg...@googlegroups.com
# HG changeset patch
# User Yuya Nishihara <yu...@tcha.org>
# Date 1625997133 -32400
# Sun Jul 11 18:52:13 2021 +0900
# Node ID 98380a5a5bd141d9b2ff276ca269d471037c6ab9
# Parent c2bde63d7559abba0a2ccbe82ef3ccc13cb2d9f4
hgversion: bump required Mercurial version to 5.8

diff --git a/tortoisehg/util/hgversion.py b/tortoisehg/util/hgversion.py
--- a/tortoisehg/util/hgversion.py
+++ b/tortoisehg/util/hgversion.py
@@ -19,7 +19,7 @@ try:
except ImportError:
hgversion = None

-testedwith = b'5.7 5.8'
+testedwith = b'5.8 5.9'

def checkhgversion(v):
"""range check the Mercurial version"""

Yuya Nishihara

unread,
Jul 11, 2021, 6:51:52 AM7/11/21
to thg...@googlegroups.com
# HG changeset patch
# User Yuya Nishihara <yu...@tcha.org>
# Date 1625997753 -32400
# Sun Jul 11 19:02:33 2021 +0900
# Node ID 8cad17c4d34657f1e4943ddfa1f4155c03e89f31
# Parent 98380a5a5bd141d9b2ff276ca269d471037c6ab9
wconfig: drop compatibility layer for hg 5.7

I intentionally leave the wrapper functions with comments as I think they
will give a hint for future refactoring.

diff --git a/tests/wconfig_test.py b/tests/wconfig_test.py
--- a/tests/wconfig_test.py
+++ b/tests/wconfig_test.py
@@ -53,31 +53,23 @@ def writetempfile(s):
os.close(fd)
return path

-if getattr(config.config, 'alter', None):
- # hg >= 5.8 (a3dced4b7b04): config dict is no longer a plain
- # {key: value} dict, but has metadata for each key.
+# Since hg 5.8 (a3dced4b7b04), config dict is no longer a plain
+# {key: value} dict, but has metadata for each key.

- def metadict(src):
- return {k: metavalue(v) for k, v in src.items()}
+def metadict(src):
+ return {k: metavalue(v) for k, v in src.items()}

- def metavalue(v):
- return (v, b'', 0)
-
- def plaindict(src):
- return {k: plainvalue(v) for k, v in src.items()}
+def metavalue(v):
+ return (v, b'', 0)

- def plainvalue(v):
- value, source, level = v
- assert isinstance(source, bytes)
- assert isinstance(level, int)
- return value
+def plaindict(src):
+ return {k: plainvalue(v) for k, v in src.items()}

-else:
- metadict = dict
- metavalue = pycompat.identity
- plaindict = dict
- plainvalue = pycompat.identity
-
+def plainvalue(v):
+ value, source, level = v
+ assert isinstance(source, bytes)
+ assert isinstance(level, int)
+ return value

def with_rconfig(f):
f.__test__ = True
diff --git a/tortoisehg/util/wconfig.py b/tortoisehg/util/wconfig.py
--- a/tortoisehg/util/wconfig.py
+++ b/tortoisehg/util/wconfig.py
@@ -53,23 +53,15 @@ if _hasiniparse:
r'(?P<sep>=\s*)'
r'(?P<value>.*)$')

-if getattr(config_mod.config, 'alter', None):
- # hg >= 5.8 (a3dced4b7b04): config dict is no longer a plain
- # {key: value} dict, but has metadata for each key.
-
- def _packvalue(config, value, source):
- return (value, source, config._current_source_level)
+# Since hg 5.8 (a3dced4b7b04), config dict is no longer a plain
+# {key: value} dict, but has metadata for each key.

- def _unpackvalue(packed):
- value, _source, _level = packed
- return value
+def _packvalue(config, value, source):
+ return (value, source, config._current_source_level)

-else:
- def _packvalue(config, value, source):
- return value
-
- def _unpackvalue(value):
- return value
+def _unpackvalue(packed):
+ value, _source, _level = packed
+ return value

class _wsortdict(object):
"""Wrapper for config.sortdict to record set/del operations"""

Yuya Nishihara

unread,
Jul 11, 2021, 6:51:54 AM7/11/21
to thg...@googlegroups.com
# HG changeset patch
# User Yuya Nishihara <yu...@tcha.org>
# Date 1625998745 -32400
# Sun Jul 11 19:19:05 2021 +0900
# Node ID 010d3b0ab6bfb52f6acf5cb49be287e9fdd67c3d
# Parent 8cad17c4d34657f1e4943ddfa1f4155c03e89f31
hgcommands: stop using deprecated ui.expandpath()

See hg 82366464190a, 3800a6aafb6f, etc. for the choice of substitutions.

diff --git a/tortoisehg/util/hgcommands.py b/tortoisehg/util/hgcommands.py
--- a/tortoisehg/util/hgcommands.py
+++ b/tortoisehg/util/hgcommands.py
@@ -20,6 +20,9 @@ from mercurial import (
sslutil,
util,
)
+from mercurial.utils import (
+ urlutil,
+)

from tortoisehg.util import (
hgversion,
@@ -49,7 +52,10 @@ def debuggethostfingerprint(ui, repo, so

Specify --insecure to disable SSL verification.
"""
- source = ui.expandpath(source)
+ # we have no idea if the source url is for pull or push, so let's assume
+ # 'pull' is more basic operation like other hg debug* commands.
+ source, _branches = urlutil.get_unique_pull_path(
+ b'debuggethostfingerprint', repo, ui, source)
u = util.url(source)
scheme = (u.scheme or b'').split(b'+')[-1]
host = u.host
@@ -78,7 +84,7 @@ def postinitskel(ui, repo, hooktype, res
assert hooktype == b'post-init', hooktype
if result:
return
- dest = ui.expandpath(pats and pats[0] or b'.')
+ _src, dest, _branch = urlutil.get_clone_path(ui, pats and pats[0] or b'.')
skel = ui.config(b'tortoisehg', b'initskel')
if skel:
# copy working tree from user-defined path if any

Yuya Nishihara

unread,
Jul 11, 2021, 6:51:55 AM7/11/21
to thg...@googlegroups.com
# HG changeset patch
# User Yuya Nishihara <yu...@tcha.org>
# Date 1625999645 -32400
# Sun Jul 11 19:34:05 2021 +0900
# Node ID 4f3a20e633546f9dfe452921b761e6db7a5fcf0a
# Parent 010d3b0ab6bfb52f6acf5cb49be287e9fdd67c3d
run: upgrade one of ui.expandpath() call to get_clone_path()

See hg e7d082e4ace6, which should be the copy source of our dispatcher.

diff --git a/tortoisehg/hgqt/run.py b/tortoisehg/hgqt/run.py
--- a/tortoisehg/hgqt/run.py
+++ b/tortoisehg/hgqt/run.py
@@ -30,6 +30,7 @@ from mercurial import (
from mercurial.utils import (
procutil,
stringutil,
+ urlutil,
)

from ..util import (
@@ -390,7 +391,7 @@ def runcommand(ui, args):
else:
path, bundle = s
cmdoptions[b'bundle'] = os.path.abspath(bundle)
- path = ui.expandpath(path)
+ path = urlutil.get_clone_path(ui, path)[0]
# TODO: replace by abspath() if chdir() isn't necessary
try:
os.chdir(path)

Yuya Nishihara

unread,
Jul 11, 2021, 6:51:57 AM7/11/21
to thg...@googlegroups.com
# HG changeset patch
# User Yuya Nishihara <yu...@tcha.org>
# Date 1625999729 -32400
# Sun Jul 11 19:35:29 2021 +0900
# Node ID 7080f27ebf4db1d6b07beeb0a97fa1463752ad10
# Parent 4f3a20e633546f9dfe452921b761e6db7a5fcf0a
run: drop misuse of ui.expandpath()

profiling.output should be a local filesystem path, not a repository URL.

diff --git a/tortoisehg/hgqt/run.py b/tortoisehg/hgqt/run.py
--- a/tortoisehg/hgqt/run.py
+++ b/tortoisehg/hgqt/run.py
@@ -455,7 +455,7 @@ def _runcommand(ui, options, cmd, cmdfun
output = ui.config(b'profiling', b'output')

if output:
- path = ui.expandpath(output)
+ path = util.expandpath(output)
ostream = open(path, 'wb')
else:
ostream = sys.stderr

Yuya Nishihara

unread,
Jul 11, 2021, 6:51:59 AM7/11/21
to thg...@googlegroups.com
# HG changeset patch
# User Yuya Nishihara <yu...@tcha.org>
# Date 1626000194 -32400
# Sun Jul 11 19:43:14 2021 +0900
# Node ID 50dbfa3689c2e5113e06ad8719099d6ceeb80e86
# Parent 7080f27ebf4db1d6b07beeb0a97fa1463752ad10
graph: add TODO comment on deprecated use of ui.expandpath() in ShallowFileDag

I have no idea which get_path() should be used here, and I'm not willing to
set up test environment for remotefilelog thingy. So let's leave it for now.

diff --git a/tortoisehg/hgqt/graph.py b/tortoisehg/hgqt/graph.py
--- a/tortoisehg/hgqt/graph.py
+++ b/tortoisehg/hgqt/graph.py
@@ -708,6 +708,7 @@ class ShallowFileDag(FileDag):
path = self.path

try:
+ # TODO: switch to one of the urlutil.get_*path() functions
dest = repo.ui.expandpath('default')
peer = hg.peer(repo, {}, dest)
except error.RepoError:

Yuya Nishihara

unread,
Jul 13, 2021, 6:57:47 AM7/13/21
to thg...@googlegroups.com
On Sun, 11 Jul 2021 19:51:30 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yu...@tcha.org>
> # Date 1625997133 -32400
> # Sun Jul 11 18:52:13 2021 +0900
> # Node ID 98380a5a5bd141d9b2ff276ca269d471037c6ab9
> # Parent c2bde63d7559abba0a2ccbe82ef3ccc13cb2d9f4
> hgversion: bump required Mercurial version to 5.8

Pushed.
Reply all
Reply to author
Forward
0 new messages