# HG changeset patch # User Pulkit Goyal # Date 1552926705 -10800 # Node ID 0bd730fbcc2bb9e8427956e62b8d239b7cf3598c # Parent 7546bf46bfcd4a74f6dabc8c346bad55a1cc6259 branchcache: introduce hasbranch() This will be used to check whether a branch exists or not. This will optimized in future. Differential Revision: https://phab.mercurial-scm.org/D6154 diff -r 7546bf46bfcd -r 0bd730fbcc2b mercurial/branchmap.py --- a/mercurial/branchmap.py Mon Mar 18 19:11:55 2019 +0300 +++ b/mercurial/branchmap.py Mon Mar 18 19:31:45 2019 +0300 @@ -175,6 +175,10 @@ def iteritems(self): return self.entries.iteritems() + def hasbranch(self, label): + """ checks whether a branch of this name exists or not """ + return label in self.entries + @classmethod def fromfile(cls, repo): f = None diff -r 7546bf46bfcd -r 0bd730fbcc2b mercurial/localrepo.py --- a/mercurial/localrepo.py Mon Mar 18 19:11:55 2019 +0300 +++ b/mercurial/localrepo.py Mon Mar 18 19:31:45 2019 +0300 @@ -1556,7 +1556,7 @@ return scmutil.revsymbol(self, key).node() def lookupbranch(self, key): - if key in self.branchmap().entries: + if self.branchmap().hasbranch(key): 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.entries: + if not branches.hasbranch(branch): return [] # the cache returns heads ordered lowest to highest bheads = list(reversed(branches.branchheads(branch, closed=closed))) diff -r 7546bf46bfcd -r 0bd730fbcc2b mercurial/revset.py --- a/mercurial/revset.py Mon Mar 18 19:11:55 2019 +0300 +++ b/mercurial/revset.py Mon Mar 18 19:31:45 2019 +0300 @@ -555,7 +555,7 @@ if kind == 'literal': # note: falls through to the revspec case if no branch with # this name exists and pattern kind is not specified explicitly - if pattern in repo.branchmap(): + if repo.branchmap().hasbranch(pattern): return subset.filter(lambda r: matcher(getbranch(r)), condrepr=('', b)) if b.startswith('literal:'):