[PATCH] repowidget: restore applying MQ patches with a double click (fixes #5924)

7 views
Skip to first unread message

Matt Harbison

unread,
Aug 13, 2023, 5:32:25 PM8/13/23
to thg...@googlegroups.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1691962091 14400
# Sun Aug 13 17:28:11 2023 -0400
# Branch stable
# Node ID 2cbbab6928594f9003c57bb083902a38243770a9
# Parent 9e63cbbba0ee735f27403f4ec839c5f2135e8806
repowidget: restore applying MQ patches with a double click (fixes #5924)

Back in the python2 days, this did an `isinstance` check against `basestring`,
which could be either bytes or unicode. 70ea875f3f83 introduced `isbasestring`
for py3 support. While most of its users are happy with unicode, the MQ patch
names are bytes (from `repo.mq` in core). Therefore, double clicking attempted
a visual diff, `visdiff.visualdiff` caught a `LookupError` or `RepoError`, and
put up a nonsense messagebox that the application needs to be refreshed.

It looks like double clicking a normal revision or an applied patch causes an
`int` to be passed in here. I'm not sure that this would ever be `str`, but
let's just restore the status quo.

Double clicking `qparent` unapplies the patch, which seems a little inconistent,
but that appears to be the intended behavior.

diff --git a/tortoisehg/hgqt/repowidget.py b/tortoisehg/hgqt/repowidget.py
--- a/tortoisehg/hgqt/repowidget.py
+++ b/tortoisehg/hgqt/repowidget.py
@@ -1017,7 +1017,7 @@

def onRevisionActivated(self, rev):
qgoto = False
- if hglib.isbasestring(rev):
+ if isinstance(rev, (bytes, str)):
qgoto = True
else:
ctx = self.repo[rev]

Yuya Nishihara

unread,
Aug 13, 2023, 7:19:49 PM8/13/23
to Matt Harbison, thg...@googlegroups.com
On Sun, 13 Aug 2023 17:32:19 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_h...@yahoo.com>
> # Date 1691962091 14400
> # Sun Aug 13 17:28:11 2023 -0400
> # Branch stable
> # Node ID 2cbbab6928594f9003c57bb083902a38243770a9
> # Parent 9e63cbbba0ee735f27403f4ec839c5f2135e8806
> repowidget: restore applying MQ patches with a double click (fixes #5924)
>
> Back in the python2 days, this did an `isinstance` check against `basestring`,
> which could be either bytes or unicode. 70ea875f3f83 introduced `isbasestring`
> for py3 support. While most of its users are happy with unicode, the MQ patch
> names are bytes (from `repo.mq` in core). Therefore, double clicking attempted
> a visual diff, `visdiff.visualdiff` caught a `LookupError` or `RepoError`, and
> put up a nonsense messagebox that the application needs to be refreshed.
>
> It looks like double clicking a normal revision or an applied patch causes an
> `int` to be passed in here. I'm not sure that this would ever be `str`, but
> let's just restore the status quo.

The code LGTM, but can you add a comment about that? I also think str wouldn't
be a valid patch "revision", but I'm not sure.

Matt Harbison

unread,
Aug 13, 2023, 9:30:53 PM8/13/23
to thg...@googlegroups.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1691962091 14400
# Sun Aug 13 17:28:11 2023 -0400
# Branch stable
# Node ID 390fbc068c3cacb3febc0b18f021101504cf3d99
# Parent 9e63cbbba0ee735f27403f4ec839c5f2135e8806
repowidget: restore applying MQ patches with a double click (fixes #5924)

Back in the python2 days, this did an `isinstance` check against `basestring`,
which could be either bytes or unicode. 70ea875f3f83 introduced `isbasestring`
for py3 support. While most of its users are happy with unicode, the MQ patch
names are bytes (from `repo.mq` in core). Therefore, double clicking attempted
a visual diff, `visdiff.visualdiff` caught a `LookupError` or `RepoError`, and
put up a nonsense messagebox that the application needs to be refreshed.

It looks like double clicking a normal revision or an applied patch causes an
`int` to be passed in here. I'm not sure that this would ever be `str`, but
let's just restore the status quo.

Double clicking `qparent` unapplies the patch, which seems a little inconistent,
but that appears to be the intended behavior.

diff --git a/tortoisehg/hgqt/repowidget.py b/tortoisehg/hgqt/repowidget.py
--- a/tortoisehg/hgqt/repowidget.py
+++ b/tortoisehg/hgqt/repowidget.py
@@ -1017,7 +1017,12 @@

def onRevisionActivated(self, rev):
qgoto = False
- if hglib.isbasestring(rev):
+
+ # Normal revisions and applied patches are int values, while unapplied
+ # patches seem to always(?) be bytes. The python2 code used to check
+ # for the basestring type, which can be either bytes or unicode on py2,
+ # so there may be a few cases of unicode.

Yuya Nishihara

unread,
Aug 14, 2023, 1:51:16 AM8/14/23
to Matt Harbison, thg...@googlegroups.com
On Sun, 13 Aug 2023 21:30:46 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_h...@yahoo.com>
> # Date 1691962091 14400
> # Sun Aug 13 17:28:11 2023 -0400
> # Branch stable
> # Node ID 390fbc068c3cacb3febc0b18f021101504cf3d99
> # Parent 9e63cbbba0ee735f27403f4ec839c5f2135e8806
> repowidget: restore applying MQ patches with a double click (fixes #5924)

Queued for stable, thanks.
Reply all
Reply to author
Forward
0 new messages