[PATCH 2 of 5] hg72: fix find_cmd being moved to main_script in hg >= 7.2

15 views
Skip to first unread message

Antonio Muci

unread,
May 4, 2026, 4:52:33 PMMay 4
to thg...@googlegroups.com, a....@inwind.it
# HG changeset patch
# User Antonio Muci <a....@inwind.it>
# Date 1777674769 -7200
# Sat May 02 00:32:49 2026 +0200
# Branch stable
# Node ID 5592126afcb4b230c415838b7e1af7adafaca505
# Parent 6c0e690e3bb3d6e248612bde4cead6f4297364f4
hg72: fix find_cmd being moved to main_script in hg >= 7.2

The previous commit fixed the first TortoiseHg startup error. This commit fixes
the one that pops out immediately after that.

Incompatibility introduced on 2025-08-06 in mercurial changeset
d32b62bf63c8614b2d88796c9e5feeda25fa3fdc ("cycle-breaking: extract command
finding logic in its own module").

diff --git a/tortoisehg/hgqt/clone.py b/tortoisehg/hgqt/clone.py
--- a/tortoisehg/hgqt/clone.py
+++ b/tortoisehg/hgqt/clone.py
@@ -32,7 +32,6 @@ from .qtgui import (
)

from mercurial import (
- cmdutil,
commands,
hg,
pycompat,
@@ -65,7 +64,7 @@ if typing.TYPE_CHECKING:


def _startrev_available() -> bool:
- entry = cmdutil.findcmd(b'clone', commands.table)[1]
+ entry = hglib.find_cmd(b'clone', commands.table)[1]
longopts = {e[1] for e in entry[1]}
return b'startrev' in longopts

diff --git a/tortoisehg/hgqt/run.py b/tortoisehg/hgqt/run.py
--- a/tortoisehg/hgqt/run.py
+++ b/tortoisehg/hgqt/run.py
@@ -19,7 +19,6 @@ from typing import (
)

from mercurial import (
- cmdutil,
encoding,
error,
extensions,
@@ -308,7 +307,7 @@ def _parse(ui, args):
else:
alias, args = b'workbench', []

- aliases, i = cmdutil.findcmd(alias, table, ui.config(b"ui", b"strict"))
+ aliases, i = hglib.find_cmd(alias, table, ui.config(b"ui", b"strict"))
for a in aliases:
if a.startswith(alias):
alias = a
@@ -842,7 +841,7 @@ def help_(ui, name: Optional[bytes]=None
ui.write(b'\n')

try:
- aliases, i = cmdutil.findcmd(name, table, False)
+ aliases, i = hglib.find_cmd(name, table, False)
except error.AmbiguousCommand as inst:
prefix = inst.prefix
select = lambda c: c.startswith(prefix)
diff --git a/tortoisehg/util/hglib.py b/tortoisehg/util/hglib.py
--- a/tortoisehg/util/hglib.py
+++ b/tortoisehg/util/hglib.py
@@ -79,9 +79,11 @@ except (ImportError, AttributeError):

try:
# mercurial >= 7.2
+ from mercurial.main_script.cmd_finder import find_cmd
from mercurial.main_script.options import parse_config_opts
from mercurial.main_script.options import early_parse_opts
except ModuleNotFoundError:
+ from mercurial.cmdutil import findcmd as find_cmd
from mercurial.dispatch import _parseconfig as parse_config_opts
from mercurial.dispatch import _earlyparseopts as early_parse_opts

Antonio Muci

unread,
May 4, 2026, 4:52:33 PMMay 4
to thg...@googlegroups.com, a....@inwind.it
# HG changeset patch
# User Antonio Muci <a....@inwind.it>
# Date 1777677708 -7200
# Sat May 02 01:21:48 2026 +0200
# Branch stable
# Node ID 6198e0a68a68c5594ccec763c9fbbeb64517df71
# Parent 5592126afcb4b230c415838b7e1af7adafaca505
hg72: handle iterbranches being removed from branchmap in hg >= 7.2

Mercurial commit 02010bf96a32 ("branchmap: drop the `iterbranches` method from
the interface") removed branchmap().iterbranches(), which causes a runtime error
at TortoiseHg's startup:

```
Traceback (most recent call last):
File "<BASE>/tortoisehg/util/hglib.py", line xxx, in namedbranches
in branchmap.iterbranches()
^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'BranchCacheV2' object has no attribute 'iterbranches'
```

Immediately before that, 241e9d8ccf64 ("branchmap: add a `open_only` argument to
`hasbranch`") enriched hasbranch() api in a way that could be useful to us.

Both changes were integrated in mercurial 7.2.

This commit tries to be logically equivalent to the old (hg <= 7.1.2) fragment,
which is kept as a fallback. The change isinspired by what mercurial has done
in ce46d9d90f1c ("branchmap: use `hasbranch` to detect non-closed branch in `hg
branch`").

diff --git a/tortoisehg/util/hglib.py b/tortoisehg/util/hglib.py
--- a/tortoisehg/util/hglib.py
+++ b/tortoisehg/util/hglib.py
@@ -9,6 +9,7 @@ from __future__ import annotations

import glob
import io
+import inspect
import os
import re
import shlex
@@ -247,9 +248,27 @@ def activebookmark(repo) -> bytes:
def namedbranches(repo) -> List[bytes]:
branchmap = repo.branchmap()
dead = repo.deadbranches
- return sorted(br for br, _heads, _tip, isclosed
- in branchmap.iterbranches()
- if not isclosed and br not in dead)
+ if "open_only" in inspect.getfullargspec(branchmap.hasbranch).args:
+ # mercurial >= 7.2
+ #
+ # Mercurial commit 02010bf96a32 ("branchmap: drop the `iterbranches`
+ # method from the interface") removed branchmap().iterbranches(), but
+ # immediately before that 241e9d8ccf64 ("branchmap: add a `open_only`
+ # argument to `hasbranch`") enriched hasbranch() api.
+ # Both changes were integrated in mercurial 7.2.
+ #
+ # The logic of this fragment is inspired by mercurial changeset
+ # ce46d9d90f1c ("branchmap: use `hasbranch` to detect non-closed branch
+ # in `hg branch`") and tries to be logically equivalent to the old one,
+ # which is kept in the 'except' branch below.
+ return sorted(bn for bn in branchmap
+ if branchmap.hasbranch(bn, open_only=True) and bn not in dead)
+ else:
+ # pre 7.2 behaviour, where hasbranch(bn, open_only=True) could not be
+ # used, because the open_only parameter was not available.
+ return sorted(br for br, _heads, _tip, isclosed
+ in branchmap.iterbranches()
+ if not isclosed and br not in dead)

def _firstchangectx(repo):
try:

Antonio Muci

unread,
May 4, 2026, 4:52:33 PMMay 4
to thg...@googlegroups.com, a....@inwind.it
# HG changeset patch
# User Antonio Muci <a....@inwind.it>
# Date 1777673658 -7200
# Sat May 02 00:14:18 2026 +0200
# Branch stable
# Node ID 6c0e690e3bb3d6e248612bde4cead6f4297364f4
# Parent c92cd00dbfe34302c6ea6824a2636b28c92adcbc
hg72: start the work to implement compatibility with mercurial 7.2

This first commit adapts the code base to parse_config_opts and early_parse_opts
being moved in a new main_script module.

In order to keep compatibility with mercurial <= 7.1.2, the old imports are kept
as a fallback. They are however renamed according to the new API.

The API incompatibility was introduced on 2025-06-18 in mercurial changeset
aa0ff1214f489a804a6a924df699bf72d890390d ("cycle-breaking: move some of
`dispatch.py` in a new `main_script` module") and subsequent changes.

diff --git a/tests/helpers.py b/tests/helpers.py
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -168,9 +168,9 @@ class HgClient:
ui.ferr = util.bytesio()
args = list(args)
req = dispatch.request(args, ui=ui)
- options = dispatch._earlyparseopts(ui, args)
+ options = hglib.early_parse_opts(ui, args)
req.earlyoptions.update(options)
- dispatch._parseconfig(ui, req.earlyoptions[b'config'])
+ hglib.parse_config_opts(ui, req.earlyoptions[b'config'])
try:
result = dispatch._dispatch(req) or 0
return result, ui.fout.getvalue(), ui.ferr.getvalue()
diff --git a/tortoisehg/util/hglib.py b/tortoisehg/util/hglib.py
--- a/tortoisehg/util/hglib.py
+++ b/tortoisehg/util/hglib.py
@@ -28,7 +28,6 @@ from mercurial import (
cmdutil,
config,
context,
- dispatch as dispatchmod,
encoding,
error,
extensions,
@@ -78,6 +77,14 @@ except (ImportError, AttributeError):
raise NotImplementedError
# pytype: enable=import-error

+try:
+ # mercurial >= 7.2
+ from mercurial.main_script.options import parse_config_opts
+ from mercurial.main_script.options import early_parse_opts
+except ModuleNotFoundError:
+ from mercurial.dispatch import _parseconfig as parse_config_opts
+ from mercurial.dispatch import _earlyparseopts as early_parse_opts
+
if typing.TYPE_CHECKING:
from typing import (
AbstractSet,
@@ -1054,11 +1061,11 @@ def parseconfigopts(ui: uimod.ui,
>>> u.config(b'extensions', b'mq')
b'!'
"""
- config = dispatchmod._earlyparseopts(ui, args)[b'config']
+ config = early_parse_opts(ui, args)[b'config']
# drop --config from args
args[:] = fancyopts.earlygetopt(args, b'', [b'config='],
gnu=True, keepsep=True)[1]
- return dispatchmod._parseconfig(ui, config)
+ return parse_config_opts(ui, config)


# (unicode, QString) -> unicode, otherwise -> str

Antonio Muci

unread,
May 4, 2026, 4:52:34 PMMay 4
to thg...@googlegroups.com, a....@inwind.it
# HG changeset patch
# User Antonio Muci <a....@inwind.it>
# Date 1777679419 -7200
# Sat May 02 01:50:19 2026 +0200
# Branch stable
# Node ID caadae118b1a55a4618f31bd0b42207da5e8ffd2
# Parent 6198e0a68a68c5594ccec763c9fbbeb64517df71
hg72: handle repo.branchheads being removed from branchmap in hg >= 7.2

The removal happened on 2025-11-06, in mercurial commit a49c8fe2c986
("branchmap: drop the `repo.branchheads` method"), and was integrated in
mercurial 7.2.

Anyhow, a solution was already at hand: from at least 2019 (and possibly before:
I did not bother to check), branchmap was already exposing a branchheads()
method.

This changeset is inspired to what mercurial has done on 2025-11-06 in
dff46af5e54d ("branchmap: directly use the branchmap in `summary`").

From this commit on, tortoisehg is working under mercurial >= 7.2, while keeping
compatibility with hg <= 7.1.2.

However, tests are still broken and need an intervention. This will be done in
the next commit.

diff --git a/tortoisehg/hgqt/csinfo.py b/tortoisehg/hgqt/csinfo.py
--- a/tortoisehg/hgqt/csinfo.py
+++ b/tortoisehg/hgqt/csinfo.py
@@ -253,7 +253,7 @@ class SummaryInfo:
else:
return None
elif item == 'ishead':
- return ctx.node() in ctx.repo().branchheads(ctx.branch())
+ return ctx.node() in ctx.repo().branchmap().branchheads(ctx.branch())
elif item == 'mqoriginalparent':
target = ctx.thgmqoriginalparent()
if not target:
diff --git a/tortoisehg/hgqt/repomodel.py b/tortoisehg/hgqt/repomodel.py
--- a/tortoisehg/hgqt/repomodel.py
+++ b/tortoisehg/hgqt/repomodel.py
@@ -833,7 +833,7 @@ class HgRepoListModel(QAbstractTableMode
try:
branchheads = self._branchheads[branch]
except KeyError:
- branchheads = set(self.repo.branchheads(branch))
+ branchheads = set(self.repo.branchmap().branchheads(branch))
self._branchheads[branch] = branchheads

if ctx.rev() is None:
diff --git a/tortoisehg/hgqt/sync.py b/tortoisehg/hgqt/sync.py
--- a/tortoisehg/hgqt/sync.py
+++ b/tortoisehg/hgqt/sync.py
@@ -351,7 +351,7 @@ class SyncWidget(QWidget, qtlib.TaskWidg
for name in ctx.bookmarks():
uname = hglib.tounicode(name)
return self.targetcombo.findText(_('bookmark: ') + uname)
- if ctx.node() in self.repo.branchheads(ctx.branch()):
+ if ctx.node() in self.repo.branchmap().branchheads(ctx.branch()):
uname = hglib.tounicode(ctx.branch())
return self.targetcombo.findText(_('branch: ') + uname)
return 0
diff --git a/tortoisehg/util/hglib.py b/tortoisehg/util/hglib.py
--- a/tortoisehg/util/hglib.py
+++ b/tortoisehg/util/hglib.py
@@ -1453,7 +1453,7 @@ def parsecmdline(cmdline: str, cwd: str)
def createsnewhead(ctx, branchheads=None):
branch = ctx.branch()
if branchheads is None:
- branchheads = set(ctx.repo().branchheads(branch))
+ branchheads = set(ctx.repo().branchmap().branchheads(branch))
return branchheads and not any(
p.node() in branchheads and p.branch() == branch for p in ctx.parents()
)

Antonio Muci

unread,
May 4, 2026, 4:52:35 PMMay 4
to thg...@googlegroups.com, a....@inwind.it
# HG changeset patch
# User Antonio Muci <a....@inwind.it>
# Date 1777715277 -7200
# Sat May 02 11:47:57 2026 +0200
# Branch stable
# Node ID 06eb45af618bf1254d7e6d44d1e675f7790e506f
# Parent caadae118b1a55a4618f31bd0b42207da5e8ffd2
hg72: handle dispatch.request being moved into main_script.request in hg >= 7.2

The change happened on 2025-06-18, in mercurial d505cac73c02 ("cycle-breaking:
move dispatch.request into the new main_script module").

The errors that tests were triggering before this commit were of the form:
AttributeError: module 'mercurial.dispatch' has no attribute 'request'

After this commit, tortoisehg passess tests on my local machine with the
following version combinations:
- python 3.13, hg (6.9.5)
- python 3.14, hg (6.9.5, 7.1.2, 7.2, 7.2.1)

However, the hg >= 7.2 compatibility work is not over yet.

For example, selecting two revisions with CTRL+click and invoking "visual diff"
works with hg<=7.1.2, but causes a crash with hg >= 7.2. Evidently this case is
not covered by the test suite.

This problem will have to be addressed later.

diff --git a/tests/helpers.py b/tests/helpers.py
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -167,7 +167,7 @@ class HgClient:
ui.fout = util.bytesio()
ui.ferr = util.bytesio()
args = list(args)
- req = dispatch.request(args, ui=ui)
+ req = hglib.request(args, ui=ui)
options = hglib.early_parse_opts(ui, args)
req.earlyoptions.update(options)
hglib.parse_config_opts(ui, req.earlyoptions[b'config'])
diff --git a/tortoisehg/util/hglib.py b/tortoisehg/util/hglib.py
--- a/tortoisehg/util/hglib.py
+++ b/tortoisehg/util/hglib.py
@@ -81,10 +81,12 @@ except (ImportError, AttributeError):
try:
# mercurial >= 7.2
from mercurial.main_script.cmd_finder import find_cmd
+ from mercurial.main_script import request
from mercurial.main_script.options import parse_config_opts
from mercurial.main_script.options import early_parse_opts
except ModuleNotFoundError:
from mercurial.cmdutil import findcmd as find_cmd
+ from mercurial.dispatch import request
from mercurial.dispatch import _parseconfig as parse_config_opts

a....@inwind.it

unread,
May 4, 2026, 4:56:05 PMMay 4
to thg...@googlegroups.com
Please not that there is still at least a crash lingering in the hg 7.2 compatibility work, and that this crash is not caught by tests.

I am not sure if the bug was introduced by me (for example in "hg72: handle repo.branchheads being removed from branchmap..."), or if it is something deriving from mercurial 7.2 itself.

I am not able to untangle the traceback (where does "_list" come from?).

Antonio


```python
** Mercurial version (7.2). TortoiseHg version (+-b9a1d206fead)
** Command:
** CWD: <BASE>
** Encoding: UTF-8
** Extensions loaded: absorb, amend, churn, extdiff, hggit 1.3.0.dev20+hfa37b51caa (dulwich 0.24.10), histedit, mq, patchbomb, rebase, show, strip, tortoisehg.util.configitems, uncommit
** Python version: 3.14.4 (main, Apr 16 2026, 00:00:00) [GCC 16.0.1 20260321 (Red Hat 16.0.1-0)]
** Qt-6.10.3 PyQt-6.11.0 QScintilla-2.14.1
Traceback (most recent call last):
File "<BASE>/tortoisehg/hgqt/repowidget.py", line 1914, in visualDiffRevisionsPair
dlg = visdiff.visualdiff(self.repo.ui, self.repo, [],
{'rev': (str(revA), str(revB))})
File "<BASE>/tortoisehg/hgqt/visdiff.py", line 282, in visualdiff
n1, n2 = scmutil.revpair(repo, [hglib.fromunicode(rev)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
for rev in revs])
^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.14/site-packages/mercurial/scmutil.py", line 885, in revpair
l = revrange(repo, revs)
File "/usr/lib64/python3.14/site-packages/mercurial/scmutil.py", line 937, in revrange
return repo.anyrevs(allspecs, user=True, localalias=localalias)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.14/site-packages/mercurial/localrepo.py", line 1871, in anyrevs
return m(self)
File "/usr/lib64/python3.14/site-packages/mercurial/revset.py", line 607, in mfunc
return getset(repo, subset, tree, order)
File "/usr/lib64/python3.14/site-packages/mercurial/revset.py", line 110, in getset
return methods[x[0]](repo, subset, *x[1:], order=order)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.14/site-packages/mercurial/revset.py", line 369, in func
raise error.UnknownIdentifier(f, syms)
mercurial.error.UnknownIdentifier: unknown identifier: _list

```
> --
> You received this message because you are subscribed to the Google Groups "TortoiseHg Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to thg-dev+u...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/thg-dev/06eb45af618bf1254d7e.1777927953%40matebook.

Yuya Nishihara

unread,
May 5, 2026, 5:01:43 AMMay 5
to 'Antonio Muci' via TortoiseHg Developers, a....@inwind.it
On Mon, 04 May 2026 22:52:29 +0200, 'Antonio Muci' via TortoiseHg Developers wrote:
> # HG changeset patch
> # User Antonio Muci <a....@inwind.it>
> # Date 1777673658 -7200
> # Sat May 02 00:14:18 2026 +0200
> # Branch stable
> # Node ID 6c0e690e3bb3d6e248612bde4cead6f4297364f4
> # Parent c92cd00dbfe34302c6ea6824a2636b28c92adcbc
> hg72: start the work to implement compatibility with mercurial 7.2

Queued, thanks.

Yuya Nishihara

unread,
May 5, 2026, 5:01:45 AMMay 5
to 'Antonio Muci' via TortoiseHg Developers, a....@inwind.it
On Mon, 04 May 2026 22:52:32 +0200, 'Antonio Muci' via TortoiseHg Developers wrote:
> # HG changeset patch
> # User Antonio Muci <a....@inwind.it>
> # Date 1777679419 -7200
> # Sat May 02 01:50:19 2026 +0200
> # Branch stable
> # Node ID caadae118b1a55a4618f31bd0b42207da5e8ffd2
> # Parent 6198e0a68a68c5594ccec763c9fbbeb64517df71
> hg72: handle repo.branchheads being removed from branchmap in hg >= 7.2

I got the following error with hg 7.0.1. Dropped this patch for now.

Traceback (most recent call last):
File "/home/yuya/work/2010/hghacks/thg/tortoisehg/hgqt/repomodel.py", line 834, in _getrevlabels
branchheads = self._branchheads[branch]
~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: b''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/yuya/work/2010/hghacks/thg/tortoisehg/hgqt/repomodel.py", line 566, in data
return self._safedata(index, role)
~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "/home/yuya/work/2010/hghacks/thg/tortoisehg/hgqt/repomodel.py", line 586, in _safedata
result = self._rawdata(index, role)
File "/home/yuya/work/2010/hghacks/thg/tortoisehg/hgqt/repomodel.py", line 629, in _rawdata
return self._getrevlabels(ctx)
~~~~~~~~~~~~~~~~~~^^^^^
File "/home/yuya/work/2010/hghacks/thg/tortoisehg/hgqt/repomodel.py", line 836, in _getrevlabels
branchheads = set(self.repo.branchmap().branchheads(branch))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
File "/home/yuya/work/hghacks/mercurial-stable/mercurial/branchmap.py", line 706, in branchheads
return super().branchheads(branch, closed=closed)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
File "/home/yuya/work/hghacks/mercurial-stable/mercurial/branchmap.py", line 265, in branchheads
heads = self._entries[branch]
~~~~~~~~~~~~~^^^^^^^^
KeyError: b''
Traceback (most recent call last):
File "/home/yuya/work/2010/hghacks/thg/tortoisehg/hgqt/repomodel.py", line 834, in _getrevlabels
branchheads = self._branchheads[branch]
~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: b''

a....@inwind.it

unread,
May 5, 2026, 1:21:57 PMMay 5
to thg...@googlegroups.com, Yuya Nishihara
Hi Yuya,

I am trying to replicate this crash without success.

The current stable (edb6a9b390eb) does not start under 7.2, but that is expected because this patch is missing.
So in order to replicate your crash I grafted this dropped patch ("hg72: handle repo.branchheads being removed from branchmap in hg >= 7.2") on top of current stable (edb6a9b390eb).

After the graft, the code base is equivalent to the head of the patch series sent yesterday.

The environment to replicate the crash is a venv with python3.13 and hg 7.0.1, built like so:

```
python3.13 -m venv venv3.13-hg701
source venv3.13-hg701/bin/activate
pip install mercurial==7.0.1
pip install PyQt6-QScintilla
pip install pytest
```

In this condition I try to:

1. start thg via `THG_QT_API=PyQt6 ./thg`
- startup and basic workflow are functional (update, commit, etc...)
- vdiff (and who knows what else) is broken, but we already knew that

2. tests execute with the following command pass (except from the hghave ones, that I think are not relevant):

```
make tests HGPATH=venv3.13-hg701/lib64/python3.13/site-packages/ THG_QT_API=PyQt6
```

What am I missing?

Antonio
> --
> You received this message because you are subscribed to the Google Groups "TortoiseHg Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to thg-dev+u...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/thg-dev/20260505175606.4aa2a5c7%40lemosa.

a....@inwind.it

unread,
May 5, 2026, 1:27:03 PMMay 5
to thg...@googlegroups.com, Yuya Nishihara
I forgot to mention that current stable (edb6a9b390eb) obviously work and passes tests (except for hghave) with the setup mentioned below on hg 7.0.1. This is also expected: the dropped patch is not needed for hg < 7.2.

Antonio
> To view this discussion visit https://groups.google.com/d/msgid/thg-dev/564622816.2154261.1778001713767%40mail1.libero.it.

Yuya Nishihara

unread,
May 5, 2026, 9:09:52 PMMay 5
to a....@inwind.it, thg...@googlegroups.com
On Tue, 5 May 2026 19:21:53 +0200 (CEST), a....@inwind.it wrote:
> I am trying to replicate this crash without success.
>
> The current stable (edb6a9b390eb) does not start under 7.2, but that is expected because this patch is missing.
> So in order to replicate your crash I grafted this dropped patch ("hg72: handle repo.branchheads being removed from branchmap in hg >= 7.2") on top of current stable (edb6a9b390eb).
>
> After the graft, the code base is equivalent to the head of the patch series sent yesterday.
>
> The environment to replicate the crash is a venv with python3.13 and hg 7.0.1, built like so:
>
> ```
> python3.13 -m venv venv3.13-hg701
> source venv3.13-hg701/bin/activate
> pip install mercurial==7.0.1
> pip install PyQt6-QScintilla
> pip install pytest
> ```
>
> In this condition I try to:
>
> 1. start thg via `THG_QT_API=PyQt6 ./thg`
> - startup and basic workflow are functional (update, commit, etc...)
> - vdiff (and who knows what else) is broken, but we already knew that
>
> 2. tests execute with the following command pass (except from the hghave ones, that I think are not relevant):
>
> ```
> make tests HGPATH=venv3.13-hg701/lib64/python3.13/site-packages/ THG_QT_API=PyQt6
> ```
>
> What am I missing?

Perhaps, you would need unapplied mq patches to test with branch = b''. Can you
check if repo.branchheads() was exactly the same as branchmap().branchheads()?

Александр Литягин

unread,
May 6, 2026, 4:23:35 PMMay 6
to thg...@googlegroups.com
Hallow!

here i attaches patch <hg-7-2.patch>  for thg v7.0 allows work with
hg-7.2.1 (hg-7.2.0 have broken mq)

Second patch <legacy-7-1.patch> - for mercurial-7.2.1 (stable) provides
legacy api to run thg-7.0, and hggit-1.3.0 (succesfuly pulls from git repo)

PS: i have no access to heptapod now, so cant provide patches there, and
my google mailer no more allows sending email by patch-bomb. This is
only way i cap share it to you.


05.05.2026 11:51, Yuya Nishihara пишет:
hg-7-2.patch
legacy-v7-1.patch

Antonio Muci

unread,
May 12, 2026, 8:24:35 PM (10 days ago) May 12
to thg...@googlegroups.com, Yuya Nishihara
I tried to put a mq queue on top of this commit, with both applied and
unapplied changes. I was still not able to replicate the problem.

On the other side, this last commit ("handle repo.branchheads being
removed from branchmap in hg >= 7.2") is the one I have been using for
some days to continue to work with thg.

Are you sure the commit can't be pulled anyways (default instead of
stable would be ok, too)? It's the difference between having a broken
thg or a somewhat working one on Fedora 44.

Alternatively, what can I do to replicate your crash? Can you send a
your copy and some instructions? Or can anyone in the mailing list try
the change and independently assess if it is working or not?


Antonio

Yuya Nishihara

unread,
May 13, 2026, 6:40:50 AM (9 days ago) May 13
to Antonio Muci, thg...@googlegroups.com
On Wed, 13 May 2026 02:24:32 +0200, Antonio Muci wrote:
> I tried to put a mq queue on top of this commit, with both applied and
> unapplied changes. I was still not able to replicate the problem.

Ok, I have a dated patch which doesn't include "# Branch" header. I think you
can reproduce the problem by removing the Branch header. patchctx defaults to
b'', and maybe the new branchheads() function wouldn't check if the branch
exists or not.

Antonio Muci

unread,
May 21, 2026, 5:14:42 PM (yesterday) May 21
to thg...@googlegroups.com, Yuya Nishihara, Manuel Jacob
Thanks to help from Manuel, I was able to reproduce your crash, Yuya.

Manuel explained, and I verified, that repo.branchmap().branchheads was
buggy in hg (>= 7.0.1, < 7.2).

The problem in hg was fixed in 7.2 via 0969bb749bec ("branchmap: accept
missing `branch` in `branchheads`").

I am going to send a v2 of this commit that directly checks hg version
and activates the new code path only for hg >= 7.2.

From the manual testing I was able to do on various thg/hg versions,
this v2 should work as intended even with your unapplied patch.

Please review with cruelty.

Antonio
Reply all
Reply to author
Forward
0 new messages