changeset 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 4528858e7202
children b0bfe087ad8a
files mercurial/hgweb/hgweb_mod.py
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/hgweb_mod.py	Mon Sep 24 19:00:11 2007 -0300
+++ b/mercurial/hgweb/hgweb_mod.py	Mon Sep 24 19:00:11 2007 -0300
@@ -141,7 +141,10 @@
     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