Patchwork D9462: chgserver: catch RepoError while loading configuration

login
register
mail settings
Submitter phabricator
Date Nov. 30, 2020, 9:42 a.m.
Message ID <differential-rev-PHID-DREV-enlty74ufpzmnzhhklg5-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47741/
State Superseded
Headers show

Comments

phabricator - Nov. 30, 2020, 9:42 a.m.
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D9462

AFFECTED FILES
  mercurial/chgserver.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -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") % inst)
+            if inst.hint:
+                self.ui.error(_("(%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