diff --git a/remotefilelog/__init__.py b/remotefilelog/__init__.py --- a/remotefilelog/__init__.py +++ b/remotefilelog/__init__.py @@ -449,14 +449,17 @@ # close cache miss server connection after the command has finished def runcommand(orig, lui, repo, *args, **kwargs): + fileservice = None + # repo can be None when running in chg: + # - at startup, reposetup was called because serve is not norepo + # - a norepo command like "help" is called + if repo and shallowrepo.requirement in repo.requirements: + fileservice = repo.fileservice try: return orig(lui, repo, *args, **kwargs) finally: - # repo can be None when running in chg: - # - at startup, reposetup was called because serve is not norepo - # - a norepo command like "help" is called - if repo and shallowrepo.requirement in repo.requirements: - repo.fileservice.close() + if fileservice: + fileservice.close() wrapfunction(dispatch, 'runcommand', runcommand) # disappointing hacks below