# HG changeset patch # User Alexis S. L. Carvalho # Date 1190671211 10800 # Node ID 8ee5b8129e7be1457f3a7f98625ea4cb952aa04b # Parent 4528858e7202d02c55c78e48eed18b76f6b71083 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. diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py +++ b/mercurial/hgweb/hgweb_mod.py @@ -141,7 +141,10 @@ class hgweb(object): def nodebranchdict(self, ctx): branches = [] branch = ctx.branch() - if self.repo.branchtags()[branch] == ctx.node(): + # If this is an empty repo, ctx.node() == nullid, + # ctx.branch() == 'default', but branchtags() is + # an empty dict. Using dict.get avoids a traceback. + if self.repo.branchtags().get(branch) == ctx.node(): branches.append({"name": branch}) return branches