D6154: branchcache: introduce hasbranch()
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Tue Mar 19 11:30:43 UTC 2019
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
This will be used to check whether a branch exists or not. This will optimized
in future.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D6154
AFFECTED FILES
mercurial/branchmap.py
mercurial/localrepo.py
CHANGE DETAILS
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
To: pulkit, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list