# HG changeset patch # User Martijn Pieters # Date 1542801646 0 # Node ID d46360b8c0dc7613b85ce3ab83af9be060a40ecc # Parent 9b0cde5efbc9550d4523a41b884888ee6169c70c topic: make topics compatible with branchmap refactor See https://phab.mercurial-scm.org/D5290 diff -r 9b0cde5efbc9 -r d46360b8c0dc hgext3rd/serverminitopic.py --- a/hgext3rd/serverminitopic.py Wed Mar 27 20:52:30 2019 +0800 +++ b/hgext3rd/serverminitopic.py Wed Nov 21 12:00:46 2018 +0000 @@ -146,6 +146,10 @@ return hasminitopic(repo) and repo.filtername not in _publiconly class _topiccache(branchmap.branchcache): # combine me with branchmap.branchcache + @classmethod + def fromfile(cls, repo): + orig = super(_topiccache, cls).fromfile + return wrapread(orig, repo) def __init__(self, *args, **kwargs): # super() call may fail otherwise @@ -226,6 +230,12 @@ def uisetup(ui): wrapclass(branchmap, 'branchcache', _topiccache) - extensions.wrapfunction(branchmap, 'read', wrapread) + try: + # Mercurial 4.8 and older + extensions.wrapfunction(branchmap, 'read', wrapread) + except AttributeError: + # Mercurial 4.9; branchcache.fromfile now takes care of this + # which is alredy defined on _topiccache + pass extensions.wrapfunction(wireproto, '_capabilities', wireprotocaps) extensions.wrapfunction(context.changectx, 'branch', topicbranch) diff -r 9b0cde5efbc9 -r d46360b8c0dc hgext3rd/topic/topicmap.py --- a/hgext3rd/topic/topicmap.py Wed Mar 27 20:52:30 2019 +0800 +++ b/hgext3rd/topic/topicmap.py Wed Nov 21 12:00:46 2018 +0000 @@ -118,7 +118,21 @@ class topiccache(_topiccache, branchmap.branchcache): pass branchmap.branchcache = topiccache - extensions.wrapfunction(branchmap, 'updatecache', _wrapupdatebmcache) + + try: + # Mercurial 4.9 + class remotetopiccache(_topiccache, branchmap.remotebranchcache): + pass + branchmap.remotebranchcache = remotetopiccache + + def _wrapupdatebmcachemethod(orig, self, repo): + # pass in the bound method as the original + return _wrapupdatebmcache(orig.__get__(self), repo) + extensions.wrapfunction(branchmap.BranchMapCache, 'updatecache', _wrapupdatebmcachemethod) + except AttributeError: + # Mercurial 4.8 and before + extensions.wrapfunction(branchmap, 'updatecache', _wrapupdatebmcache) + def _wrapupdatebmcache(orig, repo): previous = getattr(repo, '_autobranchmaptopic', False)