diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2471,7 +2471,7 @@ def serve(ui, repo, **opts): for o in optlist.split(): if opts[o]: parentui.setconfig("web", o, str(opts[o])) - if repo.ui != parentui: + if (repo is not None) and (repo.ui != parentui): repo.ui.setconfig("web", o, str(opts[o])) if repo is None and not ui.config("web", "webdir_conf"):