From 5cdafa4002d87bf272f5a701fe0024e8af59f793 Mon Sep 17 00:00:00 2001 From: Christopher Speck Date: Wed, 17 May 2023 20:43:52 -0400 Subject: [PATCH] Update the arc-hg.py extension to work with mercurial 6.4 Summary: Mercurial 6.4 was recently released and showing up in package managers. With the update to 6.4 using `arc land` would result in an exception indicating that `expandpath` function does not exist. The `ui.expandpath` function was deprecated in 5.8 and now removed in 6.4. The functionality has been moved to `utils.urlutil.get_` functions (they are split between getting pull, push, and clone paths). This updates the script to try `utils.urlutil.get_clone_path` function if the `ui.expandpath` function is not present. Imported from: https://secure.phabricator.com/rARC0fc22183e796fb8ac2e3a0a3f3f37aa964c6d7fa Test Plan: I updated my latest mercurial install to 6.4 and verified with `hg --version`. I created a diff in a mercurial repo and used `arc land` to successfully land the revision without any exceptions. Closes T15288 Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: speck, tobiaswiese, Matthew, Cigaryno Maniphest Tasks: T15288 Differential Revision: https://we.phorge.it/D25143 --- support/hg/arc-hg.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/support/hg/arc-hg.py b/support/hg/arc-hg.py index 6689db86..bedd6aed 100644 --- a/support/hg/arc-hg.py +++ b/support/hg/arc-hg.py @@ -273,8 +273,21 @@ def remotemarkers(ui, repo, source, opts): markers = [] - source, branches = parseurl(ui.expandpath(source)) - remote = hg.peer(repo, opts, source) + # Determine the remote to use based on the default path configured in + # [ui.paths] for this local repository. + # + # The expandpath function in the ui module was deprecated in 5.8 and removed + # in 6.4. NOTE: There is also an expandpath function in mercurial.util (not + # plural mercurial.utils...) however that function behaves differently from + # the old ui.expandpath. Reviewing the source comments for the old + # ui.expandpath function points to using urilutils.get_ functions. + try: + remote_path, branches = parseurl(ui.expandpath(source)) + except: + from mercurial import utils + origsource, remote_path, branch = utils.urlutil.get_clone_path(ui, source) + + remote = hg.peer(repo, opts, remote_path) with remote.commandexecutor() as e: branchmap = e.callcommand(b'branchmap', {}).result()