changeset 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 c7fc2d92067e
children 6237cb11753e
files mercurial/localrepo.py
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Fri Nov 22 18:02:12 2019 -0500
+++ b/mercurial/localrepo.py	Sun Nov 17 03:27:51 2019 +0100
@@ -1515,10 +1515,13 @@
         self.invalidate(clearfilecache=True)
 
     def __getitem__(self, changeid):
+        # dealing with special cases
         if changeid is None:
             return context.workingctx(self)
         if isinstance(changeid, context.basectx):
             return changeid
+
+        # dealing with multiple revisions
         if isinstance(changeid, slice):
             # wdirrev isn't contiguous so the slice shouldn't include it
             return [
@@ -1526,6 +1529,8 @@
                 for i in pycompat.xrange(*changeid.indices(len(self)))
                 if i not in self.changelog.filteredrevs
             ]
+
+        # dealing with arbitrary values
         try:
             if isinstance(changeid, int):
                 node = self.changelog.node(changeid)