Mercurial > hg
changeset 43145:4296cc3c4ae1
changelog: make copies related function return None or a valid value
With the previous code, existing but empty value were not "decoded", leading to
the method returning one of `None`, some valid value (`list` or `dict`) or
`b''`.
On a general basis, not explicitly checking for None is a source of bugs.
Having a clean return types will help the side-data copies code in future
changesets.
Differential Revision: https://phab.mercurial-scm.org/D7037
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 10 Oct 2019 00:06:41 +0200 |
parents | ea230325dc8c |
children | 0171483b082f |
files | mercurial/changelog.py |
diffstat | 1 files changed, 12 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/changelog.py Thu Oct 10 00:01:40 2019 +0200 +++ b/mercurial/changelog.py Thu Oct 10 00:06:41 2019 +0200 @@ -363,22 +363,30 @@ @property def filesadded(self): rawindices = self.extra.get(b'filesadded') - return rawindices and decodefileindices(self.files, rawindices) + if rawindices is None: + return None + return decodefileindices(self.files, rawindices) @property def filesremoved(self): rawindices = self.extra.get(b'filesremoved') - return rawindices and decodefileindices(self.files, rawindices) + if rawindices is None: + return None + return decodefileindices(self.files, rawindices) @property def p1copies(self): rawcopies = self.extra.get(b'p1copies') - return rawcopies and decodecopies(self.files, rawcopies) + if rawcopies is None: + return None + return decodecopies(self.files, rawcopies) @property def p2copies(self): rawcopies = self.extra.get(b'p2copies') - return rawcopies and decodecopies(self.files, rawcopies) + if rawcopies is None: + return None + return decodecopies(self.files, rawcopies) @property def description(self):