[PATCH 1 of 3] revdetails: port to modern Mercurial API (fixes #5957)

8 views
Skip to first unread message

Matt Harbison

unread,
Nov 16, 2023, 1:21:58 PM11/16/23
to thg...@googlegroups.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1700157763 18000
# Thu Nov 16 13:02:43 2023 -0500
# Branch stable
# Node ID 2c5ec6c6eb671df2171cca8f57c373cfd41fbd15
# Parent 9da7ef8afe68e83ed66e98d5ac7c96422c49285a
# EXP-Topic revdetails-fixes
revdetails: port to modern Mercurial API (fixes #5957)

This worked if the revision was a special symbolic name, but crashed if it was a
short hash, because `repo[rev]` stopped accepting short hashes way back in
Mercurial 4.8 (hg 3d35304bd09b). Additionally, the `rev` arg defaulted to '',
so the fallback to '.' was never taken. `scmutil.revsingle()` handles that
fallback properly, given a rev of ''.

diff --git a/tortoisehg/hgqt/run.py b/tortoisehg/hgqt/run.py
--- a/tortoisehg/hgqt/run.py
+++ b/tortoisehg/hgqt/run.py
@@ -1249,7 +1249,7 @@
from tortoisehg.hgqt import revdetails as revdetailsmod
repo = repoagent.rawRepo()
os.chdir(repo.root)
- rev = opts.get('rev', '.')
+ rev = scmutil.revsingle(repo, opts.get('rev')).rev()
return revdetailsmod.RevDetailsDialog(repoagent, rev=rev)

@command(b'revert', [], _('thg revert [FILE]...'))

Matt Harbison

unread,
Nov 16, 2023, 1:22:00 PM11/16/23
to thg...@googlegroups.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1700157999 18000
# Thu Nov 16 13:06:39 2023 -0500
# Branch stable
# Node ID 55a64724cae315d9307c7d41a5fc1e0b2a6fb1e5
# Parent 2c5ec6c6eb671df2171cca8f57c373cfd41fbd15
# EXP-Topic revdetails-fixes
revdetails: byteify a default argument passed for a core API

In practice, this doesn't matter because all callers pass a revision value, but
I noticed it while working on the last commit.

diff --git a/tortoisehg/hgqt/revdetails.py b/tortoisehg/hgqt/revdetails.py
--- a/tortoisehg/hgqt/revdetails.py
+++ b/tortoisehg/hgqt/revdetails.py
@@ -559,7 +559,7 @@
class RevDetailsDialog(QDialog):
'Standalone revision details tool, a wrapper for RevDetailsWidget'

- def __init__(self, repoagent, rev='.', parent=None):
+ def __init__(self, repoagent, rev=b'.', parent=None):
QDialog.__init__(self, parent)
self.setWindowFlags(Qt.WindowType.Window)
self.setWindowIcon(qtlib.geticon('hg-log'))

Matt Harbison

unread,
Nov 16, 2023, 1:22:02 PM11/16/23
to thg...@googlegroups.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1700158750 18000
# Thu Nov 16 13:19:10 2023 -0500
# Branch stable
# Node ID e11eb85b5c5e5407f4b462a3d43eca1aa981f0fb
# Parent 55a64724cae315d9307c7d41a5fc1e0b2a6fb1e5
# EXP-Topic revdetails-fixes
revdetails: stringify the hash in the titlebar to avoid `b'xxxx'` display

This didn't crash, but looked ugly.

diff --git a/tortoisehg/hgqt/revdetails.py b/tortoisehg/hgqt/revdetails.py
--- a/tortoisehg/hgqt/revdetails.py
+++ b/tortoisehg/hgqt/revdetails.py
@@ -660,7 +660,7 @@
revstr = _('Working Directory')
else:
hash = self.revdetails.ctx.hex()[:12]
- revstr = '@%s: %s' % (str(revnum), hash)
+ revstr = '@%s: %s' % (str(revnum), hglib.tounicode(hash))
self.setWindowTitle(_('%s - Revision Details (%s)')
% (self._repoagent.displayName(), revstr))
self.revdetails.reload()

Yuya Nishihara

unread,
Nov 17, 2023, 3:55:49 AM11/17/23
to Matt Harbison, thg...@googlegroups.com
On Thu, 16 Nov 2023 13:21:54 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_h...@yahoo.com>
> # Date 1700157763 18000
> # Thu Nov 16 13:02:43 2023 -0500
> # Branch stable
> # Node ID 2c5ec6c6eb671df2171cca8f57c373cfd41fbd15
> # Parent 9da7ef8afe68e83ed66e98d5ac7c96422c49285a
> # EXP-Topic revdetails-fixes
> revdetails: port to modern Mercurial API (fixes #5957)

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