mercurial/hgweb/hgweb_mod.py
changeset 5336 24de027551c1
parent 5290 05889b6b1468
parent 5331 8ee5b8129e7b
--- 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