Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/changelog.py @ 46442:cad17d50736c
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
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Fri, 15 Jan 2021 01:30:08 +0100 |
parents | 2607a9346398 |
children | f7b61ad3c64a |
comparison
equal
deleted
inserted
replaced
46441:cabc5e9366c5 | 46442:cad17d50736c |
---|---|
198 filesadded = attr.ib(default=None) | 198 filesadded = attr.ib(default=None) |
199 filesremoved = attr.ib(default=None) | 199 filesremoved = attr.ib(default=None) |
200 p1copies = attr.ib(default=None) | 200 p1copies = attr.ib(default=None) |
201 p2copies = attr.ib(default=None) | 201 p2copies = attr.ib(default=None) |
202 description = attr.ib(default=b'') | 202 description = attr.ib(default=b'') |
203 branchinfo = attr.ib(default=(_defaultextra[b'branch'], False)) | |
203 | 204 |
204 | 205 |
205 class changelogrevision(object): | 206 class changelogrevision(object): |
206 """Holds results of a parsed changelog revision. | 207 """Holds results of a parsed changelog revision. |
207 | 208 |
369 return metadata.decodecopies(self.files, rawcopies) | 370 return metadata.decodecopies(self.files, rawcopies) |
370 | 371 |
371 @property | 372 @property |
372 def description(self): | 373 def description(self): |
373 return encoding.tolocal(self._text[self._offsets[3] + 2 :]) | 374 return encoding.tolocal(self._text[self._offsets[3] + 2 :]) |
375 | |
376 @property | |
377 def branchinfo(self): | |
378 extra = self.extra | |
379 return encoding.tolocal(extra.get(b"branch")), b'close' in extra | |
374 | 380 |
375 | 381 |
376 class changelog(revlog.revlog): | 382 class changelog(revlog.revlog): |
377 def __init__(self, opener, trypending=False): | 383 def __init__(self, opener, trypending=False): |
378 """Load a changelog revlog using an opener. | 384 """Load a changelog revlog using an opener. |
599 def branchinfo(self, rev): | 605 def branchinfo(self, rev): |
600 """return the branch name and open/close state of a revision | 606 """return the branch name and open/close state of a revision |
601 | 607 |
602 This function exists because creating a changectx object | 608 This function exists because creating a changectx object |
603 just to access this is costly.""" | 609 just to access this is costly.""" |
604 extra = self.changelogrevision(rev).extra | 610 return self.changelogrevision(rev).branchinfo |
605 return encoding.tolocal(extra.get(b"branch")), b'close' in extra | |
606 | 611 |
607 def _nodeduplicatecallback(self, transaction, node): | 612 def _nodeduplicatecallback(self, transaction, node): |
608 # keep track of revisions that got "re-added", eg: unbunde of know rev. | 613 # keep track of revisions that got "re-added", eg: unbunde of know rev. |
609 # | 614 # |
610 # We track them in a list to preserve their order from the source bundle | 615 # We track them in a list to preserve their order from the source bundle |