diff mercurial/exchange.py @ 41715:3b0ba4575c8c

exchange: raise error.Abort instead of ValueError Raising ValueError results in an uncaught exception and a traceback being printed. In the context of servers, it can result in an HTTP 500 and an exception being logged in the error log. I don't think this is proper behavior. The bundle2 code paths have a mechanism for translating an error.Abort into an error message reported to the clients. I think we should use that instead. This commit replaces some ValueError with Abort so that servers can error more gracefully. Differential Revision: https://phab.mercurial-scm.org/D5972
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 15 Feb 2019 11:31:17 -0800
parents 876494fd967d
children aaad36b88298
line wrap: on
line diff
--- a/mercurial/exchange.py	Fri Feb 15 11:42:54 2019 -0800
+++ b/mercurial/exchange.py	Fri Feb 15 11:31:17 2019 -0800
@@ -920,7 +920,7 @@
                       if v in changegroup.supportedoutgoingversions(
                           pushop.repo)]
         if not cgversions:
-            raise ValueError(_('no common changegroup version'))
+            raise error.Abort(_('no common changegroup version'))
         version = max(cgversions)
     cgstream = changegroup.makestream(pushop.repo, pushop.outgoing, version,
                                       'push')
@@ -2184,7 +2184,7 @@
         cgversions = [v for v in cgversions
                       if v in changegroup.supportedoutgoingversions(repo)]
         if not cgversions:
-            raise ValueError(_('no common changegroup version'))
+            raise error.Abort(_('no common changegroup version'))
         version = max(cgversions)
 
     outgoing = _computeoutgoing(repo, heads, common)
@@ -2228,7 +2228,7 @@
     if not kwargs.get(r'bookmarks', False):
         return
     if 'bookmarks' not in b2caps:
-        raise ValueError(_('no common bookmarks exchange method'))
+        raise error.Abort(_('no common bookmarks exchange method'))
     books  = bookmod.listbinbookmarks(repo)
     data = bookmod.binaryencode(books)
     if data:
@@ -2263,7 +2263,7 @@
     """add phase heads part to the requested bundle"""
     if kwargs.get(r'phases', False):
         if not 'heads' in b2caps.get('phases'):
-            raise ValueError(_('no common phases exchange method'))
+            raise error.Abort(_('no common phases exchange method'))
         if heads is None:
             heads = repo.heads()