Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 43750:9c83d28776af
localrepo: add some basic comment for block in __getitem__
There are different early processing before getting to the core of the function.
We highlight that fact.
Differential Revision: https://phab.mercurial-scm.org/D7473
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 17 Nov 2019 03:27:51 +0100 |
parents | 7eb701e355bd |
children | 6237cb11753e |
comparison
equal
deleted
inserted
replaced
43749:c7fc2d92067e | 43750:9c83d28776af |
---|---|
1513 def setnarrowpats(self, newincludes, newexcludes): | 1513 def setnarrowpats(self, newincludes, newexcludes): |
1514 narrowspec.save(self, newincludes, newexcludes) | 1514 narrowspec.save(self, newincludes, newexcludes) |
1515 self.invalidate(clearfilecache=True) | 1515 self.invalidate(clearfilecache=True) |
1516 | 1516 |
1517 def __getitem__(self, changeid): | 1517 def __getitem__(self, changeid): |
1518 # dealing with special cases | |
1518 if changeid is None: | 1519 if changeid is None: |
1519 return context.workingctx(self) | 1520 return context.workingctx(self) |
1520 if isinstance(changeid, context.basectx): | 1521 if isinstance(changeid, context.basectx): |
1521 return changeid | 1522 return changeid |
1523 | |
1524 # dealing with multiple revisions | |
1522 if isinstance(changeid, slice): | 1525 if isinstance(changeid, slice): |
1523 # wdirrev isn't contiguous so the slice shouldn't include it | 1526 # wdirrev isn't contiguous so the slice shouldn't include it |
1524 return [ | 1527 return [ |
1525 self[i] | 1528 self[i] |
1526 for i in pycompat.xrange(*changeid.indices(len(self))) | 1529 for i in pycompat.xrange(*changeid.indices(len(self))) |
1527 if i not in self.changelog.filteredrevs | 1530 if i not in self.changelog.filteredrevs |
1528 ] | 1531 ] |
1532 | |
1533 # dealing with arbitrary values | |
1529 try: | 1534 try: |
1530 if isinstance(changeid, int): | 1535 if isinstance(changeid, int): |
1531 node = self.changelog.node(changeid) | 1536 node = self.changelog.node(changeid) |
1532 rev = changeid | 1537 rev = changeid |
1533 elif changeid == b'null': | 1538 elif changeid == b'null': |