Commit cd394bf9 authored by Martin von Zweigbergk's avatar Martin von Zweigbergk
Browse files

compat: make topics compatible across change to cmdutil.commitstatus()

`cmdutil.commitstatus()` was changed in
https://phab.mercurial-scm.org/D9257 so it has a new `tip`
argument. This patch adds compatibility with that. It was harder than
I expected because the callers all pass the arguments as positional,
so we can't look for `opts` or `tip` in the `kwargs`. I instead
extracted much of the override to a helper. I think the result is
okay.
parent c2fab88e6d60
......@@ -8,6 +8,8 @@ Compatibility module
from __future__ import absolute_import
from mercurial import (
cmdutil,
extensions,
pycompat,
registrar,
util,
......@@ -46,3 +48,14 @@ def nonpublicphaseroots(repo):
return set().union(
*[roots for roots in repo._phasecache.phaseroots[1:] if roots]
)
def overridecommitstatus(overridefn):
if r'tip' in cmdutil.commitstatus.__code__.co_varnames:
extensions.wrapfunction(cmdutil, 'commitstatus', overridefn)
else:
# hg <= 5.6 (976b26bdd0d8)
def _override(orig, repo, node, branch, bheads=None, opts=None):
def _orig(repo, node, branch, bheads=None, tip=None, opts=None):
return orig(repo, node, branch, bheads=bheads, opts=opts)
return overridefn(_orig, repo, node, branch, bheads=bheads, tip=None, opts=opts)
extensions.wrapfunction(cmdutil, 'commitstatus', _override)
......@@ -6,7 +6,6 @@ from mercurial.node import nullid
from mercurial import (
branchmap,
changegroup,
cmdutil,
extensions,
repoview,
util,
......@@ -89,20 +88,20 @@ def modsetup(ui):
_setuptopicfilter(ui)
_wrapbmcache(ui)
extensions.wrapfunction(changegroup.cg1unpacker, 'apply', cgapply)
extensions.wrapfunction(cmdutil, 'commitstatus', commitstatus)
compat.overridecommitstatus(commitstatus)
def cgapply(orig, self, repo, *args, **kwargs):
"""make sure a topicmap is used when applying a changegroup"""
other = repo.filtered(topicfilter(repo.filtername))
return orig(self, other, *args, **kwargs)
def commitstatus(orig, repo, node, branch, bheads=None, opts=None):
def commitstatus(orig, repo, node, branch, bheads=None, tip=None, opts=None):
# wrap commit status use the topic branch heads
ctx = repo[node]
if ctx.topic() and ctx.branch() == branch:
bheads = repo.branchheads(b"%s:%s" % (branch, ctx.topic()))
ret = orig(repo, node, branch, bheads=bheads, opts=opts)
ret = orig(repo, node, branch, bheads=bheads, tip=tip, opts=opts)
# logic copy-pasted from cmdutil.commitstatus()
if opts is None:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment