From 86951ad0678f117ff0fa64199023e60bf5b4f330 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 10 Jun 2020 15:30:51 -0700 Subject: [PATCH] Use a "branchmap" call to identify remote branches in "arc-hg" Summary: Ref T9948. Ref T13546. To identify remote branch heads -- not just modified heads -- use "branchmap" like "hg outgoing" does. I wasn't able to find any other way to get what we want: for example, with a bundlerepo, "peer.heads()" and "peer.changelog.heads()" include local branches which are not present in the remote. It generally seems difficult (perhaps impossible?) to distinguish between these cases by using "getremotechanges()": - branch X exists at position Y in both the local and remote; - branch X exists at positino Y in the local, but not the remote. In any case, this seems to work properly and //should// do less work than "getremotechanges()" since we don't need to pull as much data over the wire. Test Plan: Ran "hg arc-ls-markers" in various repositories, got what appeared to be a faithful representation of the remote branch and bookmark state. Maniphest Tasks: T13546, T9948 Differential Revision: https://secure.phabricator.com/D21349 --- support/hg/arc-hg.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/support/hg/arc-hg.py b/support/hg/arc-hg.py index 70dad19f..a11cef73 100644 --- a/support/hg/arc-hg.py +++ b/support/hg/arc-hg.py @@ -159,25 +159,20 @@ def remotemarkers(ui, repo, source, opts): source, branches = hg.parseurl(ui.expandpath(source)) remote = hg.peer(repo, opts, source) - bundle, remotebranches, cleanup = bundlerepo.getremotechanges( - ui, - repo, - remote) + with remote.commandexecutor() as e: + branchmap = e.callcommand('branchmap', {}).result() - try: - for n in remotebranches: - ctx = bundle[n] + for branch_name in branchmap: + for branch_node in branchmap[branch_name]: markers.append({ 'type': 'branch', - 'name': ctx.branch(), - 'node': node.hex(ctx.node()), + 'name': branch_name, + 'node': node.hex(branch_node), }) - finally: - cleanup() with remote.commandexecutor() as e: remotemarks = bookmarks.unhexlifybookmarks(e.callcommand('listkeys', { - 'namespace': 'bookmarks', + 'namespace': 'bookmarks', }).result()) for mark in remotemarks: