comparison mercurial/commandserver.py @ 26587:56b2bcea2529

error: get Abort from 'error' instead of 'util' The home of 'Abort' is 'error' not 'util' however, a lot of code seems to be confused about that and gives all the credit to 'util' instead of the hardworking 'error'. In a spirit of equity, we break the cycle of injustice and give back to 'error' the respect it deserves. And screw that 'util' poser. For great justice.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 08 Oct 2015 12:55:45 -0700
parents 5857be01962e
children 28e50c4b15ed
comparison
equal deleted inserted replaced
26586:d51c658d3f04 26587:56b2bcea2529
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 from i18n import _ 8 from i18n import _
9 import struct 9 import struct
10 import sys, os, errno, traceback, SocketServer 10 import sys, os, errno, traceback, SocketServer
11 import dispatch, encoding, util 11 import dispatch, encoding, util, error
12 12
13 logfile = None 13 logfile = None
14 14
15 def log(*args): 15 def log(*args):
16 if not logfile: 16 if not logfile:
220 if handler: 220 if handler:
221 handler(self) 221 handler(self)
222 else: 222 else:
223 # clients are expected to check what commands are supported by 223 # clients are expected to check what commands are supported by
224 # looking at the servers capabilities 224 # looking at the servers capabilities
225 raise util.Abort(_('unknown command %s') % cmd) 225 raise error.Abort(_('unknown command %s') % cmd)
226 226
227 return cmd != '' 227 return cmd != ''
228 228
229 capabilities = {'runcommand' : runcommand, 229 capabilities = {'runcommand' : runcommand,
230 'getencoding' : getencoding} 230 'getencoding' : getencoding}
299 try: 299 try:
300 try: 300 try:
301 sv.serve() 301 sv.serve()
302 # handle exceptions that may be raised by command server. most of 302 # handle exceptions that may be raised by command server. most of
303 # known exceptions are caught by dispatch. 303 # known exceptions are caught by dispatch.
304 except util.Abort as inst: 304 except error.Abort as inst:
305 ui.warn(_('abort: %s\n') % inst) 305 ui.warn(_('abort: %s\n') % inst)
306 except IOError as inst: 306 except IOError as inst:
307 if inst.errno != errno.EPIPE: 307 if inst.errno != errno.EPIPE:
308 raise 308 raise
309 except KeyboardInterrupt: 309 except KeyboardInterrupt:
321 def __init__(self, ui, repo, opts): 321 def __init__(self, ui, repo, opts):
322 self.ui = ui 322 self.ui = ui
323 self.repo = repo 323 self.repo = repo
324 self.address = opts['address'] 324 self.address = opts['address']
325 if not util.safehasattr(SocketServer, 'UnixStreamServer'): 325 if not util.safehasattr(SocketServer, 'UnixStreamServer'):
326 raise util.Abort(_('unsupported platform')) 326 raise error.Abort(_('unsupported platform'))
327 if not self.address: 327 if not self.address:
328 raise util.Abort(_('no socket path specified with --address')) 328 raise error.Abort(_('no socket path specified with --address'))
329 329
330 def init(self): 330 def init(self):
331 class cls(SocketServer.ForkingMixIn, SocketServer.UnixStreamServer): 331 class cls(SocketServer.ForkingMixIn, SocketServer.UnixStreamServer):
332 ui = self.ui 332 ui = self.ui
333 repo = self.repo 333 repo = self.repo
349 def createservice(ui, repo, opts): 349 def createservice(ui, repo, opts):
350 mode = opts['cmdserver'] 350 mode = opts['cmdserver']
351 try: 351 try:
352 return _servicemap[mode](ui, repo, opts) 352 return _servicemap[mode](ui, repo, opts)
353 except KeyError: 353 except KeyError:
354 raise util.Abort(_('unknown mode %s') % mode) 354 raise error.Abort(_('unknown mode %s') % mode)