##// END OF EJS Templates
localrepo: add ignoremissing parameter to branchtip...
Sean Farley -
r23775:885c0290 default
parent child Browse files
Show More
@@ -718,12 +718,21 b' class localrepository(object):'
718 branchmap.updatecache(self)
718 branchmap.updatecache(self)
719 return self._branchcaches[self.filtername]
719 return self._branchcaches[self.filtername]
720
720
721 def branchtip(self, branch):
721 def branchtip(self, branch, ignoremissing=False):
722 '''return the tip node for a given branch'''
722 '''return the tip node for a given branch
723
724 If ignoremissing is True, then this method will not raise an error.
725 This is helpful for callers that only expect None for a missing branch
726 (e.g. namespace).
727
728 '''
723 try:
729 try:
724 return self.branchmap().branchtip(branch)
730 return self.branchmap().branchtip(branch)
725 except KeyError:
731 except KeyError:
726 raise error.RepoLookupError(_("unknown branch '%s'") % branch)
732 if not ignoremissing:
733 raise error.RepoLookupError(_("unknown branch '%s'") % branch)
734 else:
735 pass
727
736
728 def lookup(self, key):
737 def lookup(self, key):
729 return self[key].node()
738 return self[key].node()
@@ -41,7 +41,7 b' class namespaces(object):'
41
41
42 n = ns("branches", "branch",
42 n = ns("branches", "branch",
43 lambda repo: repo.branchmap().keys(),
43 lambda repo: repo.branchmap().keys(),
44 lambda repo, name: tolist(repo.branchtip(name)),
44 lambda repo, name: tolist(repo.branchtip(name, True)),
45 lambda repo, node: [repo[node].branch()])
45 lambda repo, node: [repo[node].branch()])
46 self.addnamespace(n)
46 self.addnamespace(n)
47
47
General Comments 0
You need to be logged in to leave comments. Login now