Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/branchmap.py @ 47031:f38bf44e077f stable
black: make codebase compatible with black v21.4b2 and v20.8b1
I don't know what exact version of black made it care about these whitespace
differences, but this is the version I got when I just installed it with
`pip3 install black`.
I'm intentionally not increasing the version of black required, as I don't want
to force everyone to upgrade their version of black, and these fixes are
backwards compatible with black v20.8b1. If there are more issues in the future
and this becomes a maintenance burden I may do so in a future change.
Tested with both versions of black (I got the older version via
`pip3 install black==20.8b1`)
Differential Revision: https://phab.mercurial-scm.org/D10539
author | Kyle Lippincott <spectral@google.com> |
---|---|
date | Fri, 30 Apr 2021 16:13:02 -0700 |
parents | d4ba4d51f85f |
children | bea4717415c0 |
comparison
equal
deleted
inserted
replaced
47030:bd2ed1032b4e | 47031:f38bf44e077f |
---|---|
218 self._hasnode = hasnode | 218 self._hasnode = hasnode |
219 if self._hasnode is None: | 219 if self._hasnode is None: |
220 self._hasnode = lambda x: True | 220 self._hasnode = lambda x: True |
221 | 221 |
222 def _verifyclosed(self): | 222 def _verifyclosed(self): |
223 """ verify the closed nodes we have """ | 223 """verify the closed nodes we have""" |
224 if self._closedverified: | 224 if self._closedverified: |
225 return | 225 return |
226 for node in self._closednodes: | 226 for node in self._closednodes: |
227 if not self._hasnode(node): | 227 if not self._hasnode(node): |
228 _unknownnode(node) | 228 _unknownnode(node) |
229 | 229 |
230 self._closedverified = True | 230 self._closedverified = True |
231 | 231 |
232 def _verifybranch(self, branch): | 232 def _verifybranch(self, branch): |
233 """ verify head nodes for the given branch. """ | 233 """verify head nodes for the given branch.""" |
234 if branch not in self._entries or branch in self._verifiedbranches: | 234 if branch not in self._entries or branch in self._verifiedbranches: |
235 return | 235 return |
236 for n in self._entries[branch]: | 236 for n in self._entries[branch]: |
237 if not self._hasnode(n): | 237 if not self._hasnode(n): |
238 _unknownnode(n) | 238 _unknownnode(n) |
239 | 239 |
240 self._verifiedbranches.add(branch) | 240 self._verifiedbranches.add(branch) |
241 | 241 |
242 def _verifyall(self): | 242 def _verifyall(self): |
243 """ verifies nodes of all the branches """ | 243 """verifies nodes of all the branches""" |
244 needverification = set(self._entries.keys()) - self._verifiedbranches | 244 needverification = set(self._entries.keys()) - self._verifiedbranches |
245 for b in needverification: | 245 for b in needverification: |
246 self._verifybranch(b) | 246 self._verifybranch(b) |
247 | 247 |
248 def __iter__(self): | 248 def __iter__(self): |
265 yield k, v | 265 yield k, v |
266 | 266 |
267 items = iteritems | 267 items = iteritems |
268 | 268 |
269 def hasbranch(self, label): | 269 def hasbranch(self, label): |
270 """ checks whether a branch of this name exists or not """ | 270 """checks whether a branch of this name exists or not""" |
271 self._verifybranch(label) | 271 self._verifybranch(label) |
272 return label in self._entries | 272 return label in self._entries |
273 | 273 |
274 @classmethod | 274 @classmethod |
275 def fromfile(cls, repo): | 275 def fromfile(cls, repo): |
383 def iterbranches(self): | 383 def iterbranches(self): |
384 for bn, heads in pycompat.iteritems(self): | 384 for bn, heads in pycompat.iteritems(self): |
385 yield (bn, heads) + self._branchtip(heads) | 385 yield (bn, heads) + self._branchtip(heads) |
386 | 386 |
387 def iterheads(self): | 387 def iterheads(self): |
388 """ returns all the heads """ | 388 """returns all the heads""" |
389 self._verifyall() | 389 self._verifyall() |
390 return pycompat.itervalues(self._entries) | 390 return pycompat.itervalues(self._entries) |
391 | 391 |
392 def copy(self): | 392 def copy(self): |
393 """return an deep copy of the branchcache object""" | 393 """return an deep copy of the branchcache object""" |
782 finally: | 782 finally: |
783 if wlock is not None: | 783 if wlock is not None: |
784 wlock.release() | 784 wlock.release() |
785 | 785 |
786 def _writenames(self, repo): | 786 def _writenames(self, repo): |
787 """ write the new branch names to revbranchcache """ | 787 """write the new branch names to revbranchcache""" |
788 if self._rbcnamescount != 0: | 788 if self._rbcnamescount != 0: |
789 f = repo.cachevfs.open(_rbcnames, b'ab') | 789 f = repo.cachevfs.open(_rbcnames, b'ab') |
790 if f.tell() == self._rbcsnameslen: | 790 if f.tell() == self._rbcsnameslen: |
791 f.write(b'\0') | 791 f.write(b'\0') |
792 else: | 792 else: |
807 self._rbcsnameslen = f.tell() | 807 self._rbcsnameslen = f.tell() |
808 f.close() | 808 f.close() |
809 self._rbcnamescount = len(self._names) | 809 self._rbcnamescount = len(self._names) |
810 | 810 |
811 def _writerevs(self, repo, start): | 811 def _writerevs(self, repo, start): |
812 """ write the new revs to revbranchcache """ | 812 """write the new revs to revbranchcache""" |
813 revs = min(len(repo.changelog), len(self._rbcrevs) // _rbcrecsize) | 813 revs = min(len(repo.changelog), len(self._rbcrevs) // _rbcrecsize) |
814 with repo.cachevfs.open(_rbcrevs, b'ab') as f: | 814 with repo.cachevfs.open(_rbcrevs, b'ab') as f: |
815 if f.tell() != start: | 815 if f.tell() != start: |
816 repo.ui.debug( | 816 repo.ui.debug( |
817 b"truncating cache/%s to %d\n" % (_rbcrevs, start) | 817 b"truncating cache/%s to %d\n" % (_rbcrevs, start) |