Mercurial > hg
comparison hgext/convert/common.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 | 86598f4fe1cf |
children | 48b04018c897 80cac1de6aea |
comparison
equal
deleted
inserted
replaced
26586:d51c658d3f04 | 26587:56b2bcea2529 |
---|---|
5 # This software may be used and distributed according to the terms of the | 5 # This software may be used and distributed according to the terms of the |
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 import base64, errno, subprocess, os, datetime, re | 8 import base64, errno, subprocess, os, datetime, re |
9 import cPickle as pickle | 9 import cPickle as pickle |
10 from mercurial import phases, util | 10 from mercurial import phases, util, error |
11 from mercurial.i18n import _ | 11 from mercurial.i18n import _ |
12 | 12 |
13 propertycache = util.propertycache | 13 propertycache = util.propertycache |
14 | 14 |
15 def encodeargs(args): | 15 def encodeargs(args): |
30 | 30 |
31 def checktool(exe, name=None, abort=True): | 31 def checktool(exe, name=None, abort=True): |
32 name = name or exe | 32 name = name or exe |
33 if not util.findexe(exe): | 33 if not util.findexe(exe): |
34 if abort: | 34 if abort: |
35 exc = util.Abort | 35 exc = error.Abort |
36 else: | 36 else: |
37 exc = MissingTool | 37 exc = MissingTool |
38 raise exc(_('cannot find required "%s" tool') % name) | 38 raise exc(_('cannot find required "%s" tool') % name) |
39 | 39 |
40 class NoRepo(Exception): | 40 class NoRepo(Exception): |
71 def checkhexformat(self, revstr, mapname='splicemap'): | 71 def checkhexformat(self, revstr, mapname='splicemap'): |
72 """ fails if revstr is not a 40 byte hex. mercurial and git both uses | 72 """ fails if revstr is not a 40 byte hex. mercurial and git both uses |
73 such format for their revision numbering | 73 such format for their revision numbering |
74 """ | 74 """ |
75 if not re.match(r'[0-9a-fA-F]{40,40}$', revstr): | 75 if not re.match(r'[0-9a-fA-F]{40,40}$', revstr): |
76 raise util.Abort(_('%s entry %s is not a valid revision' | 76 raise error.Abort(_('%s entry %s is not a valid revision' |
77 ' identifier') % (mapname, revstr)) | 77 ' identifier') % (mapname, revstr)) |
78 | 78 |
79 def before(self): | 79 def before(self): |
80 pass | 80 pass |
81 | 81 |
367 if status: | 367 if status: |
368 if output: | 368 if output: |
369 self.ui.warn(_('%s error:\n') % self.command) | 369 self.ui.warn(_('%s error:\n') % self.command) |
370 self.ui.warn(output) | 370 self.ui.warn(output) |
371 msg = util.explainexit(status)[0] | 371 msg = util.explainexit(status)[0] |
372 raise util.Abort('%s %s' % (self.command, msg)) | 372 raise error.Abort('%s %s' % (self.command, msg)) |
373 | 373 |
374 def run0(self, cmd, *args, **kwargs): | 374 def run0(self, cmd, *args, **kwargs): |
375 output, status = self.run(cmd, *args, **kwargs) | 375 output, status = self.run(cmd, *args, **kwargs) |
376 self.checkexit(status, output) | 376 self.checkexit(status, output) |
377 return output | 377 return output |
444 # Ignore blank lines | 444 # Ignore blank lines |
445 continue | 445 continue |
446 try: | 446 try: |
447 key, value = line.rsplit(' ', 1) | 447 key, value = line.rsplit(' ', 1) |
448 except ValueError: | 448 except ValueError: |
449 raise util.Abort( | 449 raise error.Abort( |
450 _('syntax error in %s(%d): key/value pair expected') | 450 _('syntax error in %s(%d): key/value pair expected') |
451 % (self.path, i + 1)) | 451 % (self.path, i + 1)) |
452 if key not in self: | 452 if key not in self: |
453 self.order.append(key) | 453 self.order.append(key) |
454 super(mapfile, self).__setitem__(key, value) | 454 super(mapfile, self).__setitem__(key, value) |
457 def __setitem__(self, key, value): | 457 def __setitem__(self, key, value): |
458 if self.fp is None: | 458 if self.fp is None: |
459 try: | 459 try: |
460 self.fp = open(self.path, 'a') | 460 self.fp = open(self.path, 'a') |
461 except IOError as err: | 461 except IOError as err: |
462 raise util.Abort(_('could not open map file %r: %s') % | 462 raise error.Abort(_('could not open map file %r: %s') % |
463 (self.path, err.strerror)) | 463 (self.path, err.strerror)) |
464 self.fp.write('%s %s\n' % (key, value)) | 464 self.fp.write('%s %s\n' % (key, value)) |
465 self.fp.flush() | 465 self.fp.flush() |
466 super(mapfile, self).__setitem__(key, value) | 466 super(mapfile, self).__setitem__(key, value) |
467 | 467 |