diff mercurial/localrepo.py @ 42001:624d6683c705

branchmap: remove the dict interface from the branchcache class (API) The current branchmap computation involves reading the whole branchmap from disk, validating all the nodes even if they are not required. This leads to a lot of time on repos which have large branchmap or a lot of branches. On large repos, this can validate around 1000's of nodes. On some operations, like finding whether a branch exists or not, we don't need to validate all the nodes. Or updating heads for a single branch. Before this patch, branchcache class was having dict interface and it was hard to keep track of reads. This patch removes the dict interface. Upcoming patches will implement lazy loading and validation of data and implement better API's. Differential Revision: https://phab.mercurial-scm.org/D6151
author Pulkit Goyal <pulkit@yandex-team.ru>
date Mon, 18 Mar 2019 18:59:38 +0300
parents 481259af4bdf
children 0bd730fbcc2b
line wrap: on
line diff
--- a/mercurial/localrepo.py	Sat Mar 23 20:59:07 2019 +0900
+++ b/mercurial/localrepo.py	Mon Mar 18 18:59:38 2019 +0300
@@ -1556,7 +1556,7 @@
         return scmutil.revsymbol(self, key).node()
 
     def lookupbranch(self, key):
-        if key in self.branchmap():
+        if key in self.branchmap().entries:
             return key
 
         return scmutil.revsymbol(self, key).branch()
@@ -2730,7 +2730,7 @@
         if branch is None:
             branch = self[None].branch()
         branches = self.branchmap()
-        if branch not in branches:
+        if branch not in branches.entries:
             return []
         # the cache returns heads ordered lowest to highest
         bheads = list(reversed(branches.branchheads(branch, closed=closed)))