Patchwork D6154: branchcache: introduce hasbranch()

login
register
mail settings
Submitter phabricator
Date March 23, 2019, 3:40 p.m.
Message ID <33398581b606e252b6f99544a0320ae8@localhost.localdomain>
Download mbox | patch
Permalink /patch/39370/
State Not Applicable
Headers show

Comments

phabricator - March 23, 2019, 3:40 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG0bd730fbcc2b: branchcache: introduce hasbranch() (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6154?vs=14559&id=14586

REVISION DETAIL
  https://phab.mercurial-scm.org/D6154

AFFECTED FILES
  mercurial/branchmap.py
  mercurial/localrepo.py
  mercurial/revset.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -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=('<branch %r>', b))
             if b.startswith('literal:'):
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -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 --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -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