chgserver: catch RepoError while loading configuration
authorPulkit Goyal <7895pulkit@gmail.com>
Mon, 30 Nov 2020 14:11:03 +0530
changeset 46016 aab70f05d6ec
parent 46015 c1bb02738f96
child 46017 705c37f22859
chgserver: catch RepoError while loading configuration Recent share safe work introduced functionality to read share source config file on dispatch. This can result in RepoError while reading config file as the shared source might not be present. `test-share.t#safe` was failing with chg earlier because of this. Differential Revision: https://phab.mercurial-scm.org/D9462
mercurial/chgserver.py
--- a/mercurial/chgserver.py	Sat Nov 28 16:59:40 2020 -0500
+++ b/mercurial/chgserver.py	Mon Nov 30 14:11:03 2020 +0530
@@ -504,10 +504,21 @@
         the instructions.
         """
         args = self._readlist()
+        errorraised = False
         try:
             self.ui, lui = _loadnewui(self.ui, args, self.cdebug)
+        except error.RepoError as inst:
+            # RepoError can be raised while trying to read shared source
+            # configuration
+            self.ui.error(_(b"abort: %s\n") % stringutil.forcebytestr(inst))
+            if inst.hint:
+                self.ui.error(_(b"(%s)\n") % inst.hint)
+            errorraised = True
         except error.Abort as inst:
             self.ui.error(inst.format())
+            errorraised = True
+
+        if errorraised:
             self.ui.flush()
             self.cresult.write(b'exit 255')
             return