##// END OF EJS Templates
branchcache: introduce hasbranch()...
Pulkit Goyal -
r42171:0bd730fb default
parent child Browse files
Show More
@@ -175,6 +175,10 b' class branchcache(object):'
175 def iteritems(self):
175 def iteritems(self):
176 return self.entries.iteritems()
176 return self.entries.iteritems()
177
177
178 def hasbranch(self, label):
179 """ checks whether a branch of this name exists or not """
180 return label in self.entries
181
178 @classmethod
182 @classmethod
179 def fromfile(cls, repo):
183 def fromfile(cls, repo):
180 f = None
184 f = None
@@ -1556,7 +1556,7 b' class localrepository(object):'
1556 return scmutil.revsymbol(self, key).node()
1556 return scmutil.revsymbol(self, key).node()
1557
1557
1558 def lookupbranch(self, key):
1558 def lookupbranch(self, key):
1559 if key in self.branchmap().entries:
1559 if self.branchmap().hasbranch(key):
1560 return key
1560 return key
1561
1561
1562 return scmutil.revsymbol(self, key).branch()
1562 return scmutil.revsymbol(self, key).branch()
@@ -2730,7 +2730,7 b' class localrepository(object):'
2730 if branch is None:
2730 if branch is None:
2731 branch = self[None].branch()
2731 branch = self[None].branch()
2732 branches = self.branchmap()
2732 branches = self.branchmap()
2733 if branch not in branches.entries:
2733 if not branches.hasbranch(branch):
2734 return []
2734 return []
2735 # the cache returns heads ordered lowest to highest
2735 # the cache returns heads ordered lowest to highest
2736 bheads = list(reversed(branches.branchheads(branch, closed=closed)))
2736 bheads = list(reversed(branches.branchheads(branch, closed=closed)))
@@ -555,7 +555,7 b' def branch(repo, subset, x):'
555 if kind == 'literal':
555 if kind == 'literal':
556 # note: falls through to the revspec case if no branch with
556 # note: falls through to the revspec case if no branch with
557 # this name exists and pattern kind is not specified explicitly
557 # this name exists and pattern kind is not specified explicitly
558 if pattern in repo.branchmap():
558 if repo.branchmap().hasbranch(pattern):
559 return subset.filter(lambda r: matcher(getbranch(r)),
559 return subset.filter(lambda r: matcher(getbranch(r)),
560 condrepr=('<branch %r>', b))
560 condrepr=('<branch %r>', b))
561 if b.startswith('literal:'):
561 if b.startswith('literal:'):
General Comments 0
You need to be logged in to leave comments. Login now