# HG changeset patch # User Joerg Sonnenberger # Date 1610670608 -3600 # Node ID cad17d50736ca5bd3ba83b82697461a2cf646fdc # Parent cabc5e9366c55ac4c446e474f00dd593dd5e5816 changelog: move branchinfo to changelogrevision The function parses the extra dictionary after looking up the changelogrevision. To avoid duplicated look up, it is better to provide it as property of changelogrevision instead. Keep the function for a release cycle as at least the topic extension depends on it. Differential Revision: https://phab.mercurial-scm.org/D9779 diff -r cabc5e9366c5 -r cad17d50736c mercurial/changelog.py --- a/mercurial/changelog.py Fri Jan 22 11:10:39 2021 +0100 +++ b/mercurial/changelog.py Fri Jan 15 01:30:08 2021 +0100 @@ -200,6 +200,7 @@ p1copies = attr.ib(default=None) p2copies = attr.ib(default=None) description = attr.ib(default=b'') + branchinfo = attr.ib(default=(_defaultextra[b'branch'], False)) class changelogrevision(object): @@ -372,6 +373,11 @@ def description(self): return encoding.tolocal(self._text[self._offsets[3] + 2 :]) + @property + def branchinfo(self): + extra = self.extra + return encoding.tolocal(extra.get(b"branch")), b'close' in extra + class changelog(revlog.revlog): def __init__(self, opener, trypending=False): @@ -601,8 +607,7 @@ This function exists because creating a changectx object just to access this is costly.""" - extra = self.changelogrevision(rev).extra - return encoding.tolocal(extra.get(b"branch")), b'close' in extra + return self.changelogrevision(rev).branchinfo def _nodeduplicatecallback(self, transaction, node): # keep track of revisions that got "re-added", eg: unbunde of know rev. diff -r cabc5e9366c5 -r cad17d50736c relnotes/next --- a/relnotes/next Fri Jan 22 11:10:39 2021 +0100 +++ b/relnotes/next Fri Jan 15 01:30:08 2021 +0100 @@ -65,4 +65,5 @@ == Internal API Changes == - + * `changelog.branchinfo` is deprecated and will be removed after 5.8. + It is superseded by `changelogrevision.branchinfo`.