comparison mercurial/hgweb/hgweb_mod.py @ 5331:8ee5b8129e7b

hgweb: don't raise an exception when displying empty repos The nullid node claims it's in the default branch, but the branch dict is empty. This fixes the main symptom from issue696, but we may want to set branchtags()['default'] = nullid somewhere for empty repos.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Mon, 24 Sep 2007 19:00:11 -0300
parents ed6df6b1c29a
children 24de027551c1
comparison
equal deleted inserted replaced
5330:4528858e7202 5331:8ee5b8129e7b
139 return [{"name": i} for i in self.repo.nodetags(node)] 139 return [{"name": i} for i in self.repo.nodetags(node)]
140 140
141 def nodebranchdict(self, ctx): 141 def nodebranchdict(self, ctx):
142 branches = [] 142 branches = []
143 branch = ctx.branch() 143 branch = ctx.branch()
144 if self.repo.branchtags()[branch] == ctx.node(): 144 # If this is an empty repo, ctx.node() == nullid,
145 # ctx.branch() == 'default', but branchtags() is
146 # an empty dict. Using dict.get avoids a traceback.
147 if self.repo.branchtags().get(branch) == ctx.node():
145 branches.append({"name": branch}) 148 branches.append({"name": branch})
146 return branches 149 return branches
147 150
148 def showtag(self, t1, node=nullid, **args): 151 def showtag(self, t1, node=nullid, **args):
149 for t in self.repo.nodetags(node): 152 for t in self.repo.nodetags(node):