D5292: branchmap: make it easier for extensions not to break branchcache
mjpieters (Martijn Pieters)
phabricator at mercurial-scm.org
Wed Nov 21 14:56:05 UTC 2018
mjpieters created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
The _branchcache global gives us a reference for super() to use even if an
extension subclasses branchmap.branchcache then replaces the class in the
module.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D5292
AFFECTED FILES
mercurial/branchmap.py
CHANGE DETAILS
diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -211,7 +211,7 @@
def __init__(self, entries=(), tipnode=nullid, tiprev=nullrev,
filteredhash=None, closednodes=None):
- super(branchcache, self).__init__(entries)
+ super(_branchcache, self).__init__(entries)
self.tipnode = tipnode
self.tiprev = tiprev
self.filteredhash = filteredhash
@@ -369,6 +369,11 @@
self.write(repo)
+# keep a private reference to the class object so that subclasses that
+# replace the branchcache class do not break super()
+_branchcache = branchcache
+
+
class remotebranchcache(branchcache):
"""Branchmap info for a remote connection, should not write locally"""
def write(self, repo):
To: mjpieters, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list