##// END OF EJS Templates
error: get Abort from 'error' instead of 'util'...
Pierre-Yves David -
r26587:56b2bcea default
parent child Browse files
Show More
@@ -5,7 +5,7 b' demandimport.enable()'
5
5
6 import sys
6 import sys
7 from mercurial.i18n import _
7 from mercurial.i18n import _
8 from mercurial import simplemerge, fancyopts, util, ui
8 from mercurial import error, simplemerge, fancyopts, util, ui
9
9
10 options = [('L', 'label', [], _('labels to use on conflict markers')),
10 options = [('L', 'label', [], _('labels to use on conflict markers')),
11 ('a', 'text', None, _('treat all files as text')),
11 ('a', 'text', None, _('treat all files as text')),
@@ -59,7 +59,7 b' except ParseError, e:'
59 sys.stdout.write("%s: %s\n" % (sys.argv[0], e))
59 sys.stdout.write("%s: %s\n" % (sys.argv[0], e))
60 showhelp()
60 showhelp()
61 sys.exit(1)
61 sys.exit(1)
62 except util.Abort, e:
62 except error.Abort, e:
63 sys.stderr.write("abort: %s\n" % e)
63 sys.stderr.write("abort: %s\n" % e)
64 sys.exit(255)
64 sys.exit(255)
65 except KeyboardInterrupt:
65 except KeyboardInterrupt:
@@ -37,7 +37,7 b' A few obvious properties that are not cu'
37 '''
37 '''
38
38
39 import bisect, collections, itertools, json, os, random, time, sys
39 import bisect, collections, itertools, json, os, random, time, sys
40 from mercurial import cmdutil, context, patch, scmutil, util, hg
40 from mercurial import cmdutil, context, patch, scmutil, util, hg, error
41 from mercurial.i18n import _
41 from mercurial.i18n import _
42 from mercurial.node import nullrev, nullid, short
42 from mercurial.node import nullrev, nullid, short
43
43
@@ -254,7 +254,7 b' def synthesize(ui, repo, descpath, **opt'
254 try:
254 try:
255 fp = hg.openpath(ui, descpath)
255 fp = hg.openpath(ui, descpath)
256 except Exception as err:
256 except Exception as err:
257 raise util.Abort('%s: %s' % (descpath, err[0].strerror))
257 raise error.Abort('%s: %s' % (descpath, err[0].strerror))
258 desc = json.load(fp)
258 desc = json.load(fp)
259 fp.close()
259 fp.close()
260
260
@@ -286,7 +286,7 b' def synthesize(ui, repo, descpath, **opt'
286 try:
286 try:
287 fp = open(dictfile, 'rU')
287 fp = open(dictfile, 'rU')
288 except IOError as err:
288 except IOError as err:
289 raise util.Abort('%s: %s' % (dictfile, err.strerror))
289 raise error.Abort('%s: %s' % (dictfile, err.strerror))
290 words = fp.read().splitlines()
290 words = fp.read().splitlines()
291 fp.close()
291 fp.close()
292
292
@@ -192,7 +192,7 b' 3) Deny access to a file to anyone but u'
192 '''
192 '''
193
193
194 from mercurial.i18n import _
194 from mercurial.i18n import _
195 from mercurial import util, match
195 from mercurial import util, match, error
196 import getpass, urllib
196 import getpass, urllib
197
197
198 # Note for extension authors: ONLY specify testedwith = 'internal' for
198 # Note for extension authors: ONLY specify testedwith = 'internal' for
@@ -213,7 +213,7 b' def _getusers(ui, group):'
213 try:
213 try:
214 return util.groupmembers(group)
214 return util.groupmembers(group)
215 except KeyError:
215 except KeyError:
216 raise util.Abort(_("group '%s' is undefined") % group)
216 raise error.Abort(_("group '%s' is undefined") % group)
217
217
218 def _usermatch(ui, user, usersorgroups):
218 def _usermatch(ui, user, usersorgroups):
219
219
@@ -268,7 +268,7 b' def buildmatch(ui, repo, user, key):'
268
268
269 def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
269 def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
270 if hooktype not in ['pretxnchangegroup', 'pretxncommit']:
270 if hooktype not in ['pretxnchangegroup', 'pretxncommit']:
271 raise util.Abort(_('config error - hook type "%s" cannot stop '
271 raise error.Abort(_('config error - hook type "%s" cannot stop '
272 'incoming changesets nor commits') % hooktype)
272 'incoming changesets nor commits') % hooktype)
273 if (hooktype == 'pretxnchangegroup' and
273 if (hooktype == 'pretxnchangegroup' and
274 source not in ui.config('acl', 'sources', 'serve').split()):
274 source not in ui.config('acl', 'sources', 'serve').split()):
@@ -301,11 +301,11 b' def hook(ui, repo, hooktype, node=None, '
301 ctx = repo[rev]
301 ctx = repo[rev]
302 branch = ctx.branch()
302 branch = ctx.branch()
303 if denybranches and denybranches(branch):
303 if denybranches and denybranches(branch):
304 raise util.Abort(_('acl: user "%s" denied on branch "%s"'
304 raise error.Abort(_('acl: user "%s" denied on branch "%s"'
305 ' (changeset "%s")')
305 ' (changeset "%s")')
306 % (user, branch, ctx))
306 % (user, branch, ctx))
307 if allowbranches and not allowbranches(branch):
307 if allowbranches and not allowbranches(branch):
308 raise util.Abort(_('acl: user "%s" not allowed on branch "%s"'
308 raise error.Abort(_('acl: user "%s" not allowed on branch "%s"'
309 ' (changeset "%s")')
309 ' (changeset "%s")')
310 % (user, branch, ctx))
310 % (user, branch, ctx))
311 ui.debug('acl: branch access granted: "%s" on branch "%s"\n'
311 ui.debug('acl: branch access granted: "%s" on branch "%s"\n'
@@ -313,9 +313,9 b' def hook(ui, repo, hooktype, node=None, '
313
313
314 for f in ctx.files():
314 for f in ctx.files():
315 if deny and deny(f):
315 if deny and deny(f):
316 raise util.Abort(_('acl: user "%s" denied on "%s"'
316 raise error.Abort(_('acl: user "%s" denied on "%s"'
317 ' (changeset "%s")') % (user, f, ctx))
317 ' (changeset "%s")') % (user, f, ctx))
318 if allow and not allow(f):
318 if allow and not allow(f):
319 raise util.Abort(_('acl: user "%s" not allowed on "%s"'
319 raise error.Abort(_('acl: user "%s" not allowed on "%s"'
320 ' (changeset "%s")') % (user, f, ctx))
320 ' (changeset "%s")') % (user, f, ctx))
321 ui.debug('acl: path access granted: "%s"\n' % ctx)
321 ui.debug('acl: path access granted: "%s"\n' % ctx)
@@ -279,7 +279,7 b' All the above add a comment to the Bugzi'
279
279
280 from mercurial.i18n import _
280 from mercurial.i18n import _
281 from mercurial.node import short
281 from mercurial.node import short
282 from mercurial import cmdutil, mail, util
282 from mercurial import cmdutil, mail, util, error
283 import re, time, urlparse, xmlrpclib
283 import re, time, urlparse, xmlrpclib
284
284
285 # Note for extension authors: ONLY specify testedwith = 'internal' for
285 # Note for extension authors: ONLY specify testedwith = 'internal' for
@@ -358,7 +358,7 b' class bzmysql(bzaccess):'
358 import MySQLdb as mysql
358 import MySQLdb as mysql
359 bzmysql._MySQLdb = mysql
359 bzmysql._MySQLdb = mysql
360 except ImportError as err:
360 except ImportError as err:
361 raise util.Abort(_('python mysql support not available: %s') % err)
361 raise error.Abort(_('python mysql support not available: %s') % err)
362
362
363 bzaccess.__init__(self, ui)
363 bzaccess.__init__(self, ui)
364
364
@@ -392,7 +392,7 b' class bzmysql(bzaccess):'
392 self.run('select fieldid from fielddefs where name = "longdesc"')
392 self.run('select fieldid from fielddefs where name = "longdesc"')
393 ids = self.cursor.fetchall()
393 ids = self.cursor.fetchall()
394 if len(ids) != 1:
394 if len(ids) != 1:
395 raise util.Abort(_('unknown database schema'))
395 raise error.Abort(_('unknown database schema'))
396 return ids[0][0]
396 return ids[0][0]
397
397
398 def filter_real_bug_ids(self, bugs):
398 def filter_real_bug_ids(self, bugs):
@@ -437,7 +437,7 b' class bzmysql(bzaccess):'
437 ret = fp.close()
437 ret = fp.close()
438 if ret:
438 if ret:
439 self.ui.warn(out)
439 self.ui.warn(out)
440 raise util.Abort(_('bugzilla notify command %s') %
440 raise error.Abort(_('bugzilla notify command %s') %
441 util.explainexit(ret)[0])
441 util.explainexit(ret)[0])
442 self.ui.status(_('done\n'))
442 self.ui.status(_('done\n'))
443
443
@@ -470,12 +470,12 b' class bzmysql(bzaccess):'
470 try:
470 try:
471 defaultuser = self.ui.config('bugzilla', 'bzuser')
471 defaultuser = self.ui.config('bugzilla', 'bzuser')
472 if not defaultuser:
472 if not defaultuser:
473 raise util.Abort(_('cannot find bugzilla user id for %s') %
473 raise error.Abort(_('cannot find bugzilla user id for %s') %
474 user)
474 user)
475 userid = self.get_user_id(defaultuser)
475 userid = self.get_user_id(defaultuser)
476 user = defaultuser
476 user = defaultuser
477 except KeyError:
477 except KeyError:
478 raise util.Abort(_('cannot find bugzilla user id for %s or %s')
478 raise error.Abort(_('cannot find bugzilla user id for %s or %s')
479 % (user, defaultuser))
479 % (user, defaultuser))
480 return (user, userid)
480 return (user, userid)
481
481
@@ -517,7 +517,7 b' class bzmysql_3_0(bzmysql_2_18):'
517 self.run('select id from fielddefs where name = "longdesc"')
517 self.run('select id from fielddefs where name = "longdesc"')
518 ids = self.cursor.fetchall()
518 ids = self.cursor.fetchall()
519 if len(ids) != 1:
519 if len(ids) != 1:
520 raise util.Abort(_('unknown database schema'))
520 raise error.Abort(_('unknown database schema'))
521 return ids[0][0]
521 return ids[0][0]
522
522
523 # Bugzilla via XMLRPC interface.
523 # Bugzilla via XMLRPC interface.
@@ -705,7 +705,7 b' class bzxmlrpcemail(bzxmlrpc):'
705
705
706 self.bzemail = self.ui.config('bugzilla', 'bzemail')
706 self.bzemail = self.ui.config('bugzilla', 'bzemail')
707 if not self.bzemail:
707 if not self.bzemail:
708 raise util.Abort(_("configuration 'bzemail' missing"))
708 raise error.Abort(_("configuration 'bzemail' missing"))
709 mail.validateconfig(self.ui)
709 mail.validateconfig(self.ui)
710
710
711 def makecommandline(self, fieldname, value):
711 def makecommandline(self, fieldname, value):
@@ -735,8 +735,8 b' class bzxmlrpcemail(bzxmlrpc):'
735 matches = self.bzproxy.User.get({'match': [user],
735 matches = self.bzproxy.User.get({'match': [user],
736 'token': self.bztoken})
736 'token': self.bztoken})
737 if not matches['users']:
737 if not matches['users']:
738 raise util.Abort(_("default bugzilla user %s email not found") %
738 raise error.Abort(_("default bugzilla user %s email not found")
739 user)
739 % user)
740 user = matches['users'][0]['email']
740 user = matches['users'][0]['email']
741 commands.append(self.makecommandline("id", bugid))
741 commands.append(self.makecommandline("id", bugid))
742
742
@@ -789,7 +789,7 b' class bugzilla(object):'
789 try:
789 try:
790 bzclass = bugzilla._versions[bzversion]
790 bzclass = bugzilla._versions[bzversion]
791 except KeyError:
791 except KeyError:
792 raise util.Abort(_('bugzilla version %s not supported') %
792 raise error.Abort(_('bugzilla version %s not supported') %
793 bzversion)
793 bzversion)
794 self.bzdriver = bzclass(self.ui)
794 self.bzdriver = bzclass(self.ui)
795
795
@@ -900,7 +900,7 b' def hook(ui, repo, hooktype, node=None, '
900 bugzilla bug id. only add a comment once per bug, so same change
900 bugzilla bug id. only add a comment once per bug, so same change
901 seen multiple times does not fill bug with duplicate data.'''
901 seen multiple times does not fill bug with duplicate data.'''
902 if node is None:
902 if node is None:
903 raise util.Abort(_('hook type %s does not pass a changeset id') %
903 raise error.Abort(_('hook type %s does not pass a changeset id') %
904 hooktype)
904 hooktype)
905 try:
905 try:
906 bz = bugzilla(ui, repo)
906 bz = bugzilla(ui, repo)
@@ -911,4 +911,4 b' def hook(ui, repo, hooktype, node=None, '
911 bz.update(bug, bugs[bug], ctx)
911 bz.update(bug, bugs[bug], ctx)
912 bz.notify(bugs, util.email(ctx.user()))
912 bz.notify(bugs, util.email(ctx.user()))
913 except Exception as e:
913 except Exception as e:
914 raise util.Abort(_('Bugzilla error: %s') % e)
914 raise error.Abort(_('Bugzilla error: %s') % e)
@@ -43,47 +43,47 b" testedwith = 'internal'"
43 _('-r REV [-t TEXT] [FILE]'))
43 _('-r REV [-t TEXT] [FILE]'))
44 def censor(ui, repo, path, rev='', tombstone='', **opts):
44 def censor(ui, repo, path, rev='', tombstone='', **opts):
45 if not path:
45 if not path:
46 raise util.Abort(_('must specify file path to censor'))
46 raise error.Abort(_('must specify file path to censor'))
47 if not rev:
47 if not rev:
48 raise util.Abort(_('must specify revision to censor'))
48 raise error.Abort(_('must specify revision to censor'))
49
49
50 wctx = repo[None]
50 wctx = repo[None]
51
51
52 m = scmutil.match(wctx, (path,))
52 m = scmutil.match(wctx, (path,))
53 if m.anypats() or len(m.files()) != 1:
53 if m.anypats() or len(m.files()) != 1:
54 raise util.Abort(_('can only specify an explicit filename'))
54 raise error.Abort(_('can only specify an explicit filename'))
55 path = m.files()[0]
55 path = m.files()[0]
56 flog = repo.file(path)
56 flog = repo.file(path)
57 if not len(flog):
57 if not len(flog):
58 raise util.Abort(_('cannot censor file with no history'))
58 raise error.Abort(_('cannot censor file with no history'))
59
59
60 rev = scmutil.revsingle(repo, rev, rev).rev()
60 rev = scmutil.revsingle(repo, rev, rev).rev()
61 try:
61 try:
62 ctx = repo[rev]
62 ctx = repo[rev]
63 except KeyError:
63 except KeyError:
64 raise util.Abort(_('invalid revision identifier %s') % rev)
64 raise error.Abort(_('invalid revision identifier %s') % rev)
65
65
66 try:
66 try:
67 fctx = ctx.filectx(path)
67 fctx = ctx.filectx(path)
68 except error.LookupError:
68 except error.LookupError:
69 raise util.Abort(_('file does not exist at revision %s') % rev)
69 raise error.Abort(_('file does not exist at revision %s') % rev)
70
70
71 fnode = fctx.filenode()
71 fnode = fctx.filenode()
72 headctxs = [repo[c] for c in repo.heads()]
72 headctxs = [repo[c] for c in repo.heads()]
73 heads = [c for c in headctxs if path in c and c.filenode(path) == fnode]
73 heads = [c for c in headctxs if path in c and c.filenode(path) == fnode]
74 if heads:
74 if heads:
75 headlist = ', '.join([short(c.node()) for c in heads])
75 headlist = ', '.join([short(c.node()) for c in heads])
76 raise util.Abort(_('cannot censor file in heads (%s)') % headlist,
76 raise error.Abort(_('cannot censor file in heads (%s)') % headlist,
77 hint=_('clean/delete and commit first'))
77 hint=_('clean/delete and commit first'))
78
78
79 wp = wctx.parents()
79 wp = wctx.parents()
80 if ctx.node() in [p.node() for p in wp]:
80 if ctx.node() in [p.node() for p in wp]:
81 raise util.Abort(_('cannot censor working directory'),
81 raise error.Abort(_('cannot censor working directory'),
82 hint=_('clean/delete/update first'))
82 hint=_('clean/delete/update first'))
83
83
84 flogv = flog.version & 0xFFFF
84 flogv = flog.version & 0xFFFF
85 if flogv != revlog.REVLOGNG:
85 if flogv != revlog.REVLOGNG:
86 raise util.Abort(
86 raise error.Abort(
87 _('censor does not support revlog version %d') % (flogv,))
87 _('censor does not support revlog version %d') % (flogv,))
88
88
89 tombstone = filelog.packmeta({"censored": tombstone}, "")
89 tombstone = filelog.packmeta({"censored": tombstone}, "")
@@ -91,7 +91,7 b" def censor(ui, repo, path, rev='', tombs"
91 crev = fctx.filerev()
91 crev = fctx.filerev()
92
92
93 if len(tombstone) > flog.rawsize(crev):
93 if len(tombstone) > flog.rawsize(crev):
94 raise util.Abort(_(
94 raise error.Abort(_(
95 'censor tombstone must be no longer than censored data'))
95 'censor tombstone must be no longer than censored data'))
96
96
97 # Using two files instead of one makes it easy to rewrite entry-by-entry
97 # Using two files instead of one makes it easy to rewrite entry-by-entry
@@ -9,7 +9,7 b''
9 '''command to display statistics about repository history'''
9 '''command to display statistics about repository history'''
10
10
11 from mercurial.i18n import _
11 from mercurial.i18n import _
12 from mercurial import patch, cmdutil, scmutil, util, commands
12 from mercurial import patch, cmdutil, scmutil, util, commands, error
13 from mercurial import encoding
13 from mercurial import encoding
14 import os
14 import os
15 import time, datetime
15 import time, datetime
@@ -27,7 +27,7 b' def maketemplater(ui, repo, tmpl):'
27 t = cmdutil.changeset_templater(ui, repo, False, None, tmpl,
27 t = cmdutil.changeset_templater(ui, repo, False, None, tmpl,
28 None, False)
28 None, False)
29 except SyntaxError as inst:
29 except SyntaxError as inst:
30 raise util.Abort(inst.args[0])
30 raise error.Abort(inst.args[0])
31 return t
31 return t
32
32
33 def changedlines(ui, repo, ctx1, ctx2, fns):
33 def changedlines(ui, repo, ctx1, ctx2, fns):
@@ -9,7 +9,7 b''
9 # it cannot access 'bar' repositories, but they were never used very much
9 # it cannot access 'bar' repositories, but they were never used very much
10
10
11 import os
11 import os
12 from mercurial import demandimport
12 from mercurial import demandimport, error
13 # these do not work with demandimport, blacklist
13 # these do not work with demandimport, blacklist
14 demandimport.ignore.extend([
14 demandimport.ignore.extend([
15 'bzrlib.transactions',
15 'bzrlib.transactions',
@@ -18,7 +18,7 b' demandimport.ignore.extend(['
18 ])
18 ])
19
19
20 from mercurial.i18n import _
20 from mercurial.i18n import _
21 from mercurial import util
21 from mercurial import error
22 from common import NoRepo, commit, converter_source
22 from common import NoRepo, commit, converter_source
23
23
24 try:
24 try:
@@ -108,7 +108,8 b' class bzr_source(converter_source):'
108 pass
108 pass
109 revid = info.rev_id
109 revid = info.rev_id
110 if revid is None:
110 if revid is None:
111 raise util.Abort(_('%s is not a valid revision') % self.revs[0])
111 raise error.Abort(_('%s is not a valid revision')
112 % self.revs[0])
112 heads = [revid]
113 heads = [revid]
113 # Empty repositories return 'null:', which cannot be retrieved
114 # Empty repositories return 'null:', which cannot be retrieved
114 heads = [h for h in heads if h != 'null:']
115 heads = [h for h in heads if h != 'null:']
@@ -127,7 +128,7 b' class bzr_source(converter_source):'
127 if kind == 'symlink':
128 if kind == 'symlink':
128 target = revtree.get_symlink_target(fileid)
129 target = revtree.get_symlink_target(fileid)
129 if target is None:
130 if target is None:
130 raise util.Abort(_('%s.%s symlink has no target')
131 raise error.Abort(_('%s.%s symlink has no target')
131 % (name, rev))
132 % (name, rev))
132 return target, mode
133 return target, mode
133 else:
134 else:
@@ -136,7 +137,7 b' class bzr_source(converter_source):'
136
137
137 def getchanges(self, version, full):
138 def getchanges(self, version, full):
138 if full:
139 if full:
139 raise util.Abort(_("convert from cvs do not support --full"))
140 raise error.Abort(_("convert from cvs do not support --full"))
140 self._modecache = {}
141 self._modecache = {}
141 self._revtree = self.sourcerepo.revision_tree(version)
142 self._revtree = self.sourcerepo.revision_tree(version)
142 # get the parentids from the cache
143 # get the parentids from the cache
@@ -7,7 +7,7 b''
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
@@ -32,7 +32,7 b' 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)
@@ -73,7 +73,7 b' class converter_source(object):'
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):
@@ -369,7 +369,7 b' class commandline(object):'
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)
@@ -446,7 +446,7 b' class mapfile(dict):'
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:
@@ -459,7 +459,7 b' class mapfile(dict):'
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()
@@ -18,7 +18,7 b' from p4 import p4_source'
18 import filemap
18 import filemap
19
19
20 import os, shutil, shlex
20 import os, shutil, shlex
21 from mercurial import hg, util, encoding
21 from mercurial import hg, util, encoding, error
22 from mercurial.i18n import _
22 from mercurial.i18n import _
23
23
24 orig_encoding = 'ascii'
24 orig_encoding = 'ascii'
@@ -82,7 +82,7 b' sink_converters = ['
82 def convertsource(ui, path, type, revs):
82 def convertsource(ui, path, type, revs):
83 exceptions = []
83 exceptions = []
84 if type and type not in [s[0] for s in source_converters]:
84 if type and type not in [s[0] for s in source_converters]:
85 raise util.Abort(_('%s: invalid source repository type') % type)
85 raise error.Abort(_('%s: invalid source repository type') % type)
86 for name, source, sortmode in source_converters:
86 for name, source, sortmode in source_converters:
87 try:
87 try:
88 if not type or name == type:
88 if not type or name == type:
@@ -92,11 +92,11 b' def convertsource(ui, path, type, revs):'
92 if not ui.quiet:
92 if not ui.quiet:
93 for inst in exceptions:
93 for inst in exceptions:
94 ui.write("%s\n" % inst)
94 ui.write("%s\n" % inst)
95 raise util.Abort(_('%s: missing or unsupported repository') % path)
95 raise error.Abort(_('%s: missing or unsupported repository') % path)
96
96
97 def convertsink(ui, path, type):
97 def convertsink(ui, path, type):
98 if type and type not in [s[0] for s in sink_converters]:
98 if type and type not in [s[0] for s in sink_converters]:
99 raise util.Abort(_('%s: invalid destination repository type') % type)
99 raise error.Abort(_('%s: invalid destination repository type') % type)
100 for name, sink in sink_converters:
100 for name, sink in sink_converters:
101 try:
101 try:
102 if not type or name == type:
102 if not type or name == type:
@@ -104,8 +104,8 b' def convertsink(ui, path, type):'
104 except NoRepo as inst:
104 except NoRepo as inst:
105 ui.note(_("convert: %s\n") % inst)
105 ui.note(_("convert: %s\n") % inst)
106 except MissingTool as inst:
106 except MissingTool as inst:
107 raise util.Abort('%s\n' % inst)
107 raise error.Abort('%s\n' % inst)
108 raise util.Abort(_('%s: unknown repository type') % path)
108 raise error.Abort(_('%s: unknown repository type') % path)
109
109
110 class progresssource(object):
110 class progresssource(object):
111 def __init__(self, ui, source, filecount):
111 def __init__(self, ui, source, filecount):
@@ -185,7 +185,7 b' class converter(object):'
185 line = list(lex)
185 line = list(lex)
186 # check number of parents
186 # check number of parents
187 if not (2 <= len(line) <= 3):
187 if not (2 <= len(line) <= 3):
188 raise util.Abort(_('syntax error in %s(%d): child parent1'
188 raise error.Abort(_('syntax error in %s(%d): child parent1'
189 '[,parent2] expected') % (path, i + 1))
189 '[,parent2] expected') % (path, i + 1))
190 for part in line:
190 for part in line:
191 self.source.checkrevformat(part)
191 self.source.checkrevformat(part)
@@ -196,7 +196,7 b' class converter(object):'
196 m[child] = p1 + p2
196 m[child] = p1 + p2
197 # if file does not exist or error reading, exit
197 # if file does not exist or error reading, exit
198 except IOError:
198 except IOError:
199 raise util.Abort(_('splicemap file not found or error reading %s:')
199 raise error.Abort(_('splicemap file not found or error reading %s:')
200 % path)
200 % path)
201 return m
201 return m
202
202
@@ -247,7 +247,7 b' class converter(object):'
247 continue
247 continue
248 # Parent is not in dest and not being converted, not good
248 # Parent is not in dest and not being converted, not good
249 if p not in parents:
249 if p not in parents:
250 raise util.Abort(_('unknown splice map parent: %s') % p)
250 raise error.Abort(_('unknown splice map parent: %s') % p)
251 pc.append(p)
251 pc.append(p)
252 parents[c] = pc
252 parents[c] = pc
253
253
@@ -343,7 +343,7 b' class converter(object):'
343 elif sortmode == 'closesort':
343 elif sortmode == 'closesort':
344 picknext = makeclosesorter()
344 picknext = makeclosesorter()
345 else:
345 else:
346 raise util.Abort(_('unknown sort mode: %s') % sortmode)
346 raise error.Abort(_('unknown sort mode: %s') % sortmode)
347
347
348 children, actives = mapchildren(parents)
348 children, actives = mapchildren(parents)
349
349
@@ -361,7 +361,7 b' class converter(object):'
361 try:
361 try:
362 pendings[c].remove(n)
362 pendings[c].remove(n)
363 except ValueError:
363 except ValueError:
364 raise util.Abort(_('cycle detected between %s and %s')
364 raise error.Abort(_('cycle detected between %s and %s')
365 % (recode(c), recode(n)))
365 % (recode(c), recode(n)))
366 if not pendings[c]:
366 if not pendings[c]:
367 # Parents are converted, node is eligible
367 # Parents are converted, node is eligible
@@ -369,7 +369,7 b' class converter(object):'
369 pendings[c] = None
369 pendings[c] = None
370
370
371 if len(s) != len(parents):
371 if len(s) != len(parents):
372 raise util.Abort(_("not all revisions were sorted"))
372 raise error.Abort(_("not all revisions were sorted"))
373
373
374 return s
374 return s
375
375
@@ -556,16 +556,17 b' def convert(ui, src, dest=None, revmapfi'
556 sortmodes = ('branchsort', 'datesort', 'sourcesort', 'closesort')
556 sortmodes = ('branchsort', 'datesort', 'sourcesort', 'closesort')
557 sortmode = [m for m in sortmodes if opts.get(m)]
557 sortmode = [m for m in sortmodes if opts.get(m)]
558 if len(sortmode) > 1:
558 if len(sortmode) > 1:
559 raise util.Abort(_('more than one sort mode specified'))
559 raise error.Abort(_('more than one sort mode specified'))
560 if sortmode:
560 if sortmode:
561 sortmode = sortmode[0]
561 sortmode = sortmode[0]
562 else:
562 else:
563 sortmode = defaultsort
563 sortmode = defaultsort
564
564
565 if sortmode == 'sourcesort' and not srcc.hasnativeorder():
565 if sortmode == 'sourcesort' and not srcc.hasnativeorder():
566 raise util.Abort(_('--sourcesort is not supported by this data source'))
566 raise error.Abort(_('--sourcesort is not supported by this data source')
567 )
567 if sortmode == 'closesort' and not srcc.hasnativeclose():
568 if sortmode == 'closesort' and not srcc.hasnativeclose():
568 raise util.Abort(_('--closesort is not supported by this data source'))
569 raise error.Abort(_('--closesort is not supported by this data source'))
569
570
570 fmap = opts.get('filemap')
571 fmap = opts.get('filemap')
571 if fmap:
572 if fmap:
@@ -7,7 +7,7 b''
7
7
8 import os, re, socket, errno
8 import os, re, socket, errno
9 from cStringIO import StringIO
9 from cStringIO import StringIO
10 from mercurial import encoding, util
10 from mercurial import encoding, util, error
11 from mercurial.i18n import _
11 from mercurial.i18n import _
12
12
13 from common import NoRepo, commit, converter_source, checktool
13 from common import NoRepo, commit, converter_source, checktool
@@ -43,14 +43,14 b' class convert_cvs(converter_source):'
43 maxrev = 0
43 maxrev = 0
44 if self.revs:
44 if self.revs:
45 if len(self.revs) > 1:
45 if len(self.revs) > 1:
46 raise util.Abort(_('cvs source does not support specifying '
46 raise error.Abort(_('cvs source does not support specifying '
47 'multiple revs'))
47 'multiple revs'))
48 # TODO: handle tags
48 # TODO: handle tags
49 try:
49 try:
50 # patchset number?
50 # patchset number?
51 maxrev = int(self.revs[0])
51 maxrev = int(self.revs[0])
52 except ValueError:
52 except ValueError:
53 raise util.Abort(_('revision %s is not a patchset number')
53 raise error.Abort(_('revision %s is not a patchset number')
54 % self.revs[0])
54 % self.revs[0])
55
55
56 d = os.getcwd()
56 d = os.getcwd()
@@ -150,7 +150,7 b' class convert_cvs(converter_source):'
150 sck.send("\n".join(["BEGIN AUTH REQUEST", root, user, passw,
150 sck.send("\n".join(["BEGIN AUTH REQUEST", root, user, passw,
151 "END AUTH REQUEST", ""]))
151 "END AUTH REQUEST", ""]))
152 if sck.recv(128) != "I LOVE YOU\n":
152 if sck.recv(128) != "I LOVE YOU\n":
153 raise util.Abort(_("CVS pserver authentication failed"))
153 raise error.Abort(_("CVS pserver authentication failed"))
154
154
155 self.writep = self.readp = sck.makefile('r+')
155 self.writep = self.readp = sck.makefile('r+')
156
156
@@ -193,7 +193,7 b' class convert_cvs(converter_source):'
193 self.writep.flush()
193 self.writep.flush()
194 r = self.readp.readline()
194 r = self.readp.readline()
195 if not r.startswith("Valid-requests"):
195 if not r.startswith("Valid-requests"):
196 raise util.Abort(_('unexpected response from CVS server '
196 raise error.Abort(_('unexpected response from CVS server '
197 '(expected "Valid-requests", but got %r)')
197 '(expected "Valid-requests", but got %r)')
198 % r)
198 % r)
199 if "UseUnchanged" in r:
199 if "UseUnchanged" in r:
@@ -215,7 +215,7 b' class convert_cvs(converter_source):'
215 while count > 0:
215 while count > 0:
216 data = fp.read(min(count, chunksize))
216 data = fp.read(min(count, chunksize))
217 if not data:
217 if not data:
218 raise util.Abort(_("%d bytes missing from remote file")
218 raise error.Abort(_("%d bytes missing from remote file")
219 % count)
219 % count)
220 count -= len(data)
220 count -= len(data)
221 output.write(data)
221 output.write(data)
@@ -252,18 +252,18 b' class convert_cvs(converter_source):'
252 else:
252 else:
253 if line == "ok\n":
253 if line == "ok\n":
254 if mode is None:
254 if mode is None:
255 raise util.Abort(_('malformed response from CVS'))
255 raise error.Abort(_('malformed response from CVS'))
256 return (data, "x" in mode and "x" or "")
256 return (data, "x" in mode and "x" or "")
257 elif line.startswith("E "):
257 elif line.startswith("E "):
258 self.ui.warn(_("cvs server: %s\n") % line[2:])
258 self.ui.warn(_("cvs server: %s\n") % line[2:])
259 elif line.startswith("Remove"):
259 elif line.startswith("Remove"):
260 self.readp.readline()
260 self.readp.readline()
261 else:
261 else:
262 raise util.Abort(_("unknown CVS response: %s") % line)
262 raise error.Abort(_("unknown CVS response: %s") % line)
263
263
264 def getchanges(self, rev, full):
264 def getchanges(self, rev, full):
265 if full:
265 if full:
266 raise util.Abort(_("convert from cvs do not support --full"))
266 raise error.Abort(_("convert from cvs do not support --full"))
267 self._parse()
267 self._parse()
268 return sorted(self.files[rev].iteritems()), {}, set()
268 return sorted(self.files[rev].iteritems()), {}, set()
269
269
@@ -7,7 +7,7 b''
7
7
8 from common import NoRepo, checktool, commandline, commit, converter_source
8 from common import NoRepo, checktool, commandline, commit, converter_source
9 from mercurial.i18n import _
9 from mercurial.i18n import _
10 from mercurial import util
10 from mercurial import util, error
11 import os, shutil, tempfile, re, errno
11 import os, shutil, tempfile, re, errno
12
12
13 # The naming drift of ElementTree is fun!
13 # The naming drift of ElementTree is fun!
@@ -39,11 +39,11 b' class darcs_source(converter_source, com'
39 checktool('darcs')
39 checktool('darcs')
40 version = self.run0('--version').splitlines()[0].strip()
40 version = self.run0('--version').splitlines()[0].strip()
41 if version < '2.1':
41 if version < '2.1':
42 raise util.Abort(_('darcs version 2.1 or newer needed (found %r)') %
42 raise error.Abort(_('darcs version 2.1 or newer needed (found %r)')
43 version)
43 % version)
44
44
45 if "ElementTree" not in globals():
45 if "ElementTree" not in globals():
46 raise util.Abort(_("Python ElementTree module is not available"))
46 raise error.Abort(_("Python ElementTree module is not available"))
47
47
48 self.path = os.path.realpath(path)
48 self.path = os.path.realpath(path)
49
49
@@ -158,7 +158,7 b' class darcs_source(converter_source, com'
158
158
159 def getchanges(self, rev, full):
159 def getchanges(self, rev, full):
160 if full:
160 if full:
161 raise util.Abort(_("convert from darcs do not support --full"))
161 raise error.Abort(_("convert from darcs do not support --full"))
162 copies = {}
162 copies = {}
163 changes = []
163 changes = []
164 man = None
164 man = None
@@ -192,7 +192,7 b' class darcs_source(converter_source, com'
192
192
193 def getfile(self, name, rev):
193 def getfile(self, name, rev):
194 if rev != self.lastrev:
194 if rev != self.lastrev:
195 raise util.Abort(_('internal calling inconsistency'))
195 raise error.Abort(_('internal calling inconsistency'))
196 path = os.path.join(self.tmppath, name)
196 path = os.path.join(self.tmppath, name)
197 try:
197 try:
198 data = util.readfile(path)
198 data = util.readfile(path)
@@ -7,7 +7,7 b''
7 import posixpath
7 import posixpath
8 import shlex
8 import shlex
9 from mercurial.i18n import _
9 from mercurial.i18n import _
10 from mercurial import util, error
10 from mercurial import error
11 from common import SKIPREV, converter_source
11 from common import SKIPREV, converter_source
12
12
13 def rpairs(path):
13 def rpairs(path):
@@ -45,7 +45,7 b' class filemapper(object):'
45 self.targetprefixes = None
45 self.targetprefixes = None
46 if path:
46 if path:
47 if self.parse(path):
47 if self.parse(path):
48 raise util.Abort(_('errors in filemap'))
48 raise error.Abort(_('errors in filemap'))
49
49
50 def parse(self, path):
50 def parse(self, path):
51 errs = 0
51 errs = 0
@@ -291,7 +291,7 b' class filemap_source(converter_source):'
291 try:
291 try:
292 files = self.base.getchangedfiles(rev, i)
292 files = self.base.getchangedfiles(rev, i)
293 except NotImplementedError:
293 except NotImplementedError:
294 raise util.Abort(_("source repository doesn't support --filemap"))
294 raise error.Abort(_("source repository doesn't support --filemap"))
295 for f in files:
295 for f in files:
296 if self.filemapper(f):
296 if self.filemapper(f):
297 return True
297 return True
@@ -97,7 +97,7 b' class convert_git(converter_source):'
97 # The default value (50) is based on the default for 'git diff'.
97 # The default value (50) is based on the default for 'git diff'.
98 similarity = ui.configint('convert', 'git.similarity', default=50)
98 similarity = ui.configint('convert', 'git.similarity', default=50)
99 if similarity < 0 or similarity > 100:
99 if similarity < 0 or similarity > 100:
100 raise util.Abort(_('similarity must be between 0 and 100'))
100 raise error.Abort(_('similarity must be between 0 and 100'))
101 if similarity > 0:
101 if similarity > 0:
102 self.simopt = '-C%d%%' % similarity
102 self.simopt = '-C%d%%' % similarity
103 findcopiesharder = ui.configbool('convert', 'git.findcopiesharder',
103 findcopiesharder = ui.configbool('convert', 'git.findcopiesharder',
@@ -123,14 +123,14 b' class convert_git(converter_source):'
123 heads, ret = self.gitread('git rev-parse --branches --remotes')
123 heads, ret = self.gitread('git rev-parse --branches --remotes')
124 heads = heads.splitlines()
124 heads = heads.splitlines()
125 if ret:
125 if ret:
126 raise util.Abort(_('cannot retrieve git heads'))
126 raise error.Abort(_('cannot retrieve git heads'))
127 else:
127 else:
128 heads = []
128 heads = []
129 for rev in self.revs:
129 for rev in self.revs:
130 rawhead, ret = self.gitread("git rev-parse --verify %s" % rev)
130 rawhead, ret = self.gitread("git rev-parse --verify %s" % rev)
131 heads.append(rawhead[:-1])
131 heads.append(rawhead[:-1])
132 if ret:
132 if ret:
133 raise util.Abort(_('cannot retrieve git head "%s"') % rev)
133 raise error.Abort(_('cannot retrieve git head "%s"') % rev)
134 return heads
134 return heads
135
135
136 def catfile(self, rev, type):
136 def catfile(self, rev, type):
@@ -140,11 +140,11 b' class convert_git(converter_source):'
140 self.catfilepipe[0].flush()
140 self.catfilepipe[0].flush()
141 info = self.catfilepipe[1].readline().split()
141 info = self.catfilepipe[1].readline().split()
142 if info[1] != type:
142 if info[1] != type:
143 raise util.Abort(_('cannot read %r object at %s') % (type, rev))
143 raise error.Abort(_('cannot read %r object at %s') % (type, rev))
144 size = int(info[2])
144 size = int(info[2])
145 data = self.catfilepipe[1].read(size)
145 data = self.catfilepipe[1].read(size)
146 if len(data) < size:
146 if len(data) < size:
147 raise util.Abort(_('cannot read %r object at %s: unexpected size')
147 raise error.Abort(_('cannot read %r object at %s: unexpected size')
148 % (type, rev))
148 % (type, rev))
149 # read the trailing newline
149 # read the trailing newline
150 self.catfilepipe[1].read(1)
150 self.catfilepipe[1].read(1)
@@ -210,7 +210,7 b' class convert_git(converter_source):'
210
210
211 def getchanges(self, version, full):
211 def getchanges(self, version, full):
212 if full:
212 if full:
213 raise util.Abort(_("convert from git do not support --full"))
213 raise error.Abort(_("convert from git do not support --full"))
214 self.modecache = {}
214 self.modecache = {}
215 fh = self.gitopen("git diff-tree -z --root -m -r %s %s" % (
215 fh = self.gitopen("git diff-tree -z --root -m -r %s %s" % (
216 self.simopt, version))
216 self.simopt, version))
@@ -283,7 +283,7 b' class convert_git(converter_source):'
283 copies[fdest] = f
283 copies[fdest] = f
284 entry = None
284 entry = None
285 if fh.close():
285 if fh.close():
286 raise util.Abort(_('cannot read changes in %s') % version)
286 raise error.Abort(_('cannot read changes in %s') % version)
287
287
288 if subexists[0]:
288 if subexists[0]:
289 if subdeleted[0]:
289 if subdeleted[0]:
@@ -342,13 +342,13 b' class convert_git(converter_source):'
342 for line in fh:
342 for line in fh:
343 line = line.strip()
343 line = line.strip()
344 if line.startswith("error:") or line.startswith("fatal:"):
344 if line.startswith("error:") or line.startswith("fatal:"):
345 raise util.Abort(_('cannot read tags from %s') % self.path)
345 raise error.Abort(_('cannot read tags from %s') % self.path)
346 node, tag = line.split(None, 1)
346 node, tag = line.split(None, 1)
347 if not tag.startswith(prefix):
347 if not tag.startswith(prefix):
348 continue
348 continue
349 alltags[tag[len(prefix):]] = node
349 alltags[tag[len(prefix):]] = node
350 if fh.close():
350 if fh.close():
351 raise util.Abort(_('cannot read tags from %s') % self.path)
351 raise error.Abort(_('cannot read tags from %s') % self.path)
352
352
353 # Filter out tag objects for annotated tag refs
353 # Filter out tag objects for annotated tag refs
354 for tag in alltags:
354 for tag in alltags:
@@ -376,7 +376,7 b' class convert_git(converter_source):'
376 '"%s^%s" --' % (version, version, i + 1))
376 '"%s^%s" --' % (version, version, i + 1))
377 changes = [f.rstrip('\n') for f in fh]
377 changes = [f.rstrip('\n') for f in fh]
378 if fh.close():
378 if fh.close():
379 raise util.Abort(_('cannot read changes in %s') % version)
379 raise error.Abort(_('cannot read changes in %s') % version)
380
380
381 return changes
381 return changes
382
382
@@ -8,7 +8,7 b''
8
8
9 from common import NoRepo, commandline, commit, converter_source
9 from common import NoRepo, commandline, commit, converter_source
10 from mercurial.i18n import _
10 from mercurial.i18n import _
11 from mercurial import encoding, util
11 from mercurial import encoding, util, error
12 import os, shutil, tempfile, stat
12 import os, shutil, tempfile, stat
13 from email.Parser import Parser
13 from email.Parser import Parser
14
14
@@ -42,7 +42,7 b' class gnuarch_source(converter_source, c'
42 if util.findexe('tla'):
42 if util.findexe('tla'):
43 self.execmd = 'tla'
43 self.execmd = 'tla'
44 else:
44 else:
45 raise util.Abort(_('cannot find a GNU Arch tool'))
45 raise error.Abort(_('cannot find a GNU Arch tool'))
46
46
47 commandline.__init__(self, ui, self.execmd)
47 commandline.__init__(self, ui, self.execmd)
48
48
@@ -135,7 +135,7 b' class gnuarch_source(converter_source, c'
135
135
136 def getfile(self, name, rev):
136 def getfile(self, name, rev):
137 if rev != self.lastrev:
137 if rev != self.lastrev:
138 raise util.Abort(_('internal calling inconsistency'))
138 raise error.Abort(_('internal calling inconsistency'))
139
139
140 if not os.path.lexists(os.path.join(self.tmppath, name)):
140 if not os.path.lexists(os.path.join(self.tmppath, name)):
141 return None, None
141 return None, None
@@ -144,7 +144,7 b' class gnuarch_source(converter_source, c'
144
144
145 def getchanges(self, rev, full):
145 def getchanges(self, rev, full):
146 if full:
146 if full:
147 raise util.Abort(_("convert from arch do not support --full"))
147 raise error.Abort(_("convert from arch do not support --full"))
148 self._update(rev)
148 self._update(rev)
149 changes = []
149 changes = []
150 copies = {}
150 copies = {}
@@ -287,7 +287,7 b' class gnuarch_source(converter_source, c'
287 self.changes[rev].continuationof = self.recode(
287 self.changes[rev].continuationof = self.recode(
288 catlog['Continuation-of'])
288 catlog['Continuation-of'])
289 except Exception:
289 except Exception:
290 raise util.Abort(_('could not parse cat-log of %s') % rev)
290 raise error.Abort(_('could not parse cat-log of %s') % rev)
291
291
292 def _parsechangeset(self, data, rev):
292 def _parsechangeset(self, data, rev):
293 for l in data:
293 for l in data:
@@ -205,7 +205,7 b' class mercurial_sink(converter_sink):'
205 # If the file requires actual merging, abort. We don't have enough
205 # If the file requires actual merging, abort. We don't have enough
206 # context to resolve merges correctly.
206 # context to resolve merges correctly.
207 if action in ['m', 'dm', 'cd', 'dc']:
207 if action in ['m', 'dm', 'cd', 'dc']:
208 raise util.Abort(_("unable to convert merge commit "
208 raise error.Abort(_("unable to convert merge commit "
209 "since target parents do not merge cleanly (file "
209 "since target parents do not merge cleanly (file "
210 "%s, parents %s and %s)") % (file, p1ctx,
210 "%s, parents %s and %s)") % (file, p1ctx,
211 p2ctx))
211 p2ctx))
@@ -423,7 +423,7 b' class mercurial_sink(converter_sink):'
423
423
424 def hascommitforsplicemap(self, rev):
424 def hascommitforsplicemap(self, rev):
425 if rev not in self.repo and self.clonebranches:
425 if rev not in self.repo and self.clonebranches:
426 raise util.Abort(_('revision %s not found in destination '
426 raise error.Abort(_('revision %s not found in destination '
427 'repository (lookups with clonebranches=true '
427 'repository (lookups with clonebranches=true '
428 'are not implemented)') % rev)
428 'are not implemented)') % rev)
429 return rev in self.repo
429 return rev in self.repo
@@ -455,7 +455,7 b' class mercurial_source(converter_source)'
455 try:
455 try:
456 startnode = self.repo.lookup(startnode)
456 startnode = self.repo.lookup(startnode)
457 except error.RepoError:
457 except error.RepoError:
458 raise util.Abort(_('%s is not a valid start revision')
458 raise error.Abort(_('%s is not a valid start revision')
459 % startnode)
459 % startnode)
460 startrev = self.repo.changelog.rev(startnode)
460 startrev = self.repo.changelog.rev(startnode)
461 children = {startnode: 1}
461 children = {startnode: 1}
@@ -470,7 +470,7 b' class mercurial_source(converter_source)'
470 self._heads = self.repo.heads()
470 self._heads = self.repo.heads()
471 else:
471 else:
472 if revs or startnode is not None:
472 if revs or startnode is not None:
473 raise util.Abort(_('hg.revs cannot be combined with '
473 raise error.Abort(_('hg.revs cannot be combined with '
474 'hg.startrev or --rev'))
474 'hg.startrev or --rev'))
475 nodes = set()
475 nodes = set()
476 parents = set()
476 parents = set()
@@ -7,7 +7,7 b''
7 # GNU General Public License version 2 or any later version.
7 # GNU General Public License version 2 or any later version.
8
8
9 import os, re
9 import os, re
10 from mercurial import util
10 from mercurial import util, error
11 from common import NoRepo, commit, converter_source, checktool
11 from common import NoRepo, commit, converter_source, checktool
12 from common import commandline
12 from common import commandline
13 from mercurial.i18n import _
13 from mercurial.i18n import _
@@ -16,7 +16,7 b' class monotone_source(converter_source, '
16 def __init__(self, ui, path=None, revs=None):
16 def __init__(self, ui, path=None, revs=None):
17 converter_source.__init__(self, ui, path, revs)
17 converter_source.__init__(self, ui, path, revs)
18 if revs and len(revs) > 1:
18 if revs and len(revs) > 1:
19 raise util.Abort(_('monotone source does not support specifying '
19 raise error.Abort(_('monotone source does not support specifying '
20 'multiple revs'))
20 'multiple revs'))
21 commandline.__init__(self, ui, 'mtn')
21 commandline.__init__(self, ui, 'mtn')
22
22
@@ -110,34 +110,34 b' class monotone_source(converter_source, '
110 while read != ':':
110 while read != ':':
111 read = self.mtnreadfp.read(1)
111 read = self.mtnreadfp.read(1)
112 if not read:
112 if not read:
113 raise util.Abort(_('bad mtn packet - no end of commandnbr'))
113 raise error.Abort(_('bad mtn packet - no end of commandnbr'))
114 commandnbr += read
114 commandnbr += read
115 commandnbr = commandnbr[:-1]
115 commandnbr = commandnbr[:-1]
116
116
117 stream = self.mtnreadfp.read(1)
117 stream = self.mtnreadfp.read(1)
118 if stream not in 'mewptl':
118 if stream not in 'mewptl':
119 raise util.Abort(_('bad mtn packet - bad stream type %s') % stream)
119 raise error.Abort(_('bad mtn packet - bad stream type %s') % stream)
120
120
121 read = self.mtnreadfp.read(1)
121 read = self.mtnreadfp.read(1)
122 if read != ':':
122 if read != ':':
123 raise util.Abort(_('bad mtn packet - no divider before size'))
123 raise error.Abort(_('bad mtn packet - no divider before size'))
124
124
125 read = None
125 read = None
126 lengthstr = ''
126 lengthstr = ''
127 while read != ':':
127 while read != ':':
128 read = self.mtnreadfp.read(1)
128 read = self.mtnreadfp.read(1)
129 if not read:
129 if not read:
130 raise util.Abort(_('bad mtn packet - no end of packet size'))
130 raise error.Abort(_('bad mtn packet - no end of packet size'))
131 lengthstr += read
131 lengthstr += read
132 try:
132 try:
133 length = long(lengthstr[:-1])
133 length = long(lengthstr[:-1])
134 except TypeError:
134 except TypeError:
135 raise util.Abort(_('bad mtn packet - bad packet size %s')
135 raise error.Abort(_('bad mtn packet - bad packet size %s')
136 % lengthstr)
136 % lengthstr)
137
137
138 read = self.mtnreadfp.read(length)
138 read = self.mtnreadfp.read(length)
139 if len(read) != length:
139 if len(read) != length:
140 raise util.Abort(_("bad mtn packet - unable to read full packet "
140 raise error.Abort(_("bad mtn packet - unable to read full packet "
141 "read %s of %s") % (len(read), length))
141 "read %s of %s") % (len(read), length))
142
142
143 return (commandnbr, stream, length, read)
143 return (commandnbr, stream, length, read)
@@ -152,7 +152,7 b' class monotone_source(converter_source, '
152 if stream == 'l':
152 if stream == 'l':
153 # End of command
153 # End of command
154 if output != '0':
154 if output != '0':
155 raise util.Abort(_("mtn command '%s' returned %s") %
155 raise error.Abort(_("mtn command '%s' returned %s") %
156 (command, output))
156 (command, output))
157 break
157 break
158 elif stream in 'ew':
158 elif stream in 'ew':
@@ -229,7 +229,7 b' class monotone_source(converter_source, '
229
229
230 def getchanges(self, rev, full):
230 def getchanges(self, rev, full):
231 if full:
231 if full:
232 raise util.Abort(_("convert from monotone do not support --full"))
232 raise error.Abort(_("convert from monotone do not support --full"))
233 revision = self.mtnrun("get_revision", rev).split("\n\n")
233 revision = self.mtnrun("get_revision", rev).split("\n\n")
234 files = {}
234 files = {}
235 ignoremove = {}
235 ignoremove = {}
@@ -330,7 +330,7 b' class monotone_source(converter_source, '
330 versionstr = self.mtnrunsingle("interface_version")
330 versionstr = self.mtnrunsingle("interface_version")
331 version = float(versionstr)
331 version = float(versionstr)
332 except Exception:
332 except Exception:
333 raise util.Abort(_("unable to determine mtn automate interface "
333 raise error.Abort(_("unable to determine mtn automate interface "
334 "version"))
334 "version"))
335
335
336 if version >= 12.0:
336 if version >= 12.0:
@@ -344,12 +344,12 b' class monotone_source(converter_source, '
344 # read the headers
344 # read the headers
345 read = self.mtnreadfp.readline()
345 read = self.mtnreadfp.readline()
346 if read != 'format-version: 2\n':
346 if read != 'format-version: 2\n':
347 raise util.Abort(_('mtn automate stdio header unexpected: %s')
347 raise error.Abort(_('mtn automate stdio header unexpected: %s')
348 % read)
348 % read)
349 while read != '\n':
349 while read != '\n':
350 read = self.mtnreadfp.readline()
350 read = self.mtnreadfp.readline()
351 if not read:
351 if not read:
352 raise util.Abort(_("failed to reach end of mtn automate "
352 raise error.Abort(_("failed to reach end of mtn automate "
353 "stdio headers"))
353 "stdio headers"))
354 else:
354 else:
355 self.ui.debug("mtn automate version %s - not using automate stdio "
355 self.ui.debug("mtn automate version %s - not using automate stdio "
@@ -5,7 +5,7 b''
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 from mercurial import util
8 from mercurial import util, error
9 from mercurial.i18n import _
9 from mercurial.i18n import _
10
10
11 from common import commit, converter_source, checktool, NoRepo
11 from common import commit, converter_source, checktool, NoRepo
@@ -70,7 +70,7 b' class p4_source(converter_source):'
70 self.re_keywords_old = re.compile("\$(Id|Header):[^$\n]*\$")
70 self.re_keywords_old = re.compile("\$(Id|Header):[^$\n]*\$")
71
71
72 if revs and len(revs) > 1:
72 if revs and len(revs) > 1:
73 raise util.Abort(_("p4 source does not support specifying "
73 raise error.Abort(_("p4 source does not support specifying "
74 "multiple revisions"))
74 "multiple revisions"))
75 self._parse(ui, path)
75 self._parse(ui, path)
76
76
@@ -277,7 +277,7 b' class p4_source(converter_source):'
277
277
278 def getchanges(self, rev, full):
278 def getchanges(self, rev, full):
279 if full:
279 if full:
280 raise util.Abort(_("convert from p4 do not support --full"))
280 raise error.Abort(_("convert from p4 do not support --full"))
281 return self.files[rev], self.copies[rev], set()
281 return self.files[rev], self.copies[rev], set()
282
282
283 def getcommit(self, rev):
283 def getcommit(self, rev):
@@ -6,7 +6,7 b' import os, re, sys, tempfile, urllib, ur'
6 import xml.dom.minidom
6 import xml.dom.minidom
7 import cPickle as pickle
7 import cPickle as pickle
8
8
9 from mercurial import strutil, scmutil, util, encoding
9 from mercurial import strutil, scmutil, util, encoding, error
10 from mercurial.i18n import _
10 from mercurial.i18n import _
11
11
12 propertycache = util.propertycache
12 propertycache = util.propertycache
@@ -141,7 +141,7 b' def debugsvnlog(ui, **opts):'
141 avoid memory collection issues.
141 avoid memory collection issues.
142 """
142 """
143 if svn is None:
143 if svn is None:
144 raise util.Abort(_('debugsvnlog could not load Subversion python '
144 raise error.Abort(_('debugsvnlog could not load Subversion python '
145 'bindings'))
145 'bindings'))
146
146
147 util.setbinary(sys.stdin)
147 util.setbinary(sys.stdin)
@@ -159,14 +159,14 b' class logstream(object):'
159 try:
159 try:
160 entry = pickle.load(self._stdout)
160 entry = pickle.load(self._stdout)
161 except EOFError:
161 except EOFError:
162 raise util.Abort(_('Mercurial failed to run itself, check'
162 raise error.Abort(_('Mercurial failed to run itself, check'
163 ' hg executable is in PATH'))
163 ' hg executable is in PATH'))
164 try:
164 try:
165 orig_paths, revnum, author, date, message = entry
165 orig_paths, revnum, author, date, message = entry
166 except (TypeError, ValueError):
166 except (TypeError, ValueError):
167 if entry is None:
167 if entry is None:
168 break
168 break
169 raise util.Abort(_("log stream exception '%s'") % entry)
169 raise error.Abort(_("log stream exception '%s'") % entry)
170 yield entry
170 yield entry
171
171
172 def close(self):
172 def close(self):
@@ -327,12 +327,12 b' class svn_source(converter_source):'
327
327
328 if revs:
328 if revs:
329 if len(revs) > 1:
329 if len(revs) > 1:
330 raise util.Abort(_('subversion source does not support '
330 raise error.Abort(_('subversion source does not support '
331 'specifying multiple revisions'))
331 'specifying multiple revisions'))
332 try:
332 try:
333 latest = int(revs[0])
333 latest = int(revs[0])
334 except ValueError:
334 except ValueError:
335 raise util.Abort(_('svn: revision %s is not an integer') %
335 raise error.Abort(_('svn: revision %s is not an integer') %
336 revs[0])
336 revs[0])
337
337
338 self.trunkname = self.ui.config('convert', 'svn.trunk',
338 self.trunkname = self.ui.config('convert', 'svn.trunk',
@@ -343,7 +343,7 b' class svn_source(converter_source):'
343 if self.startrev < 0:
343 if self.startrev < 0:
344 self.startrev = 0
344 self.startrev = 0
345 except ValueError:
345 except ValueError:
346 raise util.Abort(_('svn: start revision %s is not an integer')
346 raise error.Abort(_('svn: start revision %s is not an integer')
347 % self.startrev)
347 % self.startrev)
348
348
349 try:
349 try:
@@ -351,7 +351,7 b' class svn_source(converter_source):'
351 except SvnPathNotFound:
351 except SvnPathNotFound:
352 self.head = None
352 self.head = None
353 if not self.head:
353 if not self.head:
354 raise util.Abort(_('no revision found in module %s')
354 raise error.Abort(_('no revision found in module %s')
355 % self.module)
355 % self.module)
356 self.last_changed = self.revnum(self.head)
356 self.last_changed = self.revnum(self.head)
357
357
@@ -396,8 +396,8 b' class svn_source(converter_source):'
396 # we are converting from inside this directory
396 # we are converting from inside this directory
397 return None
397 return None
398 if cfgpath:
398 if cfgpath:
399 raise util.Abort(_('expected %s to be at %r, but not found')
399 raise error.Abort(_('expected %s to be at %r, but not found'
400 % (name, path))
400 ) % (name, path))
401 return None
401 return None
402 self.ui.note(_('found %s at %r\n') % (name, path))
402 self.ui.note(_('found %s at %r\n') % (name, path))
403 return path
403 return path
@@ -415,7 +415,7 b' class svn_source(converter_source):'
415 self.module += '/' + trunk
415 self.module += '/' + trunk
416 self.head = self.latest(self.module, self.last_changed)
416 self.head = self.latest(self.module, self.last_changed)
417 if not self.head:
417 if not self.head:
418 raise util.Abort(_('no revision found in module %s')
418 raise error.Abort(_('no revision found in module %s')
419 % self.module)
419 % self.module)
420
420
421 # First head in the list is the module's head
421 # First head in the list is the module's head
@@ -442,11 +442,11 b' class svn_source(converter_source):'
442
442
443 if self.startrev and self.heads:
443 if self.startrev and self.heads:
444 if len(self.heads) > 1:
444 if len(self.heads) > 1:
445 raise util.Abort(_('svn: start revision is not supported '
445 raise error.Abort(_('svn: start revision is not supported '
446 'with more than one branch'))
446 'with more than one branch'))
447 revnum = self.revnum(self.heads[0])
447 revnum = self.revnum(self.heads[0])
448 if revnum < self.startrev:
448 if revnum < self.startrev:
449 raise util.Abort(
449 raise error.Abort(
450 _('svn: no revision found after start revision %d')
450 _('svn: no revision found after start revision %d')
451 % self.startrev)
451 % self.startrev)
452
452
@@ -502,7 +502,7 b' class svn_source(converter_source):'
502 stop = revnum + 1
502 stop = revnum + 1
503 self._fetch_revisions(revnum, stop)
503 self._fetch_revisions(revnum, stop)
504 if rev not in self.commits:
504 if rev not in self.commits:
505 raise util.Abort(_('svn: revision %s not found') % revnum)
505 raise error.Abort(_('svn: revision %s not found') % revnum)
506 revcommit = self.commits[rev]
506 revcommit = self.commits[rev]
507 # caller caches the result, so free it here to release memory
507 # caller caches the result, so free it here to release memory
508 del self.commits[rev]
508 del self.commits[rev]
@@ -513,7 +513,7 b' class svn_source(converter_source):'
513 if not re.match(r'svn:[0-9a-f]{8,8}-[0-9a-f]{4,4}-'
513 if not re.match(r'svn:[0-9a-f]{8,8}-[0-9a-f]{4,4}-'
514 '[0-9a-f]{4,4}-[0-9a-f]{4,4}-[0-9a-f]'
514 '[0-9a-f]{4,4}-[0-9a-f]{4,4}-[0-9a-f]'
515 '{12,12}(.*)\@[0-9]+$',revstr):
515 '{12,12}(.*)\@[0-9]+$',revstr):
516 raise util.Abort(_('%s entry %s is not a valid revision'
516 raise error.Abort(_('%s entry %s is not a valid revision'
517 ' identifier') % (mapname, revstr))
517 ' identifier') % (mapname, revstr))
518
518
519 def numcommits(self):
519 def numcommits(self):
@@ -951,7 +951,7 b' class svn_source(converter_source):'
951 except SubversionException as xxx_todo_changeme:
951 except SubversionException as xxx_todo_changeme:
952 (inst, num) = xxx_todo_changeme.args
952 (inst, num) = xxx_todo_changeme.args
953 if num == svn.core.SVN_ERR_FS_NO_SUCH_REVISION:
953 if num == svn.core.SVN_ERR_FS_NO_SUCH_REVISION:
954 raise util.Abort(_('svn: branch has no revision %s')
954 raise error.Abort(_('svn: branch has no revision %s')
955 % to_revnum)
955 % to_revnum)
956 raise
956 raise
957
957
@@ -1052,7 +1052,7 b' class svn_source(converter_source):'
1052 try:
1052 try:
1053 stdin.close()
1053 stdin.close()
1054 except IOError:
1054 except IOError:
1055 raise util.Abort(_('Mercurial failed to run itself, check'
1055 raise error.Abort(_('Mercurial failed to run itself, check'
1056 ' hg executable is in PATH'))
1056 ' hg executable is in PATH'))
1057 return logstream(stdout)
1057 return logstream(stdout)
1058
1058
@@ -1302,7 +1302,7 b' class svn_sink(converter_sink, commandli'
1302 return parents[0]
1302 return parents[0]
1303 self.ui.warn(_('unexpected svn output:\n'))
1303 self.ui.warn(_('unexpected svn output:\n'))
1304 self.ui.warn(output)
1304 self.ui.warn(output)
1305 raise util.Abort(_('unable to cope with svn output'))
1305 raise error.Abort(_('unable to cope with svn output'))
1306 if commit.rev:
1306 if commit.rev:
1307 self.run('propset', 'hg:convert-rev', commit.rev,
1307 self.run('propset', 'hg:convert-rev', commit.rev,
1308 revprop=True, revision=rev)
1308 revprop=True, revision=rev)
@@ -1329,6 +1329,6 b' class svn_sink(converter_sink, commandli'
1329 # repository and childmap would not list all revisions. Too bad.
1329 # repository and childmap would not list all revisions. Too bad.
1330 if rev in self.childmap:
1330 if rev in self.childmap:
1331 return True
1331 return True
1332 raise util.Abort(_('splice map revision %s not found in subversion '
1332 raise error.Abort(_('splice map revision %s not found in subversion '
1333 'child map (revision lookups are not implemented)')
1333 'child map (revision lookups are not implemented)')
1334 % rev)
1334 % rev)
@@ -247,7 +247,7 b' def _checkhook(ui, repo, node, headsonly'
247 for node, target, f in failed:
247 for node, target, f in failed:
248 msgs.append(_(" %s in %s should not have %s line endings") %
248 msgs.append(_(" %s in %s should not have %s line endings") %
249 (f, node, eols[target]))
249 (f, node, eols[target]))
250 raise util.Abort(_("end-of-line check failed:\n") + "\n".join(msgs))
250 raise error.Abort(_("end-of-line check failed:\n") + "\n".join(msgs))
251
251
252 def checkallhook(ui, repo, node, hooktype, **kwargs):
252 def checkallhook(ui, repo, node, hooktype, **kwargs):
253 """verify that files have expected EOLs"""
253 """verify that files have expected EOLs"""
@@ -347,7 +347,7 b' def reposetup(ui, repo):'
347 # have all non-binary files taken care of.
347 # have all non-binary files taken care of.
348 continue
348 continue
349 if inconsistenteol(data):
349 if inconsistenteol(data):
350 raise util.Abort(_("inconsistent newline style "
350 raise error.Abort(_("inconsistent newline style "
351 "in %s\n") % f)
351 "in %s\n") % f)
352 return super(eolrepo, self).commitctx(ctx, haserror)
352 return super(eolrepo, self).commitctx(ctx, haserror)
353 repo.__class__ = eolrepo
353 repo.__class__ = eolrepo
@@ -63,7 +63,7 b' pretty fast (at least faster than having'
63 from mercurial.i18n import _
63 from mercurial.i18n import _
64 from mercurial.node import short, nullid
64 from mercurial.node import short, nullid
65 from mercurial import cmdutil, scmutil, util, commands, encoding, filemerge
65 from mercurial import cmdutil, scmutil, util, commands, encoding, filemerge
66 from mercurial import archival
66 from mercurial import archival, error
67 import os, shlex, shutil, tempfile, re
67 import os, shlex, shutil, tempfile, re
68
68
69 cmdtable = {}
69 cmdtable = {}
@@ -127,7 +127,7 b' def dodiff(ui, repo, cmdline, pats, opts'
127
127
128 if revs and change:
128 if revs and change:
129 msg = _('cannot specify --rev and --change at the same time')
129 msg = _('cannot specify --rev and --change at the same time')
130 raise util.Abort(msg)
130 raise error.Abort(msg)
131 elif change:
131 elif change:
132 node2 = scmutil.revsingle(repo, change, None).node()
132 node2 = scmutil.revsingle(repo, change, None).node()
133 node1a, node1b = repo.changelog.parents(node2)
133 node1a, node1b = repo.changelog.parents(node2)
@@ -149,9 +149,9 b' def dodiff(ui, repo, cmdline, pats, opts'
149
149
150 if opts.get('patch'):
150 if opts.get('patch'):
151 if subrepos:
151 if subrepos:
152 raise util.Abort(_('--patch cannot be used with --subrepos'))
152 raise error.Abort(_('--patch cannot be used with --subrepos'))
153 if node2 is None:
153 if node2 is None:
154 raise util.Abort(_('--patch requires two revisions'))
154 raise error.Abort(_('--patch requires two revisions'))
155 else:
155 else:
156 mod_a, add_a, rem_a = map(set, repo.status(node1a, node2, matcher,
156 mod_a, add_a, rem_a = map(set, repo.status(node1a, node2, matcher,
157 listsubrepos=subrepos)[:3])
157 listsubrepos=subrepos)[:3])
@@ -47,7 +47,7 b' service entry controls the service name '
47
47
48 from mercurial.i18n import _
48 from mercurial.i18n import _
49 from mercurial.url import passwordmgr
49 from mercurial.url import passwordmgr
50 from mercurial import httpconnection, util
50 from mercurial import httpconnection, error
51 import os, urllib2
51 import os, urllib2
52
52
53 ERRMAX = 128
53 ERRMAX = 128
@@ -56,7 +56,7 b' ERRMAX = 128'
56
56
57 def auth_getkey(self, params):
57 def auth_getkey(self, params):
58 if not self.ui.interactive():
58 if not self.ui.interactive():
59 raise util.Abort(_('factotum not interactive'))
59 raise error.Abort(_('factotum not interactive'))
60 if 'user=' not in params:
60 if 'user=' not in params:
61 params = '%s user?' % params
61 params = '%s user?' % params
62 params = '%s !password?' % params
62 params = '%s !password?' % params
@@ -77,10 +77,10 b' def auth_getuserpasswd(self, getkey, par'
77 if passwd.endswith("'"):
77 if passwd.endswith("'"):
78 passwd = passwd[1:-1].replace("''", "'")
78 passwd = passwd[1:-1].replace("''", "'")
79 else:
79 else:
80 raise util.Abort(_('malformed password string'))
80 raise error.Abort(_('malformed password string'))
81 return (user, passwd)
81 return (user, passwd)
82 except (OSError, IOError):
82 except (OSError, IOError):
83 raise util.Abort(_('factotum not responding'))
83 raise error.Abort(_('factotum not responding'))
84 finally:
84 finally:
85 os.close(fd)
85 os.close(fd)
86 getkey(self, params)
86 getkey(self, params)
@@ -60,7 +60,7 b" def fetch(ui, repo, source='default', **"
60 except error.RepoLookupError:
60 except error.RepoLookupError:
61 branchnode = None
61 branchnode = None
62 if parent != branchnode:
62 if parent != branchnode:
63 raise util.Abort(_('working directory not at branch tip'),
63 raise error.Abort(_('working directory not at branch tip'),
64 hint=_('use "hg update" to check out branch tip'))
64 hint=_('use "hg update" to check out branch tip'))
65
65
66 wlock = lock = None
66 wlock = lock = None
@@ -73,7 +73,7 b" def fetch(ui, repo, source='default', **"
73 bheads = repo.branchheads(branch)
73 bheads = repo.branchheads(branch)
74 bheads = [head for head in bheads if len(repo[head].children()) == 0]
74 bheads = [head for head in bheads if len(repo[head].children()) == 0]
75 if len(bheads) > 1:
75 if len(bheads) > 1:
76 raise util.Abort(_('multiple heads in this branch '
76 raise error.Abort(_('multiple heads in this branch '
77 '(use "hg heads ." and "hg merge" to merge)'))
77 '(use "hg heads ." and "hg merge" to merge)'))
78
78
79 other = hg.peer(repo, opts, ui.expandpath(source))
79 other = hg.peer(repo, opts, ui.expandpath(source))
@@ -86,7 +86,7 b" def fetch(ui, repo, source='default', **"
86 except error.CapabilityError:
86 except error.CapabilityError:
87 err = _("other repository doesn't support revision lookup, "
87 err = _("other repository doesn't support revision lookup, "
88 "so a rev cannot be specified.")
88 "so a rev cannot be specified.")
89 raise util.Abort(err)
89 raise error.Abort(err)
90
90
91 # Are there any changes at all?
91 # Are there any changes at all?
92 modheads = exchange.pull(repo, other, heads=revs).cgresult
92 modheads = exchange.pull(repo, other, heads=revs).cgresult
@@ -6,7 +6,7 b''
6 '''commands to sign and verify changesets'''
6 '''commands to sign and verify changesets'''
7
7
8 import os, tempfile, binascii
8 import os, tempfile, binascii
9 from mercurial import util, commands, match, cmdutil
9 from mercurial import util, commands, match, cmdutil, error
10 from mercurial import node as hgnode
10 from mercurial import node as hgnode
11 from mercurial.i18n import _
11 from mercurial.i18n import _
12
12
@@ -237,7 +237,7 b' def sign(ui, repo, *revs, **opts):'
237 nodes = [node for node in repo.dirstate.parents()
237 nodes = [node for node in repo.dirstate.parents()
238 if node != hgnode.nullid]
238 if node != hgnode.nullid]
239 if len(nodes) > 1:
239 if len(nodes) > 1:
240 raise util.Abort(_('uncommitted merge - please provide a '
240 raise error.Abort(_('uncommitted merge - please provide a '
241 'specific revision'))
241 'specific revision'))
242 if not nodes:
242 if not nodes:
243 nodes = [repo.changelog.tip()]
243 nodes = [repo.changelog.tip()]
@@ -250,7 +250,7 b' def sign(ui, repo, *revs, **opts):'
250 data = node2txt(repo, n, sigver)
250 data = node2txt(repo, n, sigver)
251 sig = mygpg.sign(data)
251 sig = mygpg.sign(data)
252 if not sig:
252 if not sig:
253 raise util.Abort(_("error while signing"))
253 raise error.Abort(_("error while signing"))
254 sig = binascii.b2a_base64(sig)
254 sig = binascii.b2a_base64(sig)
255 sig = sig.replace("\n", "")
255 sig = sig.replace("\n", "")
256 sigmessage += "%s %s %s\n" % (hexnode, sigver, sig)
256 sigmessage += "%s %s %s\n" % (hexnode, sigver, sig)
@@ -263,7 +263,7 b' def sign(ui, repo, *revs, **opts):'
263 if not opts["force"]:
263 if not opts["force"]:
264 msigs = match.exact(repo.root, '', ['.hgsigs'])
264 msigs = match.exact(repo.root, '', ['.hgsigs'])
265 if any(repo.status(match=msigs, unknown=True, ignored=True)):
265 if any(repo.status(match=msigs, unknown=True, ignored=True)):
266 raise util.Abort(_("working copy of .hgsigs is changed "),
266 raise error.Abort(_("working copy of .hgsigs is changed "),
267 hint=_("please commit .hgsigs manually"))
267 hint=_("please commit .hgsigs manually"))
268
268
269 sigsfile = repo.wfile(".hgsigs", "ab")
269 sigsfile = repo.wfile(".hgsigs", "ab")
@@ -287,7 +287,7 b' def sign(ui, repo, *revs, **opts):'
287 repo.commit(message, opts['user'], opts['date'], match=msigs,
287 repo.commit(message, opts['user'], opts['date'], match=msigs,
288 editor=editor)
288 editor=editor)
289 except ValueError as inst:
289 except ValueError as inst:
290 raise util.Abort(str(inst))
290 raise error.Abort(str(inst))
291
291
292 def shortkey(ui, key):
292 def shortkey(ui, key):
293 if len(key) != 16:
293 if len(key) != 16:
@@ -301,4 +301,4 b' def node2txt(repo, node, ver):'
301 if ver == "0":
301 if ver == "0":
302 return "%s\n" % hgnode.hex(node)
302 return "%s\n" % hgnode.hex(node)
303 else:
303 else:
304 raise util.Abort(_("unknown signature version"))
304 raise error.Abort(_("unknown signature version"))
@@ -43,7 +43,7 b' configure it, set the following options '
43
43
44 from mercurial.i18n import _
44 from mercurial.i18n import _
45 from mercurial.node import bin, short
45 from mercurial.node import bin, short
46 from mercurial import cmdutil, patch, util, mail
46 from mercurial import cmdutil, patch, util, mail, error
47 import email.Parser
47 import email.Parser
48
48
49 import socket, xmlrpclib
49 import socket, xmlrpclib
@@ -233,7 +233,7 b' class hgcia(object):'
233 srv = xmlrpclib.Server(self.ciaurl)
233 srv = xmlrpclib.Server(self.ciaurl)
234 res = srv.hub.deliver(msg)
234 res = srv.hub.deliver(msg)
235 if res is not True and res != 'queued.':
235 if res is not True and res != 'queued.':
236 raise util.Abort(_('%s returned an error: %s') %
236 raise error.Abort(_('%s returned an error: %s') %
237 (self.ciaurl, res))
237 (self.ciaurl, res))
238
238
239 def sendemail(self, address, data):
239 def sendemail(self, address, data):
@@ -259,7 +259,7 b' def hook(ui, repo, hooktype, node=None, '
259 ui.write(msg)
259 ui.write(msg)
260 elif cia.ciaurl.startswith('mailto:'):
260 elif cia.ciaurl.startswith('mailto:'):
261 if not cia.emailfrom:
261 if not cia.emailfrom:
262 raise util.Abort(_('email.from must be defined when '
262 raise error.Abort(_('email.from must be defined when '
263 'sending by email'))
263 'sending by email'))
264 cia.sendemail(cia.ciaurl[7:], msg)
264 cia.sendemail(cia.ciaurl[7:], msg)
265 else:
265 else:
@@ -225,7 +225,7 b' class histeditstate(object):'
225 except IOError as err:
225 except IOError as err:
226 if err.errno != errno.ENOENT:
226 if err.errno != errno.ENOENT:
227 raise
227 raise
228 raise util.Abort(_('no histedit in progress'))
228 raise error.Abort(_('no histedit in progress'))
229
229
230 try:
230 try:
231 data = pickle.load(fp)
231 data = pickle.load(fp)
@@ -331,7 +331,7 b' class histeditaction(object):'
331 try:
331 try:
332 node = repo[rulehash].node()
332 node = repo[rulehash].node()
333 except error.RepoError:
333 except error.RepoError:
334 raise util.Abort(_('unknown changeset %s listed') % rulehash[:12])
334 raise error.Abort(_('unknown changeset %s listed') % rulehash[:12])
335 return cls(state, node)
335 return cls(state, node)
336
336
337 def run(self):
337 def run(self):
@@ -439,7 +439,7 b' def collapse(repo, first, last, commitop'
439 return None
439 return None
440 for c in ctxs:
440 for c in ctxs:
441 if not c.mutable():
441 if not c.mutable():
442 raise util.Abort(
442 raise error.Abort(
443 _("cannot fold into public change %s") % node.short(c.node()))
443 _("cannot fold into public change %s") % node.short(c.node()))
444 base = first.parents()[0]
444 base = first.parents()[0]
445
445
@@ -664,12 +664,12 b' def findoutgoing(ui, repo, remote=None, '
664
664
665 outgoing = discovery.findcommonoutgoing(repo, other, revs, force=force)
665 outgoing = discovery.findcommonoutgoing(repo, other, revs, force=force)
666 if not outgoing.missing:
666 if not outgoing.missing:
667 raise util.Abort(_('no outgoing ancestors'))
667 raise error.Abort(_('no outgoing ancestors'))
668 roots = list(repo.revs("roots(%ln)", outgoing.missing))
668 roots = list(repo.revs("roots(%ln)", outgoing.missing))
669 if 1 < len(roots):
669 if 1 < len(roots):
670 msg = _('there are ambiguous outgoing revisions')
670 msg = _('there are ambiguous outgoing revisions')
671 hint = _('see "hg help histedit" for more detail')
671 hint = _('see "hg help histedit" for more detail')
672 raise util.Abort(msg, hint=hint)
672 raise error.Abort(msg, hint=hint)
673 return repo.lookup(roots[0])
673 return repo.lookup(roots[0])
674
674
675 actiontable = {'p': pick,
675 actiontable = {'p': pick,
@@ -736,7 +736,7 b' def _histedit(ui, repo, state, *freeargs'
736 # blanket if mq patches are applied somewhere
736 # blanket if mq patches are applied somewhere
737 mq = getattr(repo, 'mq', None)
737 mq = getattr(repo, 'mq', None)
738 if mq and mq.applied:
738 if mq and mq.applied:
739 raise util.Abort(_('source has mq patches applied'))
739 raise error.Abort(_('source has mq patches applied'))
740
740
741 # basic argument incompatibility processing
741 # basic argument incompatibility processing
742 outg = opts.get('outgoing')
742 outg = opts.get('outgoing')
@@ -748,29 +748,29 b' def _histedit(ui, repo, state, *freeargs'
748 revs = opts.get('rev', [])
748 revs = opts.get('rev', [])
749 goal = 'new' # This invocation goal, in new, continue, abort
749 goal = 'new' # This invocation goal, in new, continue, abort
750 if force and not outg:
750 if force and not outg:
751 raise util.Abort(_('--force only allowed with --outgoing'))
751 raise error.Abort(_('--force only allowed with --outgoing'))
752 if cont:
752 if cont:
753 if any((outg, abort, revs, freeargs, rules, editplan)):
753 if any((outg, abort, revs, freeargs, rules, editplan)):
754 raise util.Abort(_('no arguments allowed with --continue'))
754 raise error.Abort(_('no arguments allowed with --continue'))
755 goal = 'continue'
755 goal = 'continue'
756 elif abort:
756 elif abort:
757 if any((outg, revs, freeargs, rules, editplan)):
757 if any((outg, revs, freeargs, rules, editplan)):
758 raise util.Abort(_('no arguments allowed with --abort'))
758 raise error.Abort(_('no arguments allowed with --abort'))
759 goal = 'abort'
759 goal = 'abort'
760 elif editplan:
760 elif editplan:
761 if any((outg, revs, freeargs)):
761 if any((outg, revs, freeargs)):
762 raise util.Abort(_('only --commands argument allowed with '
762 raise error.Abort(_('only --commands argument allowed with '
763 '--edit-plan'))
763 '--edit-plan'))
764 goal = 'edit-plan'
764 goal = 'edit-plan'
765 else:
765 else:
766 if os.path.exists(os.path.join(repo.path, 'histedit-state')):
766 if os.path.exists(os.path.join(repo.path, 'histedit-state')):
767 raise util.Abort(_('history edit already in progress, try '
767 raise error.Abort(_('history edit already in progress, try '
768 '--continue or --abort'))
768 '--continue or --abort'))
769 if outg:
769 if outg:
770 if revs:
770 if revs:
771 raise util.Abort(_('no revisions allowed with --outgoing'))
771 raise error.Abort(_('no revisions allowed with --outgoing'))
772 if len(freeargs) > 1:
772 if len(freeargs) > 1:
773 raise util.Abort(
773 raise error.Abort(
774 _('only one repo argument allowed with --outgoing'))
774 _('only one repo argument allowed with --outgoing'))
775 else:
775 else:
776 revs.extend(freeargs)
776 revs.extend(freeargs)
@@ -780,7 +780,7 b' def _histedit(ui, repo, state, *freeargs'
780 if histeditdefault:
780 if histeditdefault:
781 revs.append(histeditdefault)
781 revs.append(histeditdefault)
782 if len(revs) != 1:
782 if len(revs) != 1:
783 raise util.Abort(
783 raise error.Abort(
784 _('histedit requires exactly one ancestor revision'))
784 _('histedit requires exactly one ancestor revision'))
785
785
786
786
@@ -856,13 +856,13 b' def _histedit(ui, repo, state, *freeargs'
856 else:
856 else:
857 rr = list(repo.set('roots(%ld)', scmutil.revrange(repo, revs)))
857 rr = list(repo.set('roots(%ld)', scmutil.revrange(repo, revs)))
858 if len(rr) != 1:
858 if len(rr) != 1:
859 raise util.Abort(_('The specified revisions must have '
859 raise error.Abort(_('The specified revisions must have '
860 'exactly one common root'))
860 'exactly one common root'))
861 root = rr[0].node()
861 root = rr[0].node()
862
862
863 revs = between(repo, root, topmost, state.keep)
863 revs = between(repo, root, topmost, state.keep)
864 if not revs:
864 if not revs:
865 raise util.Abort(_('%s is not an ancestor of working directory') %
865 raise error.Abort(_('%s is not an ancestor of working directory') %
866 node.short(root))
866 node.short(root))
867
867
868 ctxs = [repo[r] for r in revs]
868 ctxs = [repo[r] for r in revs]
@@ -960,7 +960,7 b' def bootstrapcontinue(ui, state, opts):'
960 actobj.continuedirty()
960 actobj.continuedirty()
961 s = repo.status()
961 s = repo.status()
962 if s.modified or s.added or s.removed or s.deleted:
962 if s.modified or s.added or s.removed or s.deleted:
963 raise util.Abort(_("working copy still dirty"))
963 raise error.Abort(_("working copy still dirty"))
964
964
965 parentctx, replacements = actobj.continueclean()
965 parentctx, replacements = actobj.continueclean()
966
966
@@ -977,12 +977,12 b' def between(repo, old, new, keep):'
977 if ctxs and not keep:
977 if ctxs and not keep:
978 if (not obsolete.isenabled(repo, obsolete.allowunstableopt) and
978 if (not obsolete.isenabled(repo, obsolete.allowunstableopt) and
979 repo.revs('(%ld::) - (%ld)', ctxs, ctxs)):
979 repo.revs('(%ld::) - (%ld)', ctxs, ctxs)):
980 raise util.Abort(_('cannot edit history that would orphan nodes'))
980 raise error.Abort(_('cannot edit history that would orphan nodes'))
981 if repo.revs('(%ld) and merge()', ctxs):
981 if repo.revs('(%ld) and merge()', ctxs):
982 raise util.Abort(_('cannot edit history that contains merges'))
982 raise error.Abort(_('cannot edit history that contains merges'))
983 root = ctxs[0] # list is already sorted by repo.set
983 root = ctxs[0] # list is already sorted by repo.set
984 if not root.mutable():
984 if not root.mutable():
985 raise util.Abort(_('cannot edit public changeset: %s') % root,
985 raise error.Abort(_('cannot edit public changeset: %s') % root,
986 hint=_('see "hg help phases" for details'))
986 hint=_('see "hg help phases" for details'))
987 return [c.node() for c in ctxs]
987 return [c.node() for c in ctxs]
988
988
@@ -1033,26 +1033,26 b' def verifyrules(rules, repo, ctxs):'
1033 seen = set()
1033 seen = set()
1034 for r in rules:
1034 for r in rules:
1035 if ' ' not in r:
1035 if ' ' not in r:
1036 raise util.Abort(_('malformed line "%s"') % r)
1036 raise error.Abort(_('malformed line "%s"') % r)
1037 action, rest = r.split(' ', 1)
1037 action, rest = r.split(' ', 1)
1038 ha = rest.strip().split(' ', 1)[0]
1038 ha = rest.strip().split(' ', 1)[0]
1039 try:
1039 try:
1040 ha = repo[ha].hex()
1040 ha = repo[ha].hex()
1041 except error.RepoError:
1041 except error.RepoError:
1042 raise util.Abort(_('unknown changeset %s listed') % ha[:12])
1042 raise error.Abort(_('unknown changeset %s listed') % ha[:12])
1043 if ha not in expected:
1043 if ha not in expected:
1044 raise util.Abort(
1044 raise error.Abort(
1045 _('may not use changesets other than the ones listed'))
1045 _('may not use changesets other than the ones listed'))
1046 if ha in seen:
1046 if ha in seen:
1047 raise util.Abort(_('duplicated command for changeset %s') %
1047 raise error.Abort(_('duplicated command for changeset %s') %
1048 ha[:12])
1048 ha[:12])
1049 seen.add(ha)
1049 seen.add(ha)
1050 if action not in actiontable or action.startswith('_'):
1050 if action not in actiontable or action.startswith('_'):
1051 raise util.Abort(_('unknown action "%s"') % action)
1051 raise error.Abort(_('unknown action "%s"') % action)
1052 parsed.append([action, ha])
1052 parsed.append([action, ha])
1053 missing = sorted(expected - seen) # sort to stabilize output
1053 missing = sorted(expected - seen) # sort to stabilize output
1054 if missing:
1054 if missing:
1055 raise util.Abort(_('missing rules for changeset %s') %
1055 raise error.Abort(_('missing rules for changeset %s') %
1056 missing[0][:12],
1056 missing[0][:12],
1057 hint=_('do you want to use the drop action?'))
1057 hint=_('do you want to use the drop action?'))
1058 return parsed
1058 return parsed
@@ -1208,7 +1208,7 b' def stripwrapper(orig, ui, repo, nodelis'
1208 strip_nodes = set([repo[n].node() for n in nodelist])
1208 strip_nodes = set([repo[n].node() for n in nodelist])
1209 common_nodes = histedit_nodes & strip_nodes
1209 common_nodes = histedit_nodes & strip_nodes
1210 if common_nodes:
1210 if common_nodes:
1211 raise util.Abort(_("histedit in progress, can't strip %s")
1211 raise error.Abort(_("histedit in progress, can't strip %s")
1212 % ', '.join(node.short(x) for x in common_nodes))
1212 % ', '.join(node.short(x) for x in common_nodes))
1213 return orig(ui, repo, nodelist, *args, **kwargs)
1213 return orig(ui, repo, nodelist, *args, **kwargs)
1214
1214
@@ -83,7 +83,7 b" like CVS' $Log$, are not supported. A ke"
83 '''
83 '''
84
84
85 from mercurial import commands, context, cmdutil, dispatch, filelog, extensions
85 from mercurial import commands, context, cmdutil, dispatch, filelog, extensions
86 from mercurial import localrepo, match, patch, templatefilters, util
86 from mercurial import localrepo, match, patch, templatefilters, util, error
87 from mercurial import scmutil, pathutil
87 from mercurial import scmutil, pathutil
88 from mercurial.hgweb import webcommands
88 from mercurial.hgweb import webcommands
89 from mercurial.i18n import _
89 from mercurial.i18n import _
@@ -348,20 +348,20 b' def _status(ui, repo, wctx, kwt, *pats, '
348 return repo.status(match=scmutil.match(wctx, pats, opts), clean=True,
348 return repo.status(match=scmutil.match(wctx, pats, opts), clean=True,
349 unknown=opts.get('unknown') or opts.get('all'))
349 unknown=opts.get('unknown') or opts.get('all'))
350 if ui.configitems('keyword'):
350 if ui.configitems('keyword'):
351 raise util.Abort(_('[keyword] patterns cannot match'))
351 raise error.Abort(_('[keyword] patterns cannot match'))
352 raise util.Abort(_('no [keyword] patterns configured'))
352 raise error.Abort(_('no [keyword] patterns configured'))
353
353
354 def _kwfwrite(ui, repo, expand, *pats, **opts):
354 def _kwfwrite(ui, repo, expand, *pats, **opts):
355 '''Selects files and passes them to kwtemplater.overwrite.'''
355 '''Selects files and passes them to kwtemplater.overwrite.'''
356 wctx = repo[None]
356 wctx = repo[None]
357 if len(wctx.parents()) > 1:
357 if len(wctx.parents()) > 1:
358 raise util.Abort(_('outstanding uncommitted merge'))
358 raise error.Abort(_('outstanding uncommitted merge'))
359 kwt = kwtools['templater']
359 kwt = kwtools['templater']
360 wlock = repo.wlock()
360 wlock = repo.wlock()
361 try:
361 try:
362 status = _status(ui, repo, wctx, kwt, *pats, **opts)
362 status = _status(ui, repo, wctx, kwt, *pats, **opts)
363 if status.modified or status.added or status.removed or status.deleted:
363 if status.modified or status.added or status.removed or status.deleted:
364 raise util.Abort(_('outstanding uncommitted changes'))
364 raise error.Abort(_('outstanding uncommitted changes'))
365 kwt.overwrite(wctx, status.clean, True, expand)
365 kwt.overwrite(wctx, status.clean, True, expand)
366 finally:
366 finally:
367 wlock.release()
367 wlock.release()
@@ -10,7 +10,7 b''
10
10
11 import re
11 import re
12
12
13 from mercurial import util, node, hg
13 from mercurial import util, node, hg, error
14 from mercurial.i18n import _
14 from mercurial.i18n import _
15
15
16 import lfutil
16 import lfutil
@@ -209,7 +209,7 b' def _openstore(repo, remote=None, put=Fa'
209 try:
209 try:
210 storeproviders = _storeprovider[scheme]
210 storeproviders = _storeprovider[scheme]
211 except KeyError:
211 except KeyError:
212 raise util.Abort(_('unsupported URL scheme %r') % scheme)
212 raise error.Abort(_('unsupported URL scheme %r') % scheme)
213
213
214 for classobj in storeproviders:
214 for classobj in storeproviders:
215 try:
215 try:
@@ -217,5 +217,5 b' def _openstore(repo, remote=None, put=Fa'
217 except lfutil.storeprotonotcapable:
217 except lfutil.storeprotonotcapable:
218 pass
218 pass
219
219
220 raise util.Abort(_('%s does not appear to be a largefile store') %
220 raise error.Abort(_('%s does not appear to be a largefile store') %
221 util.hidepassword(path))
221 util.hidepassword(path))
@@ -62,9 +62,9 b' def lfconvert(ui, src, dest, *pats, **op'
62 size = lfutil.getminsize(ui, True, opts.get('size'), default=None)
62 size = lfutil.getminsize(ui, True, opts.get('size'), default=None)
63
63
64 if not hg.islocal(src):
64 if not hg.islocal(src):
65 raise util.Abort(_('%s is not a local Mercurial repo') % src)
65 raise error.Abort(_('%s is not a local Mercurial repo') % src)
66 if not hg.islocal(dest):
66 if not hg.islocal(dest):
67 raise util.Abort(_('%s is not a local Mercurial repo') % dest)
67 raise error.Abort(_('%s is not a local Mercurial repo') % dest)
68
68
69 rsrc = hg.repository(ui, src)
69 rsrc = hg.repository(ui, src)
70 ui.status(_('initializing destination %s\n') % dest)
70 ui.status(_('initializing destination %s\n') % dest)
@@ -139,7 +139,7 b' def lfconvert(ui, src, dest, *pats, **op'
139 path = lfutil.findfile(rsrc, hash)
139 path = lfutil.findfile(rsrc, hash)
140
140
141 if path is None:
141 if path is None:
142 raise util.Abort(_("missing largefile for \'%s\' in %s")
142 raise error.Abort(_("missing largefile for '%s' in %s")
143 % (realname, realrev))
143 % (realname, realrev))
144 fp = open(path, 'rb')
144 fp = open(path, 'rb')
145
145
@@ -157,7 +157,7 b' def lfconvert(ui, src, dest, *pats, **op'
157
157
158 found, missing = downloadlfiles(ui, rsrc)
158 found, missing = downloadlfiles(ui, rsrc)
159 if missing != 0:
159 if missing != 0:
160 raise util.Abort(_("all largefiles must be present locally"))
160 raise error.Abort(_("all largefiles must be present locally"))
161
161
162 orig = convcmd.converter
162 orig = convcmd.converter
163 convcmd.converter = converter
163 convcmd.converter = converter
@@ -196,7 +196,7 b' def _lfconvert_addchangeset(rsrc, rdst, '
196 islfile |= renamedlfile
196 islfile |= renamedlfile
197 if 'l' in fctx.flags():
197 if 'l' in fctx.flags():
198 if renamedlfile:
198 if renamedlfile:
199 raise util.Abort(
199 raise error.Abort(
200 _('renamed/copied largefile %s becomes symlink')
200 _('renamed/copied largefile %s becomes symlink')
201 % f)
201 % f)
202 islfile = False
202 islfile = False
@@ -213,7 +213,7 b' def _lfconvert_addchangeset(rsrc, rdst, '
213 if 'l' in fctx.flags():
213 if 'l' in fctx.flags():
214 renamed = fctx.renamed()
214 renamed = fctx.renamed()
215 if renamed and renamed[0] in lfiles:
215 if renamed and renamed[0] in lfiles:
216 raise util.Abort(_('largefile %s becomes symlink') % f)
216 raise error.Abort(_('largefile %s becomes symlink') % f)
217
217
218 # largefile was modified, update standins
218 # largefile was modified, update standins
219 m = util.sha1('')
219 m = util.sha1('')
@@ -355,7 +355,7 b' def uploadlfiles(ui, rsrc, rdst, files):'
355 total=len(files))
355 total=len(files))
356 source = lfutil.findfile(rsrc, hash)
356 source = lfutil.findfile(rsrc, hash)
357 if not source:
357 if not source:
358 raise util.Abort(_('largefile %s missing from store'
358 raise error.Abort(_('largefile %s missing from store'
359 ' (needs to be uploaded)') % hash)
359 ' (needs to be uploaded)') % hash)
360 # XXX check for errors here
360 # XXX check for errors here
361 store.put(source, hash)
361 store.put(source, hash)
@@ -539,7 +539,7 b' def lfpull(ui, repo, source="default", *'
539
539
540 revs = opts.get('rev', [])
540 revs = opts.get('rev', [])
541 if not revs:
541 if not revs:
542 raise util.Abort(_('no revisions specified'))
542 raise error.Abort(_('no revisions specified'))
543 revs = scmutil.revrange(repo, revs)
543 revs = scmutil.revrange(repo, revs)
544
544
545 numcached = 0
545 numcached = 0
@@ -16,7 +16,7 b' import copy'
16
16
17 from mercurial import dirstate, httpconnection, match as match_, util, scmutil
17 from mercurial import dirstate, httpconnection, match as match_, util, scmutil
18 from mercurial.i18n import _
18 from mercurial.i18n import _
19 from mercurial import node
19 from mercurial import node, error
20
20
21 shortname = '.hglf'
21 shortname = '.hglf'
22 shortnameslash = shortname + '/'
22 shortnameslash = shortname + '/'
@@ -33,10 +33,10 b' def getminsize(ui, assumelfiles, opt, de'
33 try:
33 try:
34 lfsize = float(lfsize)
34 lfsize = float(lfsize)
35 except ValueError:
35 except ValueError:
36 raise util.Abort(_('largefiles: size must be number (not %s)\n')
36 raise error.Abort(_('largefiles: size must be number (not %s)\n')
37 % lfsize)
37 % lfsize)
38 if lfsize is None:
38 if lfsize is None:
39 raise util.Abort(_('minimum size for largefiles must be specified'))
39 raise error.Abort(_('minimum size for largefiles must be specified'))
40 return lfsize
40 return lfsize
41
41
42 def link(src, dest):
42 def link(src, dest):
@@ -74,7 +74,7 b' def usercachepath(ui, hash):'
74 if home:
74 if home:
75 path = os.path.join(home, '.cache', longname, hash)
75 path = os.path.join(home, '.cache', longname, hash)
76 else:
76 else:
77 raise util.Abort(_('unknown operating system: %s\n') % os.name)
77 raise error.Abort(_('unknown operating system: %s\n') % os.name)
78 return path
78 return path
79
79
80 def inusercache(ui, hash):
80 def inusercache(ui, hash):
@@ -12,7 +12,7 b' import os'
12 import copy
12 import copy
13
13
14 from mercurial import hg, util, cmdutil, scmutil, match as match_, \
14 from mercurial import hg, util, cmdutil, scmutil, match as match_, \
15 archival, pathutil, revset
15 archival, pathutil, revset, error
16 from mercurial.i18n import _
16 from mercurial.i18n import _
17
17
18 import lfutil
18 import lfutil
@@ -245,7 +245,7 b' def decodepath(orig, path):'
245
245
246 def overrideadd(orig, ui, repo, *pats, **opts):
246 def overrideadd(orig, ui, repo, *pats, **opts):
247 if opts.get('normal') and opts.get('large'):
247 if opts.get('normal') and opts.get('large'):
248 raise util.Abort(_('--normal cannot be used with --large'))
248 raise error.Abort(_('--normal cannot be used with --large'))
249 return orig(ui, repo, *pats, **opts)
249 return orig(ui, repo, *pats, **opts)
250
250
251 def cmdutiladd(orig, ui, repo, matcher, prefix, explicitonly, **opts):
251 def cmdutiladd(orig, ui, repo, matcher, prefix, explicitonly, **opts):
@@ -584,7 +584,7 b' def overridecopy(orig, ui, repo, pats, o'
584 installnormalfilesmatchfn(repo[None].manifest())
584 installnormalfilesmatchfn(repo[None].manifest())
585 try:
585 try:
586 result = orig(ui, repo, pats, opts, rename)
586 result = orig(ui, repo, pats, opts, rename)
587 except util.Abort as e:
587 except error.Abort as e:
588 if str(e) != _('no files to copy'):
588 if str(e) != _('no files to copy'):
589 raise e
589 raise e
590 else:
590 else:
@@ -688,7 +688,7 b' def overridecopy(orig, ui, repo, pats, o'
688
688
689 lfdirstate.add(destlfile)
689 lfdirstate.add(destlfile)
690 lfdirstate.write()
690 lfdirstate.write()
691 except util.Abort as e:
691 except error.Abort as e:
692 if str(e) != _('no files to copy'):
692 if str(e) != _('no files to copy'):
693 raise e
693 raise e
694 else:
694 else:
@@ -698,7 +698,7 b' def overridecopy(orig, ui, repo, pats, o'
698 wlock.release()
698 wlock.release()
699
699
700 if nolfiles and nonormalfiles:
700 if nolfiles and nonormalfiles:
701 raise util.Abort(_('no files to copy'))
701 raise error.Abort(_('no files to copy'))
702
702
703 return result
703 return result
704
704
@@ -827,7 +827,7 b' def pulledrevsetsymbol(repo, subset, x):'
827 try:
827 try:
828 firstpulled = repo.firstpulled
828 firstpulled = repo.firstpulled
829 except AttributeError:
829 except AttributeError:
830 raise util.Abort(_("pulled() only available in --lfrev"))
830 raise error.Abort(_("pulled() only available in --lfrev"))
831 return revset.baseset([r for r in subset if r >= firstpulled])
831 return revset.baseset([r for r in subset if r >= firstpulled])
832
832
833 def overrideclone(orig, ui, source, dest=None, **opts):
833 def overrideclone(orig, ui, source, dest=None, **opts):
@@ -835,7 +835,7 b' def overrideclone(orig, ui, source, dest'
835 if d is None:
835 if d is None:
836 d = hg.defaultdest(source)
836 d = hg.defaultdest(source)
837 if opts.get('all_largefiles') and not hg.islocal(d):
837 if opts.get('all_largefiles') and not hg.islocal(d):
838 raise util.Abort(_(
838 raise error.Abort(_(
839 '--all-largefiles is incompatible with non-local destination %s') %
839 '--all-largefiles is incompatible with non-local destination %s') %
840 d)
840 d)
841
841
@@ -916,13 +916,13 b' def overridearchive(orig, repo, dest, no'
916 lfcommands.cachelfiles(repo.ui, repo, node)
916 lfcommands.cachelfiles(repo.ui, repo, node)
917
917
918 if kind not in archival.archivers:
918 if kind not in archival.archivers:
919 raise util.Abort(_("unknown archive type '%s'") % kind)
919 raise error.Abort(_("unknown archive type '%s'") % kind)
920
920
921 ctx = repo[node]
921 ctx = repo[node]
922
922
923 if kind == 'files':
923 if kind == 'files':
924 if prefix:
924 if prefix:
925 raise util.Abort(
925 raise error.Abort(
926 _('cannot give prefix when archiving to files'))
926 _('cannot give prefix when archiving to files'))
927 else:
927 else:
928 prefix = archival.tidyprefix(dest, kind, prefix)
928 prefix = archival.tidyprefix(dest, kind, prefix)
@@ -949,7 +949,7 b' def overridearchive(orig, repo, dest, no'
949 path = lfutil.findfile(repo, getdata().strip())
949 path = lfutil.findfile(repo, getdata().strip())
950
950
951 if path is None:
951 if path is None:
952 raise util.Abort(
952 raise error.Abort(
953 _('largefile %s not found in repo store or system cache')
953 _('largefile %s not found in repo store or system cache')
954 % lfutil.splitstandin(f))
954 % lfutil.splitstandin(f))
955 else:
955 else:
@@ -1006,7 +1006,7 b' def hgsubrepoarchive(orig, repo, archive'
1006 path = lfutil.findfile(repo._repo, getdata().strip())
1006 path = lfutil.findfile(repo._repo, getdata().strip())
1007
1007
1008 if path is None:
1008 if path is None:
1009 raise util.Abort(
1009 raise error.Abort(
1010 _('largefile %s not found in repo store or system cache')
1010 _('largefile %s not found in repo store or system cache')
1011 % lfutil.splitstandin(f))
1011 % lfutil.splitstandin(f))
1012 else:
1012 else:
@@ -1043,7 +1043,7 b' def overridebailifchanged(orig, repo, *a'
1043 s = repo.status()
1043 s = repo.status()
1044 repo.lfstatus = False
1044 repo.lfstatus = False
1045 if s.modified or s.added or s.removed or s.deleted:
1045 if s.modified or s.added or s.removed or s.deleted:
1046 raise util.Abort(_('uncommitted changes'))
1046 raise error.Abort(_('uncommitted changes'))
1047
1047
1048 def cmdutilforget(orig, ui, repo, match, prefix, explicitonly):
1048 def cmdutilforget(orig, ui, repo, match, prefix, explicitonly):
1049 normalmatcher = composenormalfilematcher(match, repo[None].manifest())
1049 normalmatcher = composenormalfilematcher(match, repo[None].manifest())
@@ -1344,7 +1344,7 b' def overridecat(orig, ui, repo, file1, *'
1344 store = basestore._openstore(repo)
1344 store = basestore._openstore(repo)
1345 success, missing = store.get([(lf, hash)])
1345 success, missing = store.get([(lf, hash)])
1346 if len(success) != 1:
1346 if len(success) != 1:
1347 raise util.Abort(
1347 raise error.Abort(
1348 _('largefile %s is not in cache and could not be '
1348 _('largefile %s is not in cache and could not be '
1349 'downloaded') % lf)
1349 'downloaded') % lf)
1350 path = lfutil.usercachepath(repo.ui, hash)
1350 path = lfutil.usercachepath(repo.ui, hash)
@@ -51,7 +51,8 b' def getlfile(repo, proto, sha):'
51 cache.'''
51 cache.'''
52 filename = lfutil.findfile(repo, sha)
52 filename = lfutil.findfile(repo, sha)
53 if not filename:
53 if not filename:
54 raise util.Abort(_('requested largefile %s not present in cache') % sha)
54 raise error.Abort(_('requested largefile %s not present in cache')
55 % sha)
55 f = open(filename, 'rb')
56 f = open(filename, 'rb')
56 length = os.fstat(f.fileno())[6]
57 length = os.fstat(f.fileno())[6]
57
58
@@ -8,7 +8,7 b''
8
8
9 import urllib2
9 import urllib2
10
10
11 from mercurial import util, wireproto
11 from mercurial import util, wireproto, error
12 from mercurial.i18n import _
12 from mercurial.i18n import _
13
13
14 import lfutil
14 import lfutil
@@ -21,7 +21,7 b' class remotestore(basestore.basestore):'
21
21
22 def put(self, source, hash):
22 def put(self, source, hash):
23 if self.sendfile(source, hash):
23 if self.sendfile(source, hash):
24 raise util.Abort(
24 raise error.Abort(
25 _('remotestore: could not put %s to remote store %s')
25 _('remotestore: could not put %s to remote store %s')
26 % (source, util.hidepassword(self.url)))
26 % (source, util.hidepassword(self.url)))
27 self.ui.debug(
27 self.ui.debug(
@@ -39,7 +39,7 b' class remotestore(basestore.basestore):'
39 fd = lfutil.httpsendfile(self.ui, filename)
39 fd = lfutil.httpsendfile(self.ui, filename)
40 return self._put(hash, fd)
40 return self._put(hash, fd)
41 except IOError as e:
41 except IOError as e:
42 raise util.Abort(
42 raise error.Abort(
43 _('remotestore: could not open file %s: %s')
43 _('remotestore: could not open file %s: %s')
44 % (filename, str(e)))
44 % (filename, str(e)))
45 finally:
45 finally:
@@ -50,14 +50,14 b' class remotestore(basestore.basestore):'
50 try:
50 try:
51 chunks = self._get(hash)
51 chunks = self._get(hash)
52 except urllib2.HTTPError as e:
52 except urllib2.HTTPError as e:
53 # 401s get converted to util.Aborts; everything else is fine being
53 # 401s get converted to error.Aborts; everything else is fine being
54 # turned into a StoreError
54 # turned into a StoreError
55 raise basestore.StoreError(filename, hash, self.url, str(e))
55 raise basestore.StoreError(filename, hash, self.url, str(e))
56 except urllib2.URLError as e:
56 except urllib2.URLError as e:
57 # This usually indicates a connection problem, so don't
57 # This usually indicates a connection problem, so don't
58 # keep trying with the other files... they will probably
58 # keep trying with the other files... they will probably
59 # all fail too.
59 # all fail too.
60 raise util.Abort('%s: %s' %
60 raise error.Abort('%s: %s' %
61 (util.hidepassword(self.url), e.reason))
61 (util.hidepassword(self.url), e.reason))
62 except IOError as e:
62 except IOError as e:
63 raise basestore.StoreError(filename, hash, self.url, str(e))
63 raise basestore.StoreError(filename, hash, self.url, str(e))
@@ -10,7 +10,7 b''
10 import copy
10 import copy
11 import os
11 import os
12
12
13 from mercurial import error, match as match_, util
13 from mercurial import error, match as match_, error
14 from mercurial.i18n import _
14 from mercurial.i18n import _
15 from mercurial import scmutil, localrepo
15 from mercurial import scmutil, localrepo
16
16
@@ -280,7 +280,7 b' def reposetup(ui, repo):'
280 msg = _("required features are not"
280 msg = _("required features are not"
281 " supported in the destination:"
281 " supported in the destination:"
282 " %s") % (', '.join(sorted(missing)))
282 " %s") % (', '.join(sorted(missing)))
283 raise util.Abort(msg)
283 raise error.Abort(msg)
284 return super(lfilesrepo, self).push(remote, force=force, revs=revs,
284 return super(lfilesrepo, self).push(remote, force=force, revs=revs,
285 newbranch=newbranch)
285 newbranch=newbranch)
286
286
@@ -304,7 +304,7 b' def reposetup(ui, repo):'
304
304
305 for f in files:
305 for f in files:
306 if lfutil.isstandin(f + '/'):
306 if lfutil.isstandin(f + '/'):
307 raise util.Abort(
307 raise error.Abort(
308 _('file "%s" is a largefile standin') % f,
308 _('file "%s" is a largefile standin') % f,
309 hint=('commit the largefile itself instead'))
309 hint=('commit the largefile itself instead'))
310 # Scan directories
310 # Scan directories
@@ -492,7 +492,7 b' class queue(object):'
492 elif self.gitmode in ('yes', 'no'):
492 elif self.gitmode in ('yes', 'no'):
493 diffopts.git = self.gitmode == 'yes'
493 diffopts.git = self.gitmode == 'yes'
494 else:
494 else:
495 raise util.Abort(_('mq.git option can be auto/keep/yes/no'
495 raise error.Abort(_('mq.git option can be auto/keep/yes/no'
496 ' got %s') % self.gitmode)
496 ' got %s') % self.gitmode)
497 if patchfn:
497 if patchfn:
498 diffopts = self.patchopts(diffopts, patchfn)
498 diffopts = self.patchopts(diffopts, patchfn)
@@ -544,7 +544,7 b' class queue(object):'
544 patch = patch.strip()
544 patch = patch.strip()
545 if patch:
545 if patch:
546 if patch in self.series:
546 if patch in self.series:
547 raise util.Abort(_('%s appears more than once in %s') %
547 raise error.Abort(_('%s appears more than once in %s') %
548 (patch, self.join(self.seriespath)))
548 (patch, self.join(self.seriespath)))
549 self.series.append(patch)
549 self.series.append(patch)
550 self.seriesguards.append(self.guard_re.findall(comment))
550 self.seriesguards.append(self.guard_re.findall(comment))
@@ -565,7 +565,7 b' class queue(object):'
565 for guard in guards:
565 for guard in guards:
566 bad = self.checkguard(guard)
566 bad = self.checkguard(guard)
567 if bad:
567 if bad:
568 raise util.Abort(bad)
568 raise error.Abort(bad)
569 guards = sorted(set(guards))
569 guards = sorted(set(guards))
570 self.ui.debug('active guards: %s\n' % ' '.join(guards))
570 self.ui.debug('active guards: %s\n' % ' '.join(guards))
571 self.activeguards = guards
571 self.activeguards = guards
@@ -592,12 +592,12 b' class queue(object):'
592 def setguards(self, idx, guards):
592 def setguards(self, idx, guards):
593 for g in guards:
593 for g in guards:
594 if len(g) < 2:
594 if len(g) < 2:
595 raise util.Abort(_('guard %r too short') % g)
595 raise error.Abort(_('guard %r too short') % g)
596 if g[0] not in '-+':
596 if g[0] not in '-+':
597 raise util.Abort(_('guard %r starts with invalid char') % g)
597 raise error.Abort(_('guard %r starts with invalid char') % g)
598 bad = self.checkguard(g[1:])
598 bad = self.checkguard(g[1:])
599 if bad:
599 if bad:
600 raise util.Abort(bad)
600 raise error.Abort(bad)
601 drop = self.guard_re.sub('', self.fullseries[idx])
601 drop = self.guard_re.sub('', self.fullseries[idx])
602 self.fullseries[idx] = drop + ''.join([' #' + g for g in guards])
602 self.fullseries[idx] = drop + ''.join([' #' + g for g in guards])
603 self.parseseries()
603 self.parseseries()
@@ -708,7 +708,7 b' class queue(object):'
708 return (err, n)
708 return (err, n)
709
709
710 if n is None:
710 if n is None:
711 raise util.Abort(_("apply failed for patch %s") % patch)
711 raise error.Abort(_("apply failed for patch %s") % patch)
712
712
713 self.ui.warn(_("patch didn't work out, merging %s\n") % patch)
713 self.ui.warn(_("patch didn't work out, merging %s\n") % patch)
714
714
@@ -719,14 +719,14 b' class queue(object):'
719 ctx = repo[rev]
719 ctx = repo[rev]
720 ret = hg.merge(repo, rev)
720 ret = hg.merge(repo, rev)
721 if ret:
721 if ret:
722 raise util.Abort(_("update returned %d") % ret)
722 raise error.Abort(_("update returned %d") % ret)
723 n = newcommit(repo, None, ctx.description(), ctx.user(), force=True)
723 n = newcommit(repo, None, ctx.description(), ctx.user(), force=True)
724 if n is None:
724 if n is None:
725 raise util.Abort(_("repo commit failed"))
725 raise error.Abort(_("repo commit failed"))
726 try:
726 try:
727 ph = patchheader(mergeq.join(patch), self.plainmode)
727 ph = patchheader(mergeq.join(patch), self.plainmode)
728 except Exception:
728 except Exception:
729 raise util.Abort(_("unable to read %s") % patch)
729 raise error.Abort(_("unable to read %s") % patch)
730
730
731 diffopts = self.patchopts(diffopts, patch)
731 diffopts = self.patchopts(diffopts, patch)
732 patchf = self.opener(patch, "w")
732 patchf = self.opener(patch, "w")
@@ -931,9 +931,9 b' class queue(object):'
931 n = newcommit(repo, None, message, ph.user, ph.date, match=match,
931 n = newcommit(repo, None, message, ph.user, ph.date, match=match,
932 force=True)
932 force=True)
933 if repo['tip'] == oldtip:
933 if repo['tip'] == oldtip:
934 raise util.Abort(_("qpush exactly duplicates child changeset"))
934 raise error.Abort(_("qpush exactly duplicates child changeset"))
935 if n is None:
935 if n is None:
936 raise util.Abort(_("repository commit failed"))
936 raise error.Abort(_("repository commit failed"))
937
937
938 if update_status:
938 if update_status:
939 self.applied.append(statusentry(n, patchname))
939 self.applied.append(statusentry(n, patchname))
@@ -985,7 +985,7 b' class queue(object):'
985 self.ui.warn(msg % (short(rev[p]), p))
985 self.ui.warn(msg % (short(rev[p]), p))
986 else:
986 else:
987 msg = _('unknown patches: %s\n')
987 msg = _('unknown patches: %s\n')
988 raise util.Abort(''.join(msg % p for p in unknown))
988 raise error.Abort(''.join(msg % p for p in unknown))
989
989
990 self.parseseries()
990 self.parseseries()
991 self.seriesdirty = True
991 self.seriesdirty = True
@@ -997,13 +997,13 b' class queue(object):'
997 for i, rev in enumerate(revs):
997 for i, rev in enumerate(revs):
998
998
999 if rev < firstrev:
999 if rev < firstrev:
1000 raise util.Abort(_('revision %d is not managed') % rev)
1000 raise error.Abort(_('revision %d is not managed') % rev)
1001
1001
1002 ctx = repo[rev]
1002 ctx = repo[rev]
1003 base = self.applied[i].node
1003 base = self.applied[i].node
1004 if ctx.node() != base:
1004 if ctx.node() != base:
1005 msg = _('cannot delete revision %d above applied patches')
1005 msg = _('cannot delete revision %d above applied patches')
1006 raise util.Abort(msg % rev)
1006 raise error.Abort(msg % rev)
1007
1007
1008 patch = self.applied[i].name
1008 patch = self.applied[i].name
1009 for fmt in ('[mq]: %s', 'imported patch %s'):
1009 for fmt in ('[mq]: %s', 'imported patch %s'):
@@ -1035,7 +1035,7 b' class queue(object):'
1035
1035
1036 def delete(self, repo, patches, opts):
1036 def delete(self, repo, patches, opts):
1037 if not patches and not opts.get('rev'):
1037 if not patches and not opts.get('rev'):
1038 raise util.Abort(_('qdelete requires at least one revision or '
1038 raise error.Abort(_('qdelete requires at least one revision or '
1039 'patch name'))
1039 'patch name'))
1040
1040
1041 realpatches = []
1041 realpatches = []
@@ -1043,16 +1043,16 b' class queue(object):'
1043 patch = self.lookup(patch, strict=True)
1043 patch = self.lookup(patch, strict=True)
1044 info = self.isapplied(patch)
1044 info = self.isapplied(patch)
1045 if info:
1045 if info:
1046 raise util.Abort(_("cannot delete applied patch %s") % patch)
1046 raise error.Abort(_("cannot delete applied patch %s") % patch)
1047 if patch not in self.series:
1047 if patch not in self.series:
1048 raise util.Abort(_("patch %s not in series file") % patch)
1048 raise error.Abort(_("patch %s not in series file") % patch)
1049 if patch not in realpatches:
1049 if patch not in realpatches:
1050 realpatches.append(patch)
1050 realpatches.append(patch)
1051
1051
1052 numrevs = 0
1052 numrevs = 0
1053 if opts.get('rev'):
1053 if opts.get('rev'):
1054 if not self.applied:
1054 if not self.applied:
1055 raise util.Abort(_('no patches applied'))
1055 raise error.Abort(_('no patches applied'))
1056 revs = scmutil.revrange(repo, opts.get('rev'))
1056 revs = scmutil.revrange(repo, opts.get('rev'))
1057 revs.sort()
1057 revs.sort()
1058 revpatches = self._revpatches(repo, revs)
1058 revpatches = self._revpatches(repo, revs)
@@ -1067,7 +1067,7 b' class queue(object):'
1067 top = self.applied[-1].node
1067 top = self.applied[-1].node
1068 patch = self.applied[-1].name
1068 patch = self.applied[-1].name
1069 if repo.dirstate.p1() != top:
1069 if repo.dirstate.p1() != top:
1070 raise util.Abort(_("working directory revision is not qtip"))
1070 raise error.Abort(_("working directory revision is not qtip"))
1071 return top, patch
1071 return top, patch
1072 return None, None
1072 return None, None
1073
1073
@@ -1095,29 +1095,29 b' class queue(object):'
1095 _reserved = ('series', 'status', 'guards', '.', '..')
1095 _reserved = ('series', 'status', 'guards', '.', '..')
1096 def checkreservedname(self, name):
1096 def checkreservedname(self, name):
1097 if name in self._reserved:
1097 if name in self._reserved:
1098 raise util.Abort(_('"%s" cannot be used as the name of a patch')
1098 raise error.Abort(_('"%s" cannot be used as the name of a patch')
1099 % name)
1099 % name)
1100 for prefix in ('.hg', '.mq'):
1100 for prefix in ('.hg', '.mq'):
1101 if name.startswith(prefix):
1101 if name.startswith(prefix):
1102 raise util.Abort(_('patch name cannot begin with "%s"')
1102 raise error.Abort(_('patch name cannot begin with "%s"')
1103 % prefix)
1103 % prefix)
1104 for c in ('#', ':', '\r', '\n'):
1104 for c in ('#', ':', '\r', '\n'):
1105 if c in name:
1105 if c in name:
1106 raise util.Abort(_('%r cannot be used in the name of a patch')
1106 raise error.Abort(_('%r cannot be used in the name of a patch')
1107 % c)
1107 % c)
1108
1108
1109 def checkpatchname(self, name, force=False):
1109 def checkpatchname(self, name, force=False):
1110 self.checkreservedname(name)
1110 self.checkreservedname(name)
1111 if not force and os.path.exists(self.join(name)):
1111 if not force and os.path.exists(self.join(name)):
1112 if os.path.isdir(self.join(name)):
1112 if os.path.isdir(self.join(name)):
1113 raise util.Abort(_('"%s" already exists as a directory')
1113 raise error.Abort(_('"%s" already exists as a directory')
1114 % name)
1114 % name)
1115 else:
1115 else:
1116 raise util.Abort(_('patch "%s" already exists') % name)
1116 raise error.Abort(_('patch "%s" already exists') % name)
1117
1117
1118 def checkkeepchanges(self, keepchanges, force):
1118 def checkkeepchanges(self, keepchanges, force):
1119 if force and keepchanges:
1119 if force and keepchanges:
1120 raise util.Abort(_('cannot use both --force and --keep-changes'))
1120 raise error.Abort(_('cannot use both --force and --keep-changes'))
1121
1121
1122 def new(self, repo, patchfn, *pats, **opts):
1122 def new(self, repo, patchfn, *pats, **opts):
1123 """options:
1123 """options:
@@ -1140,7 +1140,7 b' class queue(object):'
1140 # detect missing files in pats
1140 # detect missing files in pats
1141 def badfn(f, msg):
1141 def badfn(f, msg):
1142 if f != '.hgsubstate': # .hgsubstate is auto-created
1142 if f != '.hgsubstate': # .hgsubstate is auto-created
1143 raise util.Abort('%s: %s' % (f, msg))
1143 raise error.Abort('%s: %s' % (f, msg))
1144 match = scmutil.match(repo[None], pats, opts, badfn=badfn)
1144 match = scmutil.match(repo[None], pats, opts, badfn=badfn)
1145 changes = repo.status(match=match)
1145 changes = repo.status(match=match)
1146 else:
1146 else:
@@ -1150,7 +1150,7 b' class queue(object):'
1150 commitfiles.extend(files)
1150 commitfiles.extend(files)
1151 match = scmutil.matchfiles(repo, commitfiles)
1151 match = scmutil.matchfiles(repo, commitfiles)
1152 if len(repo[None].parents()) > 1:
1152 if len(repo[None].parents()) > 1:
1153 raise util.Abort(_('cannot manage merge changesets'))
1153 raise error.Abort(_('cannot manage merge changesets'))
1154 self.checktoppatch(repo)
1154 self.checktoppatch(repo)
1155 insert = self.fullseriesend()
1155 insert = self.fullseriesend()
1156 wlock = repo.wlock()
1156 wlock = repo.wlock()
@@ -1159,7 +1159,7 b' class queue(object):'
1159 # if patch file write fails, abort early
1159 # if patch file write fails, abort early
1160 p = self.opener(patchfn, "w")
1160 p = self.opener(patchfn, "w")
1161 except IOError as e:
1161 except IOError as e:
1162 raise util.Abort(_('cannot write patch "%s": %s')
1162 raise error.Abort(_('cannot write patch "%s": %s')
1163 % (patchfn, e.strerror))
1163 % (patchfn, e.strerror))
1164 try:
1164 try:
1165 defaultmsg = "[mq]: %s" % patchfn
1165 defaultmsg = "[mq]: %s" % patchfn
@@ -1182,7 +1182,7 b' class queue(object):'
1182 n = newcommit(repo, None, commitmsg, user, date, match=match,
1182 n = newcommit(repo, None, commitmsg, user, date, match=match,
1183 force=True, editor=editor)
1183 force=True, editor=editor)
1184 if n is None:
1184 if n is None:
1185 raise util.Abort(_("repo commit failed"))
1185 raise error.Abort(_("repo commit failed"))
1186 try:
1186 try:
1187 self.fullseries[insert:insert] = [patchfn]
1187 self.fullseries[insert:insert] = [patchfn]
1188 self.applied.append(statusentry(n, patchfn))
1188 self.applied.append(statusentry(n, patchfn))
@@ -1299,7 +1299,7 b' class queue(object):'
1299 else:
1299 else:
1300 if i + off < len(self.series):
1300 if i + off < len(self.series):
1301 return self.series[i + off]
1301 return self.series[i + off]
1302 raise util.Abort(_("patch %s not in series") % patch)
1302 raise error.Abort(_("patch %s not in series") % patch)
1303
1303
1304 def push(self, repo, patch=None, force=False, list=False, mergeq=None,
1304 def push(self, repo, patch=None, force=False, list=False, mergeq=None,
1305 all=False, move=False, exact=False, nobackup=False,
1305 all=False, move=False, exact=False, nobackup=False,
@@ -1335,7 +1335,7 b' class queue(object):'
1335 pushable, reason = self.pushable(patch)
1335 pushable, reason = self.pushable(patch)
1336 if pushable:
1336 if pushable:
1337 if self.series.index(patch) < self.seriesend():
1337 if self.series.index(patch) < self.seriesend():
1338 raise util.Abort(
1338 raise error.Abort(
1339 _("cannot push to a previous patch: %s") % patch)
1339 _("cannot push to a previous patch: %s") % patch)
1340 else:
1340 else:
1341 if reason:
1341 if reason:
@@ -1364,25 +1364,25 b' class queue(object):'
1364
1364
1365 if exact:
1365 if exact:
1366 if keepchanges:
1366 if keepchanges:
1367 raise util.Abort(
1367 raise error.Abort(
1368 _("cannot use --exact and --keep-changes together"))
1368 _("cannot use --exact and --keep-changes together"))
1369 if move:
1369 if move:
1370 raise util.Abort(_('cannot use --exact and --move '
1370 raise error.Abort(_('cannot use --exact and --move '
1371 'together'))
1371 'together'))
1372 if self.applied:
1372 if self.applied:
1373 raise util.Abort(_('cannot push --exact with applied '
1373 raise error.Abort(_('cannot push --exact with applied '
1374 'patches'))
1374 'patches'))
1375 root = self.series[start]
1375 root = self.series[start]
1376 target = patchheader(self.join(root), self.plainmode).parent
1376 target = patchheader(self.join(root), self.plainmode).parent
1377 if not target:
1377 if not target:
1378 raise util.Abort(
1378 raise error.Abort(
1379 _("%s does not have a parent recorded") % root)
1379 _("%s does not have a parent recorded") % root)
1380 if not repo[target] == repo['.']:
1380 if not repo[target] == repo['.']:
1381 hg.update(repo, target)
1381 hg.update(repo, target)
1382
1382
1383 if move:
1383 if move:
1384 if not patch:
1384 if not patch:
1385 raise util.Abort(_("please specify the patch to move"))
1385 raise error.Abort(_("please specify the patch to move"))
1386 for fullstart, rpn in enumerate(self.fullseries):
1386 for fullstart, rpn in enumerate(self.fullseries):
1387 # strip markers for patch guards
1387 # strip markers for patch guards
1388 if self.guard_re.split(rpn, 1)[0] == self.series[start]:
1388 if self.guard_re.split(rpn, 1)[0] == self.series[start]:
@@ -1464,7 +1464,7 b' class queue(object):'
1464 patch = self.lookup(patch)
1464 patch = self.lookup(patch)
1465 info = self.isapplied(patch)
1465 info = self.isapplied(patch)
1466 if not info:
1466 if not info:
1467 raise util.Abort(_("patch %s is not applied") % patch)
1467 raise error.Abort(_("patch %s is not applied") % patch)
1468
1468
1469 if not self.applied:
1469 if not self.applied:
1470 # Allow qpop -a to work repeatedly,
1470 # Allow qpop -a to work repeatedly,
@@ -1517,13 +1517,13 b' class queue(object):'
1517 heads = repo.changelog.heads(rev)
1517 heads = repo.changelog.heads(rev)
1518 except error.LookupError:
1518 except error.LookupError:
1519 node = short(rev)
1519 node = short(rev)
1520 raise util.Abort(_('trying to pop unknown node %s') % node)
1520 raise error.Abort(_('trying to pop unknown node %s') % node)
1521
1521
1522 if heads != [self.applied[-1].node]:
1522 if heads != [self.applied[-1].node]:
1523 raise util.Abort(_("popping would remove a revision not "
1523 raise error.Abort(_("popping would remove a revision not "
1524 "managed by this patch queue"))
1524 "managed by this patch queue"))
1525 if not repo[self.applied[-1].node].mutable():
1525 if not repo[self.applied[-1].node].mutable():
1526 raise util.Abort(
1526 raise error.Abort(
1527 _("popping would remove a public revision"),
1527 _("popping would remove a public revision"),
1528 hint=_('see "hg help phases" for details'))
1528 hint=_('see "hg help phases" for details'))
1529
1529
@@ -1534,11 +1534,11 b' class queue(object):'
1534 ctx = repo[qp]
1534 ctx = repo[qp]
1535 m, a, r, d = repo.status(qp, '.')[:4]
1535 m, a, r, d = repo.status(qp, '.')[:4]
1536 if d:
1536 if d:
1537 raise util.Abort(_("deletions found between repo revs"))
1537 raise error.Abort(_("deletions found between repo revs"))
1538
1538
1539 tobackup = set(a + m + r) & tobackup
1539 tobackup = set(a + m + r) & tobackup
1540 if keepchanges and tobackup:
1540 if keepchanges and tobackup:
1541 raise util.Abort(_("local changes found, refresh first"))
1541 raise error.Abort(_("local changes found, refresh first"))
1542 self.backup(repo, tobackup)
1542 self.backup(repo, tobackup)
1543 repo.dirstate.beginparentchange()
1543 repo.dirstate.beginparentchange()
1544 for f in a:
1544 for f in a:
@@ -1593,9 +1593,9 b' class queue(object):'
1593 self.checktoppatch(repo)
1593 self.checktoppatch(repo)
1594 (top, patchfn) = (self.applied[-1].node, self.applied[-1].name)
1594 (top, patchfn) = (self.applied[-1].node, self.applied[-1].name)
1595 if repo.changelog.heads(top) != [top]:
1595 if repo.changelog.heads(top) != [top]:
1596 raise util.Abort(_("cannot refresh a revision with children"))
1596 raise error.Abort(_("cannot refresh a revision with children"))
1597 if not repo[top].mutable():
1597 if not repo[top].mutable():
1598 raise util.Abort(_("cannot refresh public revision"),
1598 raise error.Abort(_("cannot refresh public revision"),
1599 hint=_('see "hg help phases" for details'))
1599 hint=_('see "hg help phases" for details'))
1600
1600
1601 cparents = repo.changelog.parents(top)
1601 cparents = repo.changelog.parents(top)
@@ -1812,7 +1812,7 b' class queue(object):'
1812
1812
1813 def init(self, repo, create=False):
1813 def init(self, repo, create=False):
1814 if not create and os.path.isdir(self.path):
1814 if not create and os.path.isdir(self.path):
1815 raise util.Abort(_("patch queue directory already exists"))
1815 raise error.Abort(_("patch queue directory already exists"))
1816 try:
1816 try:
1817 os.mkdir(self.path)
1817 os.mkdir(self.path)
1818 except OSError as inst:
1818 except OSError as inst:
@@ -1823,7 +1823,7 b' class queue(object):'
1823
1823
1824 def unapplied(self, repo, patch=None):
1824 def unapplied(self, repo, patch=None):
1825 if patch and patch not in self.series:
1825 if patch and patch not in self.series:
1826 raise util.Abort(_("patch %s is not in series file") % patch)
1826 raise error.Abort(_("patch %s is not in series file") % patch)
1827 if not patch:
1827 if not patch:
1828 start = self.seriesend()
1828 start = self.seriesend()
1829 else:
1829 else:
@@ -2031,19 +2031,19 b' class queue(object):'
2031 force=None, git=False):
2031 force=None, git=False):
2032 def checkseries(patchname):
2032 def checkseries(patchname):
2033 if patchname in self.series:
2033 if patchname in self.series:
2034 raise util.Abort(_('patch %s is already in the series file')
2034 raise error.Abort(_('patch %s is already in the series file')
2035 % patchname)
2035 % patchname)
2036
2036
2037 if rev:
2037 if rev:
2038 if files:
2038 if files:
2039 raise util.Abort(_('option "-r" not valid when importing '
2039 raise error.Abort(_('option "-r" not valid when importing '
2040 'files'))
2040 'files'))
2041 rev = scmutil.revrange(repo, rev)
2041 rev = scmutil.revrange(repo, rev)
2042 rev.sort(reverse=True)
2042 rev.sort(reverse=True)
2043 elif not files:
2043 elif not files:
2044 raise util.Abort(_('no files or revisions specified'))
2044 raise error.Abort(_('no files or revisions specified'))
2045 if (len(files) > 1 or len(rev) > 1) and patchname:
2045 if (len(files) > 1 or len(rev) > 1) and patchname:
2046 raise util.Abort(_('option "-n" not valid when importing multiple '
2046 raise error.Abort(_('option "-n" not valid when importing multiple '
2047 'patches'))
2047 'patches'))
2048 imported = []
2048 imported = []
2049 if rev:
2049 if rev:
@@ -2052,21 +2052,21 b' class queue(object):'
2052 # Otherwise, they should form a linear path to a head.
2052 # Otherwise, they should form a linear path to a head.
2053 heads = repo.changelog.heads(repo.changelog.node(rev.first()))
2053 heads = repo.changelog.heads(repo.changelog.node(rev.first()))
2054 if len(heads) > 1:
2054 if len(heads) > 1:
2055 raise util.Abort(_('revision %d is the root of more than one '
2055 raise error.Abort(_('revision %d is the root of more than one '
2056 'branch') % rev.last())
2056 'branch') % rev.last())
2057 if self.applied:
2057 if self.applied:
2058 base = repo.changelog.node(rev.first())
2058 base = repo.changelog.node(rev.first())
2059 if base in [n.node for n in self.applied]:
2059 if base in [n.node for n in self.applied]:
2060 raise util.Abort(_('revision %d is already managed')
2060 raise error.Abort(_('revision %d is already managed')
2061 % rev.first())
2061 % rev.first())
2062 if heads != [self.applied[-1].node]:
2062 if heads != [self.applied[-1].node]:
2063 raise util.Abort(_('revision %d is not the parent of '
2063 raise error.Abort(_('revision %d is not the parent of '
2064 'the queue') % rev.first())
2064 'the queue') % rev.first())
2065 base = repo.changelog.rev(self.applied[0].node)
2065 base = repo.changelog.rev(self.applied[0].node)
2066 lastparent = repo.changelog.parentrevs(base)[0]
2066 lastparent = repo.changelog.parentrevs(base)[0]
2067 else:
2067 else:
2068 if heads != [repo.changelog.node(rev.first())]:
2068 if heads != [repo.changelog.node(rev.first())]:
2069 raise util.Abort(_('revision %d has unmanaged children')
2069 raise error.Abort(_('revision %d has unmanaged children')
2070 % rev.first())
2070 % rev.first())
2071 lastparent = None
2071 lastparent = None
2072
2072
@@ -2075,16 +2075,16 b' class queue(object):'
2075 try:
2075 try:
2076 for r in rev:
2076 for r in rev:
2077 if not repo[r].mutable():
2077 if not repo[r].mutable():
2078 raise util.Abort(_('revision %d is not mutable') % r,
2078 raise error.Abort(_('revision %d is not mutable') % r,
2079 hint=_('see "hg help phases" '
2079 hint=_('see "hg help phases" '
2080 'for details'))
2080 'for details'))
2081 p1, p2 = repo.changelog.parentrevs(r)
2081 p1, p2 = repo.changelog.parentrevs(r)
2082 n = repo.changelog.node(r)
2082 n = repo.changelog.node(r)
2083 if p2 != nullrev:
2083 if p2 != nullrev:
2084 raise util.Abort(_('cannot import merge revision %d')
2084 raise error.Abort(_('cannot import merge revision %d')
2085 % r)
2085 % r)
2086 if lastparent and lastparent != r:
2086 if lastparent and lastparent != r:
2087 raise util.Abort(_('revision %d is not the parent of '
2087 raise error.Abort(_('revision %d is not the parent of '
2088 '%d')
2088 '%d')
2089 % (r, lastparent))
2089 % (r, lastparent))
2090 lastparent = p1
2090 lastparent = p1
@@ -2118,13 +2118,14 b' class queue(object):'
2118 for i, filename in enumerate(files):
2118 for i, filename in enumerate(files):
2119 if existing:
2119 if existing:
2120 if filename == '-':
2120 if filename == '-':
2121 raise util.Abort(_('-e is incompatible with import from -'))
2121 raise error.Abort(_('-e is incompatible with import from -')
2122 )
2122 filename = normname(filename)
2123 filename = normname(filename)
2123 self.checkreservedname(filename)
2124 self.checkreservedname(filename)
2124 if util.url(filename).islocal():
2125 if util.url(filename).islocal():
2125 originpath = self.join(filename)
2126 originpath = self.join(filename)
2126 if not os.path.isfile(originpath):
2127 if not os.path.isfile(originpath):
2127 raise util.Abort(
2128 raise error.Abort(
2128 _("patch %s does not exist") % filename)
2129 _("patch %s does not exist") % filename)
2129
2130
2130 if patchname:
2131 if patchname:
@@ -2138,7 +2139,7 b' class queue(object):'
2138
2139
2139 else:
2140 else:
2140 if filename == '-' and not patchname:
2141 if filename == '-' and not patchname:
2141 raise util.Abort(_('need --name to import a patch from -'))
2142 raise error.Abort(_('need --name to import a patch from -'))
2142 elif not patchname:
2143 elif not patchname:
2143 patchname = normname(os.path.basename(filename.rstrip('/')))
2144 patchname = normname(os.path.basename(filename.rstrip('/')))
2144 self.checkpatchname(patchname, force)
2145 self.checkpatchname(patchname, force)
@@ -2150,7 +2151,7 b' class queue(object):'
2150 text = fp.read()
2151 text = fp.read()
2151 fp.close()
2152 fp.close()
2152 except (OSError, IOError):
2153 except (OSError, IOError):
2153 raise util.Abort(_("unable to read file %s") % filename)
2154 raise error.Abort(_("unable to read file %s") % filename)
2154 patchf = self.opener(patchname, "w")
2155 patchf = self.opener(patchname, "w")
2155 patchf.write(text)
2156 patchf.write(text)
2156 patchf.close()
2157 patchf.close()
@@ -2209,7 +2210,7 b' def applied(ui, repo, patch=None, **opts'
2209
2210
2210 if patch:
2211 if patch:
2211 if patch not in q.series:
2212 if patch not in q.series:
2212 raise util.Abort(_("patch %s is not in series file") % patch)
2213 raise error.Abort(_("patch %s is not in series file") % patch)
2213 end = q.series.index(patch) + 1
2214 end = q.series.index(patch) + 1
2214 else:
2215 else:
2215 end = q.seriesend(True)
2216 end = q.seriesend(True)
@@ -2241,7 +2242,7 b' def unapplied(ui, repo, patch=None, **op'
2241 q = repo.mq
2242 q = repo.mq
2242 if patch:
2243 if patch:
2243 if patch not in q.series:
2244 if patch not in q.series:
2244 raise util.Abort(_("patch %s is not in series file") % patch)
2245 raise error.Abort(_("patch %s is not in series file") % patch)
2245 start = q.series.index(patch) + 1
2246 start = q.series.index(patch) + 1
2246 else:
2247 else:
2247 start = q.seriesend(True)
2248 start = q.seriesend(True)
@@ -2408,7 +2409,7 b' def clone(ui, source, dest=None, **opts)'
2408 try:
2409 try:
2409 hg.peer(ui, opts, patchespath)
2410 hg.peer(ui, opts, patchespath)
2410 except error.RepoError:
2411 except error.RepoError:
2411 raise util.Abort(_('versioned patch repository not found'
2412 raise error.Abort(_('versioned patch repository not found'
2412 ' (see init --mq)'))
2413 ' (see init --mq)'))
2413 qbase, destrev = None, None
2414 qbase, destrev = None, None
2414 if sr.local():
2415 if sr.local():
@@ -2458,7 +2459,7 b' def commit(ui, repo, *pats, **opts):'
2458 q = repo.mq
2459 q = repo.mq
2459 r = q.qrepo()
2460 r = q.qrepo()
2460 if not r:
2461 if not r:
2461 raise util.Abort('no queue repository')
2462 raise error.Abort('no queue repository')
2462 commands.commit(r.ui, r, *pats, **opts)
2463 commands.commit(r.ui, r, *pats, **opts)
2463
2464
2464 @command("qseries",
2465 @command("qseries",
@@ -2663,9 +2664,9 b' def fold(ui, repo, *files, **opts):'
2663 Returns 0 on success."""
2664 Returns 0 on success."""
2664 q = repo.mq
2665 q = repo.mq
2665 if not files:
2666 if not files:
2666 raise util.Abort(_('qfold requires at least one patch name'))
2667 raise error.Abort(_('qfold requires at least one patch name'))
2667 if not q.checktoppatch(repo)[0]:
2668 if not q.checktoppatch(repo)[0]:
2668 raise util.Abort(_('no patches applied'))
2669 raise error.Abort(_('no patches applied'))
2669 q.checklocalchanges(repo)
2670 q.checklocalchanges(repo)
2670
2671
2671 message = cmdutil.logmessage(ui, opts)
2672 message = cmdutil.logmessage(ui, opts)
@@ -2678,7 +2679,7 b' def fold(ui, repo, *files, **opts):'
2678 if p in patches or p == parent:
2679 if p in patches or p == parent:
2679 ui.warn(_('skipping already folded patch %s\n') % p)
2680 ui.warn(_('skipping already folded patch %s\n') % p)
2680 if q.isapplied(p):
2681 if q.isapplied(p):
2681 raise util.Abort(_('qfold cannot fold already applied patch %s')
2682 raise error.Abort(_('qfold cannot fold already applied patch %s')
2682 % p)
2683 % p)
2683 patches.append(p)
2684 patches.append(p)
2684
2685
@@ -2690,7 +2691,7 b' def fold(ui, repo, *files, **opts):'
2690 pf = q.join(p)
2691 pf = q.join(p)
2691 (patchsuccess, files, fuzz) = q.patch(repo, pf)
2692 (patchsuccess, files, fuzz) = q.patch(repo, pf)
2692 if not patchsuccess:
2693 if not patchsuccess:
2693 raise util.Abort(_('error folding patch %s') % p)
2694 raise error.Abort(_('error folding patch %s') % p)
2694
2695
2695 if not message:
2696 if not message:
2696 ph = patchheader(q.join(parent), q.plainmode)
2697 ph = patchheader(q.join(parent), q.plainmode)
@@ -2789,23 +2790,23 b' def guard(ui, repo, *args, **opts):'
2789 args = list(args)
2790 args = list(args)
2790 if opts.get('list'):
2791 if opts.get('list'):
2791 if args or opts.get('none'):
2792 if args or opts.get('none'):
2792 raise util.Abort(_('cannot mix -l/--list with options or '
2793 raise error.Abort(_('cannot mix -l/--list with options or '
2793 'arguments'))
2794 'arguments'))
2794 for i in xrange(len(q.series)):
2795 for i in xrange(len(q.series)):
2795 status(i)
2796 status(i)
2796 return
2797 return
2797 if not args or args[0][0:1] in '-+':
2798 if not args or args[0][0:1] in '-+':
2798 if not q.applied:
2799 if not q.applied:
2799 raise util.Abort(_('no patches applied'))
2800 raise error.Abort(_('no patches applied'))
2800 patch = q.applied[-1].name
2801 patch = q.applied[-1].name
2801 if patch is None and args[0][0:1] not in '-+':
2802 if patch is None and args[0][0:1] not in '-+':
2802 patch = args.pop(0)
2803 patch = args.pop(0)
2803 if patch is None:
2804 if patch is None:
2804 raise util.Abort(_('no patch to work with'))
2805 raise error.Abort(_('no patch to work with'))
2805 if args or opts.get('none'):
2806 if args or opts.get('none'):
2806 idx = q.findseries(patch)
2807 idx = q.findseries(patch)
2807 if idx is None:
2808 if idx is None:
2808 raise util.Abort(_('no patch named %s') % patch)
2809 raise error.Abort(_('no patch named %s') % patch)
2809 q.setguards(idx, args)
2810 q.setguards(idx, args)
2810 q.savedirty()
2811 q.savedirty()
2811 else:
2812 else:
@@ -3031,10 +3032,10 b' def save(ui, repo, **opts):'
3031 newpath = os.path.join(q.basepath, opts.get('name'))
3032 newpath = os.path.join(q.basepath, opts.get('name'))
3032 if os.path.exists(newpath):
3033 if os.path.exists(newpath):
3033 if not os.path.isdir(newpath):
3034 if not os.path.isdir(newpath):
3034 raise util.Abort(_('destination %s exists and is not '
3035 raise error.Abort(_('destination %s exists and is not '
3035 'a directory') % newpath)
3036 'a directory') % newpath)
3036 if not opts.get('force'):
3037 if not opts.get('force'):
3037 raise util.Abort(_('destination %s exists, '
3038 raise error.Abort(_('destination %s exists, '
3038 'use -f to force') % newpath)
3039 'use -f to force') % newpath)
3039 else:
3040 else:
3040 newpath = savename(path)
3041 newpath = savename(path)
@@ -3178,7 +3179,7 b' def finish(ui, repo, *revrange, **opts):'
3178 Returns 0 on success.
3179 Returns 0 on success.
3179 """
3180 """
3180 if not opts.get('applied') and not revrange:
3181 if not opts.get('applied') and not revrange:
3181 raise util.Abort(_('no revisions specified'))
3182 raise error.Abort(_('no revisions specified'))
3182 elif opts.get('applied'):
3183 elif opts.get('applied'):
3183 revrange = ('qbase::qtip',) + revrange
3184 revrange = ('qbase::qtip',) + revrange
3184
3185
@@ -3267,7 +3268,7 b' def qqueue(ui, repo, name=None, **opts):'
3267
3268
3268 def _setactive(name):
3269 def _setactive(name):
3269 if q.applied:
3270 if q.applied:
3270 raise util.Abort(_('new queue created, but cannot make active '
3271 raise error.Abort(_('new queue created, but cannot make active '
3271 'as patches are applied'))
3272 'as patches are applied'))
3272 _setactivenocheck(name)
3273 _setactivenocheck(name)
3273
3274
@@ -3296,12 +3297,12 b' def qqueue(ui, repo, name=None, **opts):'
3296
3297
3297 def _delete(name):
3298 def _delete(name):
3298 if name not in existing:
3299 if name not in existing:
3299 raise util.Abort(_('cannot delete queue that does not exist'))
3300 raise error.Abort(_('cannot delete queue that does not exist'))
3300
3301
3301 current = _getcurrent()
3302 current = _getcurrent()
3302
3303
3303 if name == current:
3304 if name == current:
3304 raise util.Abort(_('cannot delete currently active queue'))
3305 raise error.Abort(_('cannot delete currently active queue'))
3305
3306
3306 fh = repo.vfs('patches.queues.new', 'w')
3307 fh = repo.vfs('patches.queues.new', 'w')
3307 for queue in existing:
3308 for queue in existing:
@@ -3325,14 +3326,14 b' def qqueue(ui, repo, name=None, **opts):'
3325 return
3326 return
3326
3327
3327 if not _validname(name):
3328 if not _validname(name):
3328 raise util.Abort(
3329 raise error.Abort(
3329 _('invalid queue name, may not contain the characters ":\\/."'))
3330 _('invalid queue name, may not contain the characters ":\\/."'))
3330
3331
3331 existing = _getqueues()
3332 existing = _getqueues()
3332
3333
3333 if opts.get('create'):
3334 if opts.get('create'):
3334 if name in existing:
3335 if name in existing:
3335 raise util.Abort(_('queue "%s" already exists') % name)
3336 raise error.Abort(_('queue "%s" already exists') % name)
3336 if _noqueues():
3337 if _noqueues():
3337 _addqueue(_defaultqueue)
3338 _addqueue(_defaultqueue)
3338 _addqueue(name)
3339 _addqueue(name)
@@ -3340,15 +3341,16 b' def qqueue(ui, repo, name=None, **opts):'
3340 elif opts.get('rename'):
3341 elif opts.get('rename'):
3341 current = _getcurrent()
3342 current = _getcurrent()
3342 if name == current:
3343 if name == current:
3343 raise util.Abort(_('can\'t rename "%s" to its current name') % name)
3344 raise error.Abort(_('can\'t rename "%s" to its current name')
3345 % name)
3344 if name in existing:
3346 if name in existing:
3345 raise util.Abort(_('queue "%s" already exists') % name)
3347 raise error.Abort(_('queue "%s" already exists') % name)
3346
3348
3347 olddir = _queuedir(current)
3349 olddir = _queuedir(current)
3348 newdir = _queuedir(name)
3350 newdir = _queuedir(name)
3349
3351
3350 if os.path.exists(newdir):
3352 if os.path.exists(newdir):
3351 raise util.Abort(_('non-queue directory "%s" already exists') %
3353 raise error.Abort(_('non-queue directory "%s" already exists') %
3352 newdir)
3354 newdir)
3353
3355
3354 fh = repo.vfs('patches.queues.new', 'w')
3356 fh = repo.vfs('patches.queues.new', 'w')
@@ -3372,7 +3374,7 b' def qqueue(ui, repo, name=None, **opts):'
3372 shutil.rmtree(qdir)
3374 shutil.rmtree(qdir)
3373 else:
3375 else:
3374 if name not in existing:
3376 if name not in existing:
3375 raise util.Abort(_('use --create to create a new queue'))
3377 raise error.Abort(_('use --create to create a new queue'))
3376 _setactive(name)
3378 _setactive(name)
3377
3379
3378 def mqphasedefaults(repo, roots):
3380 def mqphasedefaults(repo, roots):
@@ -3403,7 +3405,7 b' def reposetup(ui, repo):'
3403 parents = self.dirstate.parents()
3405 parents = self.dirstate.parents()
3404 patches = [s.node for s in self.mq.applied]
3406 patches = [s.node for s in self.mq.applied]
3405 if parents[0] in patches or parents[1] in patches:
3407 if parents[0] in patches or parents[1] in patches:
3406 raise util.Abort(errmsg)
3408 raise error.Abort(errmsg)
3407
3409
3408 def commit(self, text="", user=None, date=None, match=None,
3410 def commit(self, text="", user=None, date=None, match=None,
3409 force=False, editor=False, extra={}):
3411 force=False, editor=False, extra={}):
@@ -3430,7 +3432,7 b' def reposetup(ui, repo):'
3430 # looking for pushed and shared changeset
3432 # looking for pushed and shared changeset
3431 for node in outapplied:
3433 for node in outapplied:
3432 if self[node].phase() < phases.secret:
3434 if self[node].phase() < phases.secret:
3433 raise util.Abort(_('source has mq patches applied'))
3435 raise error.Abort(_('source has mq patches applied'))
3434 # no non-secret patches pushed
3436 # no non-secret patches pushed
3435 super(mqrepo, self).checkpush(pushop)
3437 super(mqrepo, self).checkpush(pushop)
3436
3438
@@ -3492,12 +3494,12 b' def mqinit(orig, ui, *args, **kwargs):'
3492 if args:
3494 if args:
3493 repopath = args[0]
3495 repopath = args[0]
3494 if not hg.islocal(repopath):
3496 if not hg.islocal(repopath):
3495 raise util.Abort(_('only a local queue repository '
3497 raise error.Abort(_('only a local queue repository '
3496 'may be initialized'))
3498 'may be initialized'))
3497 else:
3499 else:
3498 repopath = cmdutil.findrepo(os.getcwd())
3500 repopath = cmdutil.findrepo(os.getcwd())
3499 if not repopath:
3501 if not repopath:
3500 raise util.Abort(_('there is no Mercurial repository here '
3502 raise error.Abort(_('there is no Mercurial repository here '
3501 '(.hg not found)'))
3503 '(.hg not found)'))
3502 repo = hg.repository(ui, repopath)
3504 repo = hg.repository(ui, repopath)
3503 return qinit(ui, repo, True)
3505 return qinit(ui, repo, True)
@@ -3514,7 +3516,7 b' def mqcommand(orig, ui, repo, *args, **k'
3514 q = repo.mq
3516 q = repo.mq
3515 r = q.qrepo()
3517 r = q.qrepo()
3516 if not r:
3518 if not r:
3517 raise util.Abort(_('no queue repository'))
3519 raise error.Abort(_('no queue repository'))
3518 return orig(r.ui, r, *args, **kwargs)
3520 return orig(r.ui, r, *args, **kwargs)
3519
3521
3520 def summaryhook(ui, repo):
3522 def summaryhook(ui, repo):
@@ -135,7 +135,7 b' web.baseurl'
135
135
136 import email, socket, time
136 import email, socket, time
137 from mercurial.i18n import _
137 from mercurial.i18n import _
138 from mercurial import patch, cmdutil, util, mail
138 from mercurial import patch, cmdutil, util, mail, error
139 import fnmatch
139 import fnmatch
140
140
141 # Note for extension authors: ONLY specify testedwith = 'internal' for
141 # Note for extension authors: ONLY specify testedwith = 'internal' for
@@ -277,7 +277,7 b' class notifier(object):'
277 try:
277 try:
278 msg = p.parsestr(data)
278 msg = p.parsestr(data)
279 except email.Errors.MessageParseError as inst:
279 except email.Errors.MessageParseError as inst:
280 raise util.Abort(inst)
280 raise error.Abort(inst)
281
281
282 # store sender and subject
282 # store sender and subject
283 sender, subject = msg['From'], msg['Subject']
283 sender, subject = msg['From'], msg['Subject']
@@ -60,7 +60,7 b' You can set patchbomb to always ask for '
60 import os, errno, socket, tempfile, cStringIO
60 import os, errno, socket, tempfile, cStringIO
61 import email
61 import email
62
62
63 from mercurial import cmdutil, commands, hg, mail, patch, util
63 from mercurial import cmdutil, commands, hg, mail, patch, util, error
64 from mercurial import scmutil
64 from mercurial import scmutil
65 from mercurial.i18n import _
65 from mercurial.i18n import _
66 from mercurial.node import bin
66 from mercurial.node import bin
@@ -501,15 +501,15 b' def patchbomb(ui, repo, *revs, **opts):'
501 mail.validateconfig(ui)
501 mail.validateconfig(ui)
502
502
503 if not (revs or rev or outgoing or bundle or patches):
503 if not (revs or rev or outgoing or bundle or patches):
504 raise util.Abort(_('specify at least one changeset with -r or -o'))
504 raise error.Abort(_('specify at least one changeset with -r or -o'))
505
505
506 if outgoing and bundle:
506 if outgoing and bundle:
507 raise util.Abort(_("--outgoing mode always on with --bundle;"
507 raise error.Abort(_("--outgoing mode always on with --bundle;"
508 " do not re-specify --outgoing"))
508 " do not re-specify --outgoing"))
509
509
510 if outgoing or bundle:
510 if outgoing or bundle:
511 if len(revs) > 1:
511 if len(revs) > 1:
512 raise util.Abort(_("too many destinations"))
512 raise error.Abort(_("too many destinations"))
513 if revs:
513 if revs:
514 dest = revs[0]
514 dest = revs[0]
515 else:
515 else:
@@ -518,7 +518,7 b' def patchbomb(ui, repo, *revs, **opts):'
518
518
519 if rev:
519 if rev:
520 if revs:
520 if revs:
521 raise util.Abort(_('use only one form to specify the revision'))
521 raise error.Abort(_('use only one form to specify the revision'))
522 revs = rev
522 revs = rev
523
523
524 revs = scmutil.revrange(repo, revs)
524 revs = scmutil.revrange(repo, revs)
@@ -578,7 +578,7 b' def patchbomb(ui, repo, *revs, **opts):'
578 to = getaddrs('To', ask=True)
578 to = getaddrs('To', ask=True)
579 if not to:
579 if not to:
580 # we can get here in non-interactive mode
580 # we can get here in non-interactive mode
581 raise util.Abort(_('no recipient addresses provided'))
581 raise error.Abort(_('no recipient addresses provided'))
582 cc = getaddrs('Cc', ask=True, default='') or []
582 cc = getaddrs('Cc', ask=True, default='') or []
583 bcc = getaddrs('Bcc') or []
583 bcc = getaddrs('Bcc') or []
584 replyto = getaddrs('Reply-To')
584 replyto = getaddrs('Reply-To')
@@ -598,7 +598,7 b' def patchbomb(ui, repo, *revs, **opts):'
598 ui.write('\n')
598 ui.write('\n')
599 if ui.promptchoice(_('are you sure you want to send (yn)?'
599 if ui.promptchoice(_('are you sure you want to send (yn)?'
600 '$$ &Yes $$ &No')):
600 '$$ &Yes $$ &No')):
601 raise util.Abort(_('patchbomb canceled'))
601 raise error.Abort(_('patchbomb canceled'))
602
602
603 ui.write('\n')
603 ui.write('\n')
604
604
@@ -24,7 +24,7 b''
24
24
25 '''command to delete untracked files from the working directory'''
25 '''command to delete untracked files from the working directory'''
26
26
27 from mercurial import util, commands, cmdutil, scmutil
27 from mercurial import util, commands, cmdutil, scmutil, error
28 from mercurial.i18n import _
28 from mercurial.i18n import _
29 import os
29 import os
30
30
@@ -94,7 +94,7 b' def purge(ui, repo, *dirs, **opts):'
94 except OSError:
94 except OSError:
95 m = _('%s cannot be removed') % name
95 m = _('%s cannot be removed') % name
96 if opts['abort_on_err']:
96 if opts['abort_on_err']:
97 raise util.Abort(m)
97 raise error.Abort(m)
98 ui.warn(_('warning: %s\n') % m)
98 ui.warn(_('warning: %s\n') % m)
99 else:
99 else:
100 ui.write('%s%s' % (name, eol))
100 ui.write('%s%s' % (name, eol))
@@ -225,20 +225,20 b' def rebase(ui, repo, **opts):'
225 help = "hg%s help -e histedit" % enablehistedit
225 help = "hg%s help -e histedit" % enablehistedit
226 msg = _("interactive history editing is supported by the "
226 msg = _("interactive history editing is supported by the "
227 "'histedit' extension (see \"%s\")") % help
227 "'histedit' extension (see \"%s\")") % help
228 raise util.Abort(msg)
228 raise error.Abort(msg)
229
229
230 if collapsemsg and not collapsef:
230 if collapsemsg and not collapsef:
231 raise util.Abort(
231 raise error.Abort(
232 _('message can only be specified with collapse'))
232 _('message can only be specified with collapse'))
233
233
234 if contf or abortf:
234 if contf or abortf:
235 if contf and abortf:
235 if contf and abortf:
236 raise util.Abort(_('cannot use both abort and continue'))
236 raise error.Abort(_('cannot use both abort and continue'))
237 if collapsef:
237 if collapsef:
238 raise util.Abort(
238 raise error.Abort(
239 _('cannot use collapse with continue or abort'))
239 _('cannot use collapse with continue or abort'))
240 if srcf or basef or destf:
240 if srcf or basef or destf:
241 raise util.Abort(
241 raise error.Abort(
242 _('abort and continue do not allow specifying revisions'))
242 _('abort and continue do not allow specifying revisions'))
243 if abortf and opts.get('tool', False):
243 if abortf and opts.get('tool', False):
244 ui.warn(_('tool option will be ignored\n'))
244 ui.warn(_('tool option will be ignored\n'))
@@ -255,19 +255,19 b' def rebase(ui, repo, **opts):'
255 else:
255 else:
256 msg = _('cannot continue inconsistent rebase')
256 msg = _('cannot continue inconsistent rebase')
257 hint = _('use "hg rebase --abort" to clear broken state')
257 hint = _('use "hg rebase --abort" to clear broken state')
258 raise util.Abort(msg, hint=hint)
258 raise error.Abort(msg, hint=hint)
259 if abortf:
259 if abortf:
260 return abort(repo, originalwd, target, state,
260 return abort(repo, originalwd, target, state,
261 activebookmark=activebookmark)
261 activebookmark=activebookmark)
262 else:
262 else:
263 if srcf and basef:
263 if srcf and basef:
264 raise util.Abort(_('cannot specify both a '
264 raise error.Abort(_('cannot specify both a '
265 'source and a base'))
265 'source and a base'))
266 if revf and basef:
266 if revf and basef:
267 raise util.Abort(_('cannot specify both a '
267 raise error.Abort(_('cannot specify both a '
268 'revision and a base'))
268 'revision and a base'))
269 if revf and srcf:
269 if revf and srcf:
270 raise util.Abort(_('cannot specify both a '
270 raise error.Abort(_('cannot specify both a '
271 'revision and a source'))
271 'revision and a source'))
272
272
273 cmdutil.checkunfinished(repo)
273 cmdutil.checkunfinished(repo)
@@ -335,7 +335,7 b' def rebase(ui, repo, **opts):'
335 if (not (keepf or allowunstable)
335 if (not (keepf or allowunstable)
336 and repo.revs('first(children(%ld) - %ld)',
336 and repo.revs('first(children(%ld) - %ld)',
337 rebaseset, rebaseset)):
337 rebaseset, rebaseset)):
338 raise util.Abort(
338 raise error.Abort(
339 _("can't remove original changesets with"
339 _("can't remove original changesets with"
340 " unrebased descendants"),
340 " unrebased descendants"),
341 hint=_('use --keep to keep original changesets'))
341 hint=_('use --keep to keep original changesets'))
@@ -361,7 +361,7 b' def rebase(ui, repo, **opts):'
361
361
362 root = min(rebaseset)
362 root = min(rebaseset)
363 if not keepf and not repo[root].mutable():
363 if not keepf and not repo[root].mutable():
364 raise util.Abort(_("can't rebase public changeset %s")
364 raise error.Abort(_("can't rebase public changeset %s")
365 % repo[root],
365 % repo[root],
366 hint=_('see "hg help phases" for details'))
366 hint=_('see "hg help phases" for details'))
367
367
@@ -384,7 +384,7 b' def rebase(ui, repo, **opts):'
384 for rev in state:
384 for rev in state:
385 branches.add(repo[rev].branch())
385 branches.add(repo[rev].branch())
386 if len(branches) > 1:
386 if len(branches) > 1:
387 raise util.Abort(_('cannot collapse multiple named '
387 raise error.Abort(_('cannot collapse multiple named '
388 'branches'))
388 'branches'))
389
389
390 # Rebase
390 # Rebase
@@ -564,7 +564,7 b' def externalparent(repo, state, targetan'
564 return nullrev
564 return nullrev
565 if len(parents) == 1:
565 if len(parents) == 1:
566 return parents.pop()
566 return parents.pop()
567 raise util.Abort(_('unable to collapse on top of %s, there is more '
567 raise error.Abort(_('unable to collapse on top of %s, there is more '
568 'than one external parent: %s') %
568 'than one external parent: %s') %
569 (max(targetancestors),
569 (max(targetancestors),
570 ', '.join(str(p) for p in sorted(parents))))
570 ', '.join(str(p) for p in sorted(parents))))
@@ -677,7 +677,7 b' def defineparents(repo, rev, target, sta'
677 p2 = state[p2n]
677 p2 = state[p2n]
678 else: # p2n external
678 else: # p2n external
679 if p2 != nullrev: # p1n external too => rev is a merged revision
679 if p2 != nullrev: # p1n external too => rev is a merged revision
680 raise util.Abort(_('cannot use revision %d as base, result '
680 raise error.Abort(_('cannot use revision %d as base, result '
681 'would have 3 parents') % rev)
681 'would have 3 parents') % rev)
682 p2 = p2n
682 p2 = p2n
683 repo.ui.debug(" future parents are %d and %d\n" %
683 repo.ui.debug(" future parents are %d and %d\n" %
@@ -866,7 +866,7 b' def restorestatus(repo):'
866 state[repo[oldrev].rev()] = repo[newrev].rev()
866 state[repo[oldrev].rev()] = repo[newrev].rev()
867
867
868 if keepbranches is None:
868 if keepbranches is None:
869 raise util.Abort(_('.hg/rebasestate is incomplete'))
869 raise error.Abort(_('.hg/rebasestate is incomplete'))
870
870
871 skipped = set()
871 skipped = set()
872 # recompute the set of skipped revs
872 # recompute the set of skipped revs
@@ -885,7 +885,7 b' def restorestatus(repo):'
885 except IOError as err:
885 except IOError as err:
886 if err.errno != errno.ENOENT:
886 if err.errno != errno.ENOENT:
887 raise
887 raise
888 raise util.Abort(_('no rebase in progress'))
888 raise error.Abort(_('no rebase in progress'))
889
889
890 def needupdate(repo, state):
890 def needupdate(repo, state):
891 '''check whether we should `update --clean` away from a merge, or if
891 '''check whether we should `update --clean` away from a merge, or if
@@ -959,18 +959,18 b' def buildstate(repo, dest, rebaseset, co'
959 # a partially completed rebase is blocked by mq.
959 # a partially completed rebase is blocked by mq.
960 if 'qtip' in repo.tags() and (dest.node() in
960 if 'qtip' in repo.tags() and (dest.node() in
961 [s.node for s in repo.mq.applied]):
961 [s.node for s in repo.mq.applied]):
962 raise util.Abort(_('cannot rebase onto an applied mq patch'))
962 raise error.Abort(_('cannot rebase onto an applied mq patch'))
963
963
964 roots = list(repo.set('roots(%ld)', rebaseset))
964 roots = list(repo.set('roots(%ld)', rebaseset))
965 if not roots:
965 if not roots:
966 raise util.Abort(_('no matching revisions'))
966 raise error.Abort(_('no matching revisions'))
967 roots.sort()
967 roots.sort()
968 state = {}
968 state = {}
969 detachset = set()
969 detachset = set()
970 for root in roots:
970 for root in roots:
971 commonbase = root.ancestor(dest)
971 commonbase = root.ancestor(dest)
972 if commonbase == root:
972 if commonbase == root:
973 raise util.Abort(_('source is ancestor of destination'))
973 raise error.Abort(_('source is ancestor of destination'))
974 if commonbase == dest:
974 if commonbase == dest:
975 samebranch = root.branch() == dest.branch()
975 samebranch = root.branch() == dest.branch()
976 if not collapse and samebranch and root in dest.children():
976 if not collapse and samebranch and root in dest.children():
@@ -1114,7 +1114,7 b' def pullrebase(orig, ui, repo, *args, **'
1114 release(lock, wlock)
1114 release(lock, wlock)
1115 else:
1115 else:
1116 if opts.get('tool'):
1116 if opts.get('tool'):
1117 raise util.Abort(_('--tool can only be used with --rebase'))
1117 raise error.Abort(_('--tool can only be used with --rebase'))
1118 orig(ui, repo, *args, **opts)
1118 orig(ui, repo, *args, **opts)
1119
1119
1120 def _setrebasesetvisibility(repo, revs):
1120 def _setrebasesetvisibility(repo, revs):
@@ -9,7 +9,7 b''
9
9
10 from mercurial.i18n import _
10 from mercurial.i18n import _
11 from mercurial import cmdutil, commands, extensions
11 from mercurial import cmdutil, commands, extensions
12 from mercurial import util
12 from mercurial import error
13
13
14 cmdtable = {}
14 cmdtable = {}
15 command = cmdutil.command(cmdtable)
15 command = cmdutil.command(cmdtable)
@@ -54,7 +54,7 b' def record(ui, repo, *pats, **opts):'
54 This command is not available when committing a merge.'''
54 This command is not available when committing a merge.'''
55
55
56 if not ui.interactive():
56 if not ui.interactive():
57 raise util.Abort(_('running non-interactively, use %s instead') %
57 raise error.Abort(_('running non-interactively, use %s instead') %
58 'commit')
58 'commit')
59
59
60 opts["interactive"] = True
60 opts["interactive"] = True
@@ -99,7 +99,7 b' def _qrecord(cmdsuggest, ui, repo, patch'
99 try:
99 try:
100 mq = extensions.find('mq')
100 mq = extensions.find('mq')
101 except KeyError:
101 except KeyError:
102 raise util.Abort(_("'mq' extension not loaded"))
102 raise error.Abort(_("'mq' extension not loaded"))
103
103
104 repo.mq.checkpatchname(patch)
104 repo.mq.checkpatchname(patch)
105
105
@@ -7,7 +7,7 b''
7
7
8 """recreates hardlinks between repository clones"""
8 """recreates hardlinks between repository clones"""
9
9
10 from mercurial import cmdutil, hg, util
10 from mercurial import cmdutil, hg, util, error
11 from mercurial.i18n import _
11 from mercurial.i18n import _
12 import os, stat
12 import os, stat
13
13
@@ -47,7 +47,7 b' def relink(ui, repo, origin=None, **opts'
47 """
47 """
48 if (not util.safehasattr(util, 'samefile') or
48 if (not util.safehasattr(util, 'samefile') or
49 not util.safehasattr(util, 'samedevice')):
49 not util.safehasattr(util, 'samedevice')):
50 raise util.Abort(_('hardlinks are not supported on this system'))
50 raise error.Abort(_('hardlinks are not supported on this system'))
51 src = hg.repository(repo.baseui, ui.expandpath(origin or 'default-relink',
51 src = hg.repository(repo.baseui, ui.expandpath(origin or 'default-relink',
52 origin or 'default'))
52 origin or 'default'))
53 ui.status(_('relinking %s to %s\n') % (src.store.path, repo.store.path))
53 ui.status(_('relinking %s to %s\n') % (src.store.path, repo.store.path))
@@ -57,7 +57,7 b' def relink(ui, repo, origin=None, **opts'
57
57
58 if not util.samedevice(src.store.path, repo.store.path):
58 if not util.samedevice(src.store.path, repo.store.path):
59 # No point in continuing
59 # No point in continuing
60 raise util.Abort(_('source and destination are on different devices'))
60 raise error.Abort(_('source and destination are on different devices'))
61
61
62 locallock = repo.lock()
62 locallock = repo.lock()
63 try:
63 try:
@@ -114,7 +114,7 b' def prune(candidates, src, dst, ui):'
114 return False
114 return False
115 if not util.samedevice(src, dst):
115 if not util.samedevice(src, dst):
116 # No point in continuing
116 # No point in continuing
117 raise util.Abort(
117 raise error.Abort(
118 _('source and destination are on different devices'))
118 _('source and destination are on different devices'))
119 if st.st_size != ts.st_size:
119 if st.st_size != ts.st_size:
120 return False
120 return False
@@ -41,7 +41,7 b' same name.'
41 """
41 """
42
42
43 import os, re
43 import os, re
44 from mercurial import extensions, hg, templater, util
44 from mercurial import extensions, hg, templater, util, error
45 from mercurial.i18n import _
45 from mercurial.i18n import _
46
46
47 # Note for extension authors: ONLY specify testedwith = 'internal' for
47 # Note for extension authors: ONLY specify testedwith = 'internal' for
@@ -69,7 +69,7 b' class ShortRepository(object):'
69 try:
69 try:
70 url = url.split('://', 1)[1]
70 url = url.split('://', 1)[1]
71 except IndexError:
71 except IndexError:
72 raise util.Abort(_("no '://' in scheme url '%s'") % url)
72 raise error.Abort(_("no '://' in scheme url '%s'") % url)
73 parts = url.split('/', self.parts)
73 parts = url.split('/', self.parts)
74 if len(parts) > self.parts:
74 if len(parts) > self.parts:
75 tail = parts[-1]
75 tail = parts[-1]
@@ -101,7 +101,7 b' def extsetup(ui):'
101 for scheme, url in schemes.items():
101 for scheme, url in schemes.items():
102 if (os.name == 'nt' and len(scheme) == 1 and scheme.isalpha()
102 if (os.name == 'nt' and len(scheme) == 1 and scheme.isalpha()
103 and os.path.exists('%s:\\' % scheme)):
103 and os.path.exists('%s:\\' % scheme)):
104 raise util.Abort(_('custom scheme %s:// conflicts with drive '
104 raise error.Abort(_('custom scheme %s:// conflicts with drive '
105 'letter %s:\\\n') % (scheme, scheme.upper()))
105 'letter %s:\\\n') % (scheme, scheme.upper()))
106 hg.schemes[scheme] = ShortRepository(url, scheme, t)
106 hg.schemes[scheme] = ShortRepository(url, scheme, t)
107
107
@@ -38,7 +38,7 b' The following ``share.`` config options '
38 '''
38 '''
39
39
40 from mercurial.i18n import _
40 from mercurial.i18n import _
41 from mercurial import cmdutil, commands, hg, util, extensions, bookmarks
41 from mercurial import cmdutil, commands, hg, util, extensions, bookmarks, error
42 from mercurial.hg import repository, parseurl
42 from mercurial.hg import repository, parseurl
43 import errno
43 import errno
44
44
@@ -83,7 +83,7 b' def unshare(ui, repo):'
83 """
83 """
84
84
85 if not repo.shared():
85 if not repo.shared():
86 raise util.Abort(_("this is not a shared repo"))
86 raise error.Abort(_("this is not a shared repo"))
87
87
88 destlock = lock = None
88 destlock = lock = None
89 lock = repo.lock()
89 lock = repo.lock()
@@ -90,7 +90,7 b' class shelvedfile(object):'
90 except IOError as err:
90 except IOError as err:
91 if err.errno != errno.ENOENT:
91 if err.errno != errno.ENOENT:
92 raise
92 raise
93 raise util.Abort(_("shelved change '%s' not found") % self.name)
93 raise error.Abort(_("shelved change '%s' not found") % self.name)
94
94
95 def applybundle(self):
95 def applybundle(self):
96 fp = self.opener()
96 fp = self.opener()
@@ -135,7 +135,7 b' class shelvedstate(object):'
135 version = int(fp.readline().strip())
135 version = int(fp.readline().strip())
136
136
137 if version != cls._version:
137 if version != cls._version:
138 raise util.Abort(_('this version of shelve is incompatible '
138 raise error.Abort(_('this version of shelve is incompatible '
139 'with the version used in this repo'))
139 'with the version used in this repo'))
140 name = fp.readline().strip()
140 name = fp.readline().strip()
141 wctx = fp.readline().strip()
141 wctx = fp.readline().strip()
@@ -239,7 +239,7 b' def createcmd(ui, repo, pats, opts):'
239 wctx = repo[None]
239 wctx = repo[None]
240 parents = wctx.parents()
240 parents = wctx.parents()
241 if len(parents) > 1:
241 if len(parents) > 1:
242 raise util.Abort(_('cannot shelve while merging'))
242 raise error.Abort(_('cannot shelve while merging'))
243 parent = parents[0]
243 parent = parents[0]
244
244
245 # we never need the user, so we use a generic user for all shelve operations
245 # we never need the user, so we use a generic user for all shelve operations
@@ -290,22 +290,22 b' def createcmd(ui, repo, pats, opts):'
290
290
291 if name:
291 if name:
292 if shelvedfile(repo, name, 'hg').exists():
292 if shelvedfile(repo, name, 'hg').exists():
293 raise util.Abort(_("a shelved change named '%s' already exists")
293 raise error.Abort(_("a shelved change named '%s' already exists"
294 % name)
294 ) % name)
295 else:
295 else:
296 for n in gennames():
296 for n in gennames():
297 if not shelvedfile(repo, n, 'hg').exists():
297 if not shelvedfile(repo, n, 'hg').exists():
298 name = n
298 name = n
299 break
299 break
300 else:
300 else:
301 raise util.Abort(_("too many shelved changes named '%s'") %
301 raise error.Abort(_("too many shelved changes named '%s'") %
302 label)
302 label)
303
303
304 # ensure we are not creating a subdirectory or a hidden file
304 # ensure we are not creating a subdirectory or a hidden file
305 if '/' in name or '\\' in name:
305 if '/' in name or '\\' in name:
306 raise util.Abort(_('shelved change names may not contain slashes'))
306 raise error.Abort(_('shelved change names may not contain slashes'))
307 if name.startswith('.'):
307 if name.startswith('.'):
308 raise util.Abort(_("shelved change names may not start with '.'"))
308 raise error.Abort(_("shelved change names may not start with '.'"))
309 interactive = opts.get('interactive', False)
309 interactive = opts.get('interactive', False)
310
310
311 def interactivecommitfunc(ui, repo, *pats, **opts):
311 def interactivecommitfunc(ui, repo, *pats, **opts):
@@ -359,7 +359,7 b' def cleanupcmd(ui, repo):'
359 def deletecmd(ui, repo, pats):
359 def deletecmd(ui, repo, pats):
360 """subcommand that deletes a specific shelve"""
360 """subcommand that deletes a specific shelve"""
361 if not pats:
361 if not pats:
362 raise util.Abort(_('no shelved changes specified!'))
362 raise error.Abort(_('no shelved changes specified!'))
363 wlock = repo.wlock()
363 wlock = repo.wlock()
364 try:
364 try:
365 for name in pats:
365 for name in pats:
@@ -369,7 +369,7 b' def deletecmd(ui, repo, pats):'
369 except OSError as err:
369 except OSError as err:
370 if err.errno != errno.ENOENT:
370 if err.errno != errno.ENOENT:
371 raise
371 raise
372 raise util.Abort(_("shelved change '%s' not found") % name)
372 raise error.Abort(_("shelved change '%s' not found") % name)
373 finally:
373 finally:
374 lockmod.release(wlock)
374 lockmod.release(wlock)
375
375
@@ -441,18 +441,18 b' def listcmd(ui, repo, pats, opts):'
441 def singlepatchcmds(ui, repo, pats, opts, subcommand):
441 def singlepatchcmds(ui, repo, pats, opts, subcommand):
442 """subcommand that displays a single shelf"""
442 """subcommand that displays a single shelf"""
443 if len(pats) != 1:
443 if len(pats) != 1:
444 raise util.Abort(_("--%s expects a single shelf") % subcommand)
444 raise error.Abort(_("--%s expects a single shelf") % subcommand)
445 shelfname = pats[0]
445 shelfname = pats[0]
446
446
447 if not shelvedfile(repo, shelfname, 'patch').exists():
447 if not shelvedfile(repo, shelfname, 'patch').exists():
448 raise util.Abort(_("cannot find shelf %s") % shelfname)
448 raise error.Abort(_("cannot find shelf %s") % shelfname)
449
449
450 listcmd(ui, repo, pats, opts)
450 listcmd(ui, repo, pats, opts)
451
451
452 def checkparents(repo, state):
452 def checkparents(repo, state):
453 """check parent while resuming an unshelve"""
453 """check parent while resuming an unshelve"""
454 if state.parents != repo.dirstate.parents():
454 if state.parents != repo.dirstate.parents():
455 raise util.Abort(_('working directory parents do not match unshelve '
455 raise error.Abort(_('working directory parents do not match unshelve '
456 'state'))
456 'state'))
457
457
458 def pathtofiles(repo, files):
458 def pathtofiles(repo, files):
@@ -527,7 +527,7 b' def unshelvecontinue(ui, repo, state, op'
527 checkparents(repo, state)
527 checkparents(repo, state)
528 ms = merge.mergestate(repo)
528 ms = merge.mergestate(repo)
529 if [f for f in ms if ms[f] == 'u']:
529 if [f for f in ms if ms[f] == 'u']:
530 raise util.Abort(
530 raise error.Abort(
531 _("unresolved conflicts, can't continue"),
531 _("unresolved conflicts, can't continue"),
532 hint=_("see 'hg resolve', then 'hg unshelve --continue'"))
532 hint=_("see 'hg resolve', then 'hg unshelve --continue'"))
533
533
@@ -610,9 +610,9 b' def unshelve(ui, repo, *shelved, **opts)'
610
610
611 if abortf or continuef:
611 if abortf or continuef:
612 if abortf and continuef:
612 if abortf and continuef:
613 raise util.Abort(_('cannot use both abort and continue'))
613 raise error.Abort(_('cannot use both abort and continue'))
614 if shelved:
614 if shelved:
615 raise util.Abort(_('cannot combine abort/continue with '
615 raise error.Abort(_('cannot combine abort/continue with '
616 'naming a shelved change'))
616 'naming a shelved change'))
617
617
618 try:
618 try:
@@ -620,25 +620,25 b' def unshelve(ui, repo, *shelved, **opts)'
620 except IOError as err:
620 except IOError as err:
621 if err.errno != errno.ENOENT:
621 if err.errno != errno.ENOENT:
622 raise
622 raise
623 raise util.Abort(_('no unshelve operation underway'))
623 raise error.Abort(_('no unshelve operation underway'))
624
624
625 if abortf:
625 if abortf:
626 return unshelveabort(ui, repo, state, opts)
626 return unshelveabort(ui, repo, state, opts)
627 elif continuef:
627 elif continuef:
628 return unshelvecontinue(ui, repo, state, opts)
628 return unshelvecontinue(ui, repo, state, opts)
629 elif len(shelved) > 1:
629 elif len(shelved) > 1:
630 raise util.Abort(_('can only unshelve one change at a time'))
630 raise error.Abort(_('can only unshelve one change at a time'))
631 elif not shelved:
631 elif not shelved:
632 shelved = listshelves(repo)
632 shelved = listshelves(repo)
633 if not shelved:
633 if not shelved:
634 raise util.Abort(_('no shelved changes to apply!'))
634 raise error.Abort(_('no shelved changes to apply!'))
635 basename = util.split(shelved[0][1])[1]
635 basename = util.split(shelved[0][1])[1]
636 ui.status(_("unshelving change '%s'\n") % basename)
636 ui.status(_("unshelving change '%s'\n") % basename)
637 else:
637 else:
638 basename = shelved[0]
638 basename = shelved[0]
639
639
640 if not shelvedfile(repo, basename, 'patch').exists():
640 if not shelvedfile(repo, basename, 'patch').exists():
641 raise util.Abort(_("shelved change '%s' not found") % basename)
641 raise error.Abort(_("shelved change '%s' not found") % basename)
642
642
643 oldquiet = ui.quiet
643 oldquiet = ui.quiet
644 wlock = lock = tr = None
644 wlock = lock = tr = None
@@ -808,12 +808,12 b' def shelvecmd(ui, repo, *pats, **opts):'
808 if opts[opt]:
808 if opts[opt]:
809 for i, allowable in allowables:
809 for i, allowable in allowables:
810 if opts[i] and opt not in allowable:
810 if opts[i] and opt not in allowable:
811 raise util.Abort(_("options '--%s' and '--%s' may not be "
811 raise error.Abort(_("options '--%s' and '--%s' may not be "
812 "used together") % (opt, i))
812 "used together") % (opt, i))
813 return True
813 return True
814 if checkopt('cleanup'):
814 if checkopt('cleanup'):
815 if pats:
815 if pats:
816 raise util.Abort(_("cannot specify names when using '--cleanup'"))
816 raise error.Abort(_("cannot specify names when using '--cleanup'"))
817 return cleanupcmd(ui, repo)
817 return cleanupcmd(ui, repo)
818 elif checkopt('delete'):
818 elif checkopt('delete'):
819 return deletecmd(ui, repo, pats)
819 return deletecmd(ui, repo, pats)
@@ -6,7 +6,7 b' repository. See the command help for det'
6 from mercurial.i18n import _
6 from mercurial.i18n import _
7 from mercurial.node import nullid
7 from mercurial.node import nullid
8 from mercurial.lock import release
8 from mercurial.lock import release
9 from mercurial import cmdutil, hg, scmutil, util
9 from mercurial import cmdutil, hg, scmutil, util, error
10 from mercurial import repair, bookmarks, merge
10 from mercurial import repair, bookmarks, merge
11
11
12 cmdtable = {}
12 cmdtable = {}
@@ -38,10 +38,10 b' def checklocalchanges(repo, force=False,'
38 if not force:
38 if not force:
39 if s.modified or s.added or s.removed or s.deleted:
39 if s.modified or s.added or s.removed or s.deleted:
40 _("local changes found") # i18n tool detection
40 _("local changes found") # i18n tool detection
41 raise util.Abort(_("local changes found" + excsuffix))
41 raise error.Abort(_("local changes found" + excsuffix))
42 if checksubstate(repo):
42 if checksubstate(repo):
43 _("local changed subrepos found") # i18n tool detection
43 _("local changed subrepos found") # i18n tool detection
44 raise util.Abort(_("local changed subrepos found" + excsuffix))
44 raise error.Abort(_("local changed subrepos found" + excsuffix))
45 return s
45 return s
46
46
47 def strip(ui, repo, revs, update=True, backup=True, force=None, bookmark=None):
47 def strip(ui, repo, revs, update=True, backup=True, force=None, bookmark=None):
@@ -131,7 +131,7 b' def stripcmd(ui, repo, *revs, **opts):'
131 mark = opts.get('bookmark')
131 mark = opts.get('bookmark')
132 marks = repo._bookmarks
132 marks = repo._bookmarks
133 if mark not in marks:
133 if mark not in marks:
134 raise util.Abort(_("bookmark '%s' not found") % mark)
134 raise error.Abort(_("bookmark '%s' not found") % mark)
135
135
136 # If the requested bookmark is not the only one pointing to a
136 # If the requested bookmark is not the only one pointing to a
137 # a revision we have to only delete the bookmark and not strip
137 # a revision we have to only delete the bookmark and not strip
@@ -153,7 +153,7 b' def stripcmd(ui, repo, *revs, **opts):'
153 ui.write(_("bookmark '%s' deleted\n") % mark)
153 ui.write(_("bookmark '%s' deleted\n") % mark)
154
154
155 if not revs:
155 if not revs:
156 raise util.Abort(_('empty revision set'))
156 raise error.Abort(_('empty revision set'))
157
157
158 descendants = set(cl.descendants(revs))
158 descendants = set(cl.descendants(revs))
159 strippedrevs = revs.union(descendants)
159 strippedrevs = revs.union(descendants)
@@ -174,7 +174,7 b' class transplanter(object):'
174 else:
174 else:
175 parent = source.lookup(opts['parent'])
175 parent = source.lookup(opts['parent'])
176 if parent not in parents:
176 if parent not in parents:
177 raise util.Abort(_('%s is not a parent of %s') %
177 raise error.Abort(_('%s is not a parent of %s') %
178 (short(parent), short(node)))
178 (short(parent), short(node)))
179 else:
179 else:
180 parent = parents[0]
180 parent = parents[0]
@@ -245,7 +245,7 b' class transplanter(object):'
245 environ={'HGUSER': changelog[1],
245 environ={'HGUSER': changelog[1],
246 'HGREVISION': revlog.hex(node),
246 'HGREVISION': revlog.hex(node),
247 },
247 },
248 onerr=util.Abort, errprefix=_('filter failed'))
248 onerr=error.Abort, errprefix=_('filter failed'))
249 user, date, msg = self.parselog(file(headerfile))[1:4]
249 user, date, msg = self.parselog(file(headerfile))[1:4]
250 finally:
250 finally:
251 os.unlink(headerfile)
251 os.unlink(headerfile)
@@ -269,7 +269,7 b' class transplanter(object):'
269 self.ui.note('%s %s\n%s\n' % (user, date, message))
269 self.ui.note('%s %s\n%s\n' % (user, date, message))
270
270
271 if not patchfile and not merge:
271 if not patchfile and not merge:
272 raise util.Abort(_('can only omit patchfile if merging'))
272 raise error.Abort(_('can only omit patchfile if merging'))
273 if patchfile:
273 if patchfile:
274 try:
274 try:
275 files = set()
275 files = set()
@@ -332,14 +332,14 b' class transplanter(object):'
332 merge = False
332 merge = False
333
333
334 if not user or not date or not message or not parents[0]:
334 if not user or not date or not message or not parents[0]:
335 raise util.Abort(_('transplant log file is corrupt'))
335 raise error.Abort(_('transplant log file is corrupt'))
336
336
337 parent = parents[0]
337 parent = parents[0]
338 if len(parents) > 1:
338 if len(parents) > 1:
339 if opts.get('parent'):
339 if opts.get('parent'):
340 parent = source.lookup(opts['parent'])
340 parent = source.lookup(opts['parent'])
341 if parent not in parents:
341 if parent not in parents:
342 raise util.Abort(_('%s is not a parent of %s') %
342 raise error.Abort(_('%s is not a parent of %s') %
343 (short(parent), short(node)))
343 (short(parent), short(node)))
344 else:
344 else:
345 merge = True
345 merge = True
@@ -349,7 +349,7 b' class transplanter(object):'
349 try:
349 try:
350 p1, p2 = repo.dirstate.parents()
350 p1, p2 = repo.dirstate.parents()
351 if p1 != parent:
351 if p1 != parent:
352 raise util.Abort(_('working directory not at transplant '
352 raise error.Abort(_('working directory not at transplant '
353 'parent %s') % revlog.hex(parent))
353 'parent %s') % revlog.hex(parent))
354 if merge:
354 if merge:
355 repo.setparents(p1, parents[1])
355 repo.setparents(p1, parents[1])
@@ -358,7 +358,7 b' class transplanter(object):'
358 n = repo.commit(message, user, date, extra=extra,
358 n = repo.commit(message, user, date, extra=extra,
359 editor=self.getcommiteditor())
359 editor=self.getcommiteditor())
360 if not n:
360 if not n:
361 raise util.Abort(_('commit failed'))
361 raise error.Abort(_('commit failed'))
362 if not merge:
362 if not merge:
363 self.transplants.set(n, node)
363 self.transplants.set(n, node)
364 else:
364 else:
@@ -418,7 +418,7 b' class transplanter(object):'
418 inmsg = True
418 inmsg = True
419 message.append(line)
419 message.append(line)
420 if None in (user, date):
420 if None in (user, date):
421 raise util.Abort(_("filter corrupted changeset (no user or date)"))
421 raise error.Abort(_("filter corrupted changeset (no user or date)"))
422 return (node, user, date, '\n'.join(message), parents)
422 return (node, user, date, '\n'.join(message), parents)
423
423
424 def log(self, user, date, message, p1, p2, merge=False):
424 def log(self, user, date, message, p1, p2, merge=False):
@@ -594,18 +594,18 b' def transplant(ui, repo, *revs, **opts):'
594 def checkopts(opts, revs):
594 def checkopts(opts, revs):
595 if opts.get('continue'):
595 if opts.get('continue'):
596 if opts.get('branch') or opts.get('all') or opts.get('merge'):
596 if opts.get('branch') or opts.get('all') or opts.get('merge'):
597 raise util.Abort(_('--continue is incompatible with '
597 raise error.Abort(_('--continue is incompatible with '
598 '--branch, --all and --merge'))
598 '--branch, --all and --merge'))
599 return
599 return
600 if not (opts.get('source') or revs or
600 if not (opts.get('source') or revs or
601 opts.get('merge') or opts.get('branch')):
601 opts.get('merge') or opts.get('branch')):
602 raise util.Abort(_('no source URL, branch revision or revision '
602 raise error.Abort(_('no source URL, branch revision or revision '
603 'list provided'))
603 'list provided'))
604 if opts.get('all'):
604 if opts.get('all'):
605 if not opts.get('branch'):
605 if not opts.get('branch'):
606 raise util.Abort(_('--all requires a branch revision'))
606 raise error.Abort(_('--all requires a branch revision'))
607 if revs:
607 if revs:
608 raise util.Abort(_('--all is incompatible with a '
608 raise error.Abort(_('--all is incompatible with a '
609 'revision list'))
609 'revision list'))
610
610
611 checkopts(opts, revs)
611 checkopts(opts, revs)
@@ -622,13 +622,13 b' def transplant(ui, repo, *revs, **opts):'
622 cmdutil.checkunfinished(repo)
622 cmdutil.checkunfinished(repo)
623 p1, p2 = repo.dirstate.parents()
623 p1, p2 = repo.dirstate.parents()
624 if len(repo) > 0 and p1 == revlog.nullid:
624 if len(repo) > 0 and p1 == revlog.nullid:
625 raise util.Abort(_('no revision checked out'))
625 raise error.Abort(_('no revision checked out'))
626 if not opts.get('continue'):
626 if not opts.get('continue'):
627 if p2 != revlog.nullid:
627 if p2 != revlog.nullid:
628 raise util.Abort(_('outstanding uncommitted merges'))
628 raise error.Abort(_('outstanding uncommitted merges'))
629 m, a, r, d = repo.status()[:4]
629 m, a, r, d = repo.status()[:4]
630 if m or a or r or d:
630 if m or a or r or d:
631 raise util.Abort(_('outstanding local changes'))
631 raise error.Abort(_('outstanding local changes'))
632
632
633 sourcerepo = opts.get('source')
633 sourcerepo = opts.get('source')
634 if sourcerepo:
634 if sourcerepo:
@@ -47,7 +47,7 b' It is useful for the users who want to c'
47
47
48 import os, sys
48 import os, sys
49 from mercurial.i18n import _
49 from mercurial.i18n import _
50 from mercurial import util, encoding
50 from mercurial import error, encoding
51 # Note for extension authors: ONLY specify testedwith = 'internal' for
51 # Note for extension authors: ONLY specify testedwith = 'internal' for
52 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
52 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
53 # be specifying the version(s) of Mercurial they are tested with, or
53 # be specifying the version(s) of Mercurial they are tested with, or
@@ -105,7 +105,7 b' def basewrapper(func, argtype, enc, dec,'
105 # return value.
105 # return value.
106 return enc(func(*dec(args), **dec(kwds)))
106 return enc(func(*dec(args), **dec(kwds)))
107 except UnicodeError:
107 except UnicodeError:
108 raise util.Abort(_("[win32mbcs] filename conversion failed with"
108 raise error.Abort(_("[win32mbcs] filename conversion failed with"
109 " %s encoding\n") % (_encoding))
109 " %s encoding\n") % (_encoding))
110
110
111 def wrapper(func, args, kwds):
111 def wrapper(func, args, kwds):
@@ -55,7 +55,7 b' def tidyprefix(dest, kind, prefix):'
55 if prefix.startswith('./'):
55 if prefix.startswith('./'):
56 prefix = prefix[2:]
56 prefix = prefix[2:]
57 if prefix.startswith('../') or os.path.isabs(lpfx) or '/../' in prefix:
57 if prefix.startswith('../') or os.path.isabs(lpfx) or '/../' in prefix:
58 raise util.Abort(_('archive prefix contains illegal components'))
58 raise error.Abort(_('archive prefix contains illegal components'))
59 return prefix
59 return prefix
60
60
61 exts = {
61 exts = {
@@ -292,7 +292,7 b' def archive(repo, dest, node, kind, deco'
292
292
293 if kind == 'files':
293 if kind == 'files':
294 if prefix:
294 if prefix:
295 raise util.Abort(_('cannot give prefix when archiving to files'))
295 raise error.Abort(_('cannot give prefix when archiving to files'))
296 else:
296 else:
297 prefix = tidyprefix(dest, kind, prefix)
297 prefix = tidyprefix(dest, kind, prefix)
298
298
@@ -303,7 +303,7 b' def archive(repo, dest, node, kind, deco'
303 archiver.addfile(prefix + name, mode, islink, data)
303 archiver.addfile(prefix + name, mode, islink, data)
304
304
305 if kind not in archivers:
305 if kind not in archivers:
306 raise util.Abort(_("unknown archive type '%s'") % kind)
306 raise error.Abort(_("unknown archive type '%s'") % kind)
307
307
308 ctx = repo[node]
308 ctx = repo[node]
309 archiver = archivers[kind](dest, mtime or ctx.date()[0])
309 archiver = archivers[kind](dest, mtime or ctx.date()[0])
@@ -19,8 +19,8 b' from .node import ('
19 )
19 )
20 from . import (
20 from . import (
21 encoding,
21 encoding,
22 error,
22 scmutil,
23 scmutil,
23 util,
24 )
24 )
25
25
26 array = array.array
26 array = array.array
@@ -250,7 +250,7 b' class branchcache(dict):'
250 repo.ui.log('branchcache',
250 repo.ui.log('branchcache',
251 'wrote %s branch cache with %d labels and %d nodes\n',
251 'wrote %s branch cache with %d labels and %d nodes\n',
252 repo.filtername, len(self), nodecount)
252 repo.filtername, len(self), nodecount)
253 except (IOError, OSError, util.Abort) as inst:
253 except (IOError, OSError, error.Abort) as inst:
254 repo.ui.debug("couldn't write branch cache: %s\n" % inst)
254 repo.ui.debug("couldn't write branch cache: %s\n" % inst)
255 # Abort may be raise by read only opener
255 # Abort may be raise by read only opener
256 pass
256 pass
@@ -465,7 +465,7 b' class revbranchcache(object):'
465 for b in self._names[self._rbcnamescount:]))
465 for b in self._names[self._rbcnamescount:]))
466 self._rbcsnameslen = f.tell()
466 self._rbcsnameslen = f.tell()
467 f.close()
467 f.close()
468 except (IOError, OSError, util.Abort) as inst:
468 except (IOError, OSError, error.Abort) as inst:
469 repo.ui.debug("couldn't write revision branch cache names: "
469 repo.ui.debug("couldn't write revision branch cache names: "
470 "%s\n" % inst)
470 "%s\n" % inst)
471 return
471 return
@@ -483,7 +483,7 b' class revbranchcache(object):'
483 end = revs * _rbcrecsize
483 end = revs * _rbcrecsize
484 f.write(self._rbcrevs[start:end])
484 f.write(self._rbcrevs[start:end])
485 f.close()
485 f.close()
486 except (IOError, OSError, util.Abort) as inst:
486 except (IOError, OSError, error.Abort) as inst:
487 repo.ui.debug("couldn't write revision branch cache: %s\n" %
487 repo.ui.debug("couldn't write revision branch cache: %s\n" %
488 inst)
488 inst)
489 return
489 return
@@ -627,10 +627,10 b' def getunbundler(ui, fp, magicstring=Non'
627 magicstring = changegroup.readexactly(fp, 4)
627 magicstring = changegroup.readexactly(fp, 4)
628 magic, version = magicstring[0:2], magicstring[2:4]
628 magic, version = magicstring[0:2], magicstring[2:4]
629 if magic != 'HG':
629 if magic != 'HG':
630 raise util.Abort(_('not a Mercurial bundle'))
630 raise error.Abort(_('not a Mercurial bundle'))
631 unbundlerclass = formatmap.get(version)
631 unbundlerclass = formatmap.get(version)
632 if unbundlerclass is None:
632 if unbundlerclass is None:
633 raise util.Abort(_('unknown bundle version %s') % version)
633 raise error.Abort(_('unknown bundle version %s') % version)
634 unbundler = unbundlerclass(ui, fp)
634 unbundler = unbundlerclass(ui, fp)
635 indebug(ui, 'start processing of %s stream' % magicstring)
635 indebug(ui, 'start processing of %s stream' % magicstring)
636 return unbundler
636 return unbundler
@@ -1206,7 +1206,7 b' class unbundlepart(unpackermixin):'
1206 self._payloadstream = util.chunkbuffer(self._payloadchunks(chunk))
1206 self._payloadstream = util.chunkbuffer(self._payloadchunks(chunk))
1207 adjust = self.read(internaloffset)
1207 adjust = self.read(internaloffset)
1208 if len(adjust) != internaloffset:
1208 if len(adjust) != internaloffset:
1209 raise util.Abort(_('Seek failed\n'))
1209 raise error.Abort(_('Seek failed\n'))
1210 self._pos = newpos
1210 self._pos = newpos
1211
1211
1212 # These are only the static capabilities.
1212 # These are only the static capabilities.
@@ -1304,19 +1304,19 b' def handleremotechangegroup(op, inpart):'
1304 try:
1304 try:
1305 raw_url = inpart.params['url']
1305 raw_url = inpart.params['url']
1306 except KeyError:
1306 except KeyError:
1307 raise util.Abort(_('remote-changegroup: missing "%s" param') % 'url')
1307 raise error.Abort(_('remote-changegroup: missing "%s" param') % 'url')
1308 parsed_url = util.url(raw_url)
1308 parsed_url = util.url(raw_url)
1309 if parsed_url.scheme not in capabilities['remote-changegroup']:
1309 if parsed_url.scheme not in capabilities['remote-changegroup']:
1310 raise util.Abort(_('remote-changegroup does not support %s urls') %
1310 raise error.Abort(_('remote-changegroup does not support %s urls') %
1311 parsed_url.scheme)
1311 parsed_url.scheme)
1312
1312
1313 try:
1313 try:
1314 size = int(inpart.params['size'])
1314 size = int(inpart.params['size'])
1315 except ValueError:
1315 except ValueError:
1316 raise util.Abort(_('remote-changegroup: invalid value for param "%s"')
1316 raise error.Abort(_('remote-changegroup: invalid value for param "%s"')
1317 % 'size')
1317 % 'size')
1318 except KeyError:
1318 except KeyError:
1319 raise util.Abort(_('remote-changegroup: missing "%s" param') % 'size')
1319 raise error.Abort(_('remote-changegroup: missing "%s" param') % 'size')
1320
1320
1321 digests = {}
1321 digests = {}
1322 for typ in inpart.params.get('digests', '').split():
1322 for typ in inpart.params.get('digests', '').split():
@@ -1324,7 +1324,7 b' def handleremotechangegroup(op, inpart):'
1324 try:
1324 try:
1325 value = inpart.params[param]
1325 value = inpart.params[param]
1326 except KeyError:
1326 except KeyError:
1327 raise util.Abort(_('remote-changegroup: missing "%s" param') %
1327 raise error.Abort(_('remote-changegroup: missing "%s" param') %
1328 param)
1328 param)
1329 digests[typ] = value
1329 digests[typ] = value
1330
1330
@@ -1339,7 +1339,7 b' def handleremotechangegroup(op, inpart):'
1339 from . import exchange
1339 from . import exchange
1340 cg = exchange.readbundle(op.repo.ui, real_part, raw_url)
1340 cg = exchange.readbundle(op.repo.ui, real_part, raw_url)
1341 if not isinstance(cg, changegroup.cg1unpacker):
1341 if not isinstance(cg, changegroup.cg1unpacker):
1342 raise util.Abort(_('%s: not a bundle version 1.0') %
1342 raise error.Abort(_('%s: not a bundle version 1.0') %
1343 util.hidepassword(raw_url))
1343 util.hidepassword(raw_url))
1344 ret = changegroup.addchangegroup(op.repo, cg, 'bundle2', 'bundle2')
1344 ret = changegroup.addchangegroup(op.repo, cg, 'bundle2', 'bundle2')
1345 op.records.add('changegroup', {'return': ret})
1345 op.records.add('changegroup', {'return': ret})
@@ -1351,8 +1351,8 b' def handleremotechangegroup(op, inpart):'
1351 part.addparam('return', '%i' % ret, mandatory=False)
1351 part.addparam('return', '%i' % ret, mandatory=False)
1352 try:
1352 try:
1353 real_part.validate()
1353 real_part.validate()
1354 except util.Abort as e:
1354 except error.Abort as e:
1355 raise util.Abort(_('bundle at %s is corrupted:\n%s') %
1355 raise error.Abort(_('bundle at %s is corrupted:\n%s') %
1356 (util.hidepassword(raw_url), str(e)))
1356 (util.hidepassword(raw_url), str(e)))
1357 assert not inpart.read()
1357 assert not inpart.read()
1358
1358
@@ -1399,7 +1399,7 b' def handlereplycaps(op, inpart):'
1399 @parthandler('error:abort', ('message', 'hint'))
1399 @parthandler('error:abort', ('message', 'hint'))
1400 def handleerrorabort(op, inpart):
1400 def handleerrorabort(op, inpart):
1401 """Used to transmit abort error over the wire"""
1401 """Used to transmit abort error over the wire"""
1402 raise util.Abort(inpart.params['message'], hint=inpart.params.get('hint'))
1402 raise error.Abort(inpart.params['message'], hint=inpart.params.get('hint'))
1403
1403
1404 @parthandler('error:pushkey', ('namespace', 'key', 'new', 'old', 'ret',
1404 @parthandler('error:pushkey', ('namespace', 'key', 'new', 'old', 'ret',
1405 'in-reply-to'))
1405 'in-reply-to'))
@@ -282,7 +282,7 b' class bundlerepository(localrepo.localre'
282 in changegroup.packermap)]
282 in changegroup.packermap)]
283
283
284 if not cgparts:
284 if not cgparts:
285 raise util.Abort('No changegroups found')
285 raise error.Abort('No changegroups found')
286 version = cgparts[0].params.get('version', '01')
286 version = cgparts[0].params.get('version', '01')
287 cgparts = [p for p in cgparts
287 cgparts = [p for p in cgparts
288 if p.params.get('version', '01') == version]
288 if p.params.get('version', '01') == version]
@@ -374,7 +374,7 b' class bundlerepository(localrepo.localre'
374
374
375 def instance(ui, path, create):
375 def instance(ui, path, create):
376 if create:
376 if create:
377 raise util.Abort(_('cannot create new bundle repository'))
377 raise error.Abort(_('cannot create new bundle repository'))
378 # internal config: bundle.mainreporoot
378 # internal config: bundle.mainreporoot
379 parentpath = ui.config("bundle", "mainreporoot", "")
379 parentpath = ui.config("bundle", "mainreporoot", "")
380 if not parentpath:
380 if not parentpath:
@@ -37,7 +37,7 b' def readexactly(stream, n):'
37 '''read n bytes from stream.read and abort if less was available'''
37 '''read n bytes from stream.read and abort if less was available'''
38 s = stream.read(n)
38 s = stream.read(n)
39 if len(s) < n:
39 if len(s) < n:
40 raise util.Abort(_("stream ended unexpectedly"
40 raise error.Abort(_("stream ended unexpectedly"
41 " (got %d bytes, expected %d)")
41 " (got %d bytes, expected %d)")
42 % (len(s), n))
42 % (len(s), n))
43 return s
43 return s
@@ -48,7 +48,7 b' def getchunk(stream):'
48 l = struct.unpack(">l", d)[0]
48 l = struct.unpack(">l", d)[0]
49 if l <= 4:
49 if l <= 4:
50 if l:
50 if l:
51 raise util.Abort(_("invalid chunk length %d") % l)
51 raise error.Abort(_("invalid chunk length %d") % l)
52 return ""
52 return ""
53 return readexactly(stream, l - 4)
53 return readexactly(stream, l - 4)
54
54
@@ -144,12 +144,12 b' def writebundle(ui, cg, filename, bundle'
144 # compression argument is only for the bundle2 case
144 # compression argument is only for the bundle2 case
145 assert compression is None
145 assert compression is None
146 if cg.version != '01':
146 if cg.version != '01':
147 raise util.Abort(_('old bundle types only supports v1 '
147 raise error.Abort(_('old bundle types only supports v1 '
148 'changegroups'))
148 'changegroups'))
149 header, comp = bundletypes[bundletype]
149 header, comp = bundletypes[bundletype]
150 if comp not in util.compressors:
150 if comp not in util.compressors:
151 raise util.Abort(_('unknown stream compression type: %s')
151 raise error.Abort(_('unknown stream compression type: %s')
152 % comp)
152 % comp)
153 z = util.compressors[comp]()
153 z = util.compressors[comp]()
154 subchunkiter = cg.getchunks()
154 subchunkiter = cg.getchunks()
155 def chunkiter():
155 def chunkiter():
@@ -175,7 +175,7 b' class cg1unpacker(object):'
175 if alg == 'UN':
175 if alg == 'UN':
176 alg = None # get more modern without breaking too much
176 alg = None # get more modern without breaking too much
177 if not alg in util.decompressors:
177 if not alg in util.decompressors:
178 raise util.Abort(_('unknown stream compression type: %s')
178 raise error.Abort(_('unknown stream compression type: %s')
179 % alg)
179 % alg)
180 if alg == 'BZ':
180 if alg == 'BZ':
181 alg = '_truncatedBZ'
181 alg = '_truncatedBZ'
@@ -198,7 +198,7 b' class cg1unpacker(object):'
198 l = struct.unpack(">l", d)[0]
198 l = struct.unpack(">l", d)[0]
199 if l <= 4:
199 if l <= 4:
200 if l:
200 if l:
201 raise util.Abort(_("invalid chunk length %d") % l)
201 raise error.Abort(_("invalid chunk length %d") % l)
202 return 0
202 return 0
203 if self.callback:
203 if self.callback:
204 self.callback()
204 self.callback()
@@ -477,7 +477,7 b' class cg1packer(object):'
477 for i, fname in enumerate(sorted(changedfiles)):
477 for i, fname in enumerate(sorted(changedfiles)):
478 filerevlog = repo.file(fname)
478 filerevlog = repo.file(fname)
479 if not filerevlog:
479 if not filerevlog:
480 raise util.Abort(_("empty or missing revlog for %s") % fname)
480 raise error.Abort(_("empty or missing revlog for %s") % fname)
481
481
482 linkrevnodes = linknodes(filerevlog, fname)
482 linkrevnodes = linknodes(filerevlog, fname)
483 # Lookup for filenodes, we collected the linkrev nodes above in the
483 # Lookup for filenodes, we collected the linkrev nodes above in the
@@ -688,9 +688,9 b' def addchangegroupfiles(repo, source, re'
688 o = len(fl)
688 o = len(fl)
689 try:
689 try:
690 if not fl.addgroup(source, revmap, trp):
690 if not fl.addgroup(source, revmap, trp):
691 raise util.Abort(_("received file revlog group is empty"))
691 raise error.Abort(_("received file revlog group is empty"))
692 except error.CensoredBaseError as e:
692 except error.CensoredBaseError as e:
693 raise util.Abort(_("received delta base is censored: %s") % e)
693 raise error.Abort(_("received delta base is censored: %s") % e)
694 revisions += len(fl) - o
694 revisions += len(fl) - o
695 files += 1
695 files += 1
696 if f in needfiles:
696 if f in needfiles:
@@ -700,7 +700,7 b' def addchangegroupfiles(repo, source, re'
700 if n in needs:
700 if n in needs:
701 needs.remove(n)
701 needs.remove(n)
702 else:
702 else:
703 raise util.Abort(
703 raise error.Abort(
704 _("received spurious file revlog entry"))
704 _("received spurious file revlog entry"))
705 if not needs:
705 if not needs:
706 del needfiles[f]
706 del needfiles[f]
@@ -712,7 +712,7 b' def addchangegroupfiles(repo, source, re'
712 try:
712 try:
713 fl.rev(n)
713 fl.rev(n)
714 except error.LookupError:
714 except error.LookupError:
715 raise util.Abort(
715 raise error.Abort(
716 _('missing file data for %s:%s - run hg verify') %
716 _('missing file data for %s:%s - run hg verify') %
717 (f, hex(n)))
717 (f, hex(n)))
718
718
@@ -784,7 +784,7 b' def addchangegroup(repo, source, srctype'
784 efiles = len(efiles)
784 efiles = len(efiles)
785
785
786 if not (srccontent or emptyok):
786 if not (srccontent or emptyok):
787 raise util.Abort(_("received changelog group is empty"))
787 raise error.Abort(_("received changelog group is empty"))
788 clend = len(cl)
788 clend = len(cl)
789 changesets = clend - clstart
789 changesets = clend - clstart
790 repo.ui.progress(_('changesets'), None)
790 repo.ui.progress(_('changesets'), None)
@@ -85,7 +85,7 b' def dorecord(ui, repo, commitfunc, cmdsu'
85 msg = _('running non-interactively, use %s instead') % cmdsuggest
85 msg = _('running non-interactively, use %s instead') % cmdsuggest
86 else:
86 else:
87 msg = _('running non-interactively')
87 msg = _('running non-interactively')
88 raise util.Abort(msg)
88 raise error.Abort(msg)
89
89
90 # make sure username is set before going interactive
90 # make sure username is set before going interactive
91 if not opts.get('user'):
91 if not opts.get('user'):
@@ -109,7 +109,7 b' def dorecord(ui, repo, commitfunc, cmdsu'
109 checkunfinished(repo, commit=True)
109 checkunfinished(repo, commit=True)
110 merge = len(repo[None].parents()) > 1
110 merge = len(repo[None].parents()) > 1
111 if merge:
111 if merge:
112 raise util.Abort(_('cannot partially commit a merge '
112 raise error.Abort(_('cannot partially commit a merge '
113 '(use "hg commit" instead)'))
113 '(use "hg commit" instead)'))
114
114
115 status = repo.status(match=match)
115 status = repo.status(match=match)
@@ -123,7 +123,7 b' def dorecord(ui, repo, commitfunc, cmdsu'
123 try:
123 try:
124 chunks = filterfn(ui, originalchunks)
124 chunks = filterfn(ui, originalchunks)
125 except patch.PatchError as err:
125 except patch.PatchError as err:
126 raise util.Abort(_('error parsing patch: %s') % err)
126 raise error.Abort(_('error parsing patch: %s') % err)
127
127
128 # We need to keep a backup of files that have been newly added and
128 # We need to keep a backup of files that have been newly added and
129 # modified during the recording process because there is a previous
129 # modified during the recording process because there is a previous
@@ -193,7 +193,7 b' def dorecord(ui, repo, commitfunc, cmdsu'
193 ui.debug(fp.getvalue())
193 ui.debug(fp.getvalue())
194 patch.internalpatch(ui, repo, fp, 1, eolmode=None)
194 patch.internalpatch(ui, repo, fp, 1, eolmode=None)
195 except patch.PatchError as err:
195 except patch.PatchError as err:
196 raise util.Abort(str(err))
196 raise error.Abort(str(err))
197 del fp
197 del fp
198
198
199 # 4. We prepared working directory according to filtered
199 # 4. We prepared working directory according to filtered
@@ -305,10 +305,10 b' def findrepo(p):'
305
305
306 def bailifchanged(repo, merge=True):
306 def bailifchanged(repo, merge=True):
307 if merge and repo.dirstate.p2() != nullid:
307 if merge and repo.dirstate.p2() != nullid:
308 raise util.Abort(_('outstanding uncommitted merge'))
308 raise error.Abort(_('outstanding uncommitted merge'))
309 modified, added, removed, deleted = repo.status()[:4]
309 modified, added, removed, deleted = repo.status()[:4]
310 if modified or added or removed or deleted:
310 if modified or added or removed or deleted:
311 raise util.Abort(_('uncommitted changes'))
311 raise error.Abort(_('uncommitted changes'))
312 ctx = repo[None]
312 ctx = repo[None]
313 for s in sorted(ctx.substate):
313 for s in sorted(ctx.substate):
314 ctx.sub(s).bailifchanged()
314 ctx.sub(s).bailifchanged()
@@ -319,7 +319,7 b' def logmessage(ui, opts):'
319 logfile = opts.get('logfile')
319 logfile = opts.get('logfile')
320
320
321 if message and logfile:
321 if message and logfile:
322 raise util.Abort(_('options --message and --logfile are mutually '
322 raise error.Abort(_('options --message and --logfile are mutually '
323 'exclusive'))
323 'exclusive'))
324 if not message and logfile:
324 if not message and logfile:
325 try:
325 try:
@@ -328,7 +328,7 b' def logmessage(ui, opts):'
328 else:
328 else:
329 message = '\n'.join(util.readfile(logfile).splitlines())
329 message = '\n'.join(util.readfile(logfile).splitlines())
330 except IOError as inst:
330 except IOError as inst:
331 raise util.Abort(_("can't read commit message '%s': %s") %
331 raise error.Abort(_("can't read commit message '%s': %s") %
332 (logfile, inst.strerror))
332 (logfile, inst.strerror))
333 return message
333 return message
334
334
@@ -387,9 +387,9 b' def loglimit(opts):'
387 try:
387 try:
388 limit = int(limit)
388 limit = int(limit)
389 except ValueError:
389 except ValueError:
390 raise util.Abort(_('limit must be a positive integer'))
390 raise error.Abort(_('limit must be a positive integer'))
391 if limit <= 0:
391 if limit <= 0:
392 raise util.Abort(_('limit must be positive'))
392 raise error.Abort(_('limit must be positive'))
393 else:
393 else:
394 limit = None
394 limit = None
395 return limit
395 return limit
@@ -437,7 +437,7 b' def makefilename(repo, pat, node, desc=N'
437 i += 1
437 i += 1
438 return ''.join(newname)
438 return ''.join(newname)
439 except KeyError as inst:
439 except KeyError as inst:
440 raise util.Abort(_("invalid format spec '%%%s' in output filename") %
440 raise error.Abort(_("invalid format spec '%%%s' in output filename") %
441 inst.args[0])
441 inst.args[0])
442
442
443 def makefileobj(repo, pat, node=None, desc=None, total=None,
443 def makefileobj(repo, pat, node=None, desc=None, total=None,
@@ -495,7 +495,7 b' def openrevlog(repo, cmd, file_, opts):'
495 msg = _('cannot specify --changelog or --manifest or --dir '
495 msg = _('cannot specify --changelog or --manifest or --dir '
496 'without a repository')
496 'without a repository')
497 if msg:
497 if msg:
498 raise util.Abort(msg)
498 raise error.Abort(msg)
499
499
500 r = None
500 r = None
501 if repo:
501 if repo:
@@ -503,7 +503,7 b' def openrevlog(repo, cmd, file_, opts):'
503 r = repo.unfiltered().changelog
503 r = repo.unfiltered().changelog
504 elif dir:
504 elif dir:
505 if 'treemanifest' not in repo.requirements:
505 if 'treemanifest' not in repo.requirements:
506 raise util.Abort(_("--dir can only be used on repos with "
506 raise error.Abort(_("--dir can only be used on repos with "
507 "treemanifest enabled"))
507 "treemanifest enabled"))
508 dirlog = repo.dirlog(file_)
508 dirlog = repo.dirlog(file_)
509 if len(dirlog):
509 if len(dirlog):
@@ -518,7 +518,7 b' def openrevlog(repo, cmd, file_, opts):'
518 if not file_:
518 if not file_:
519 raise error.CommandError(cmd, _('invalid arguments'))
519 raise error.CommandError(cmd, _('invalid arguments'))
520 if not os.path.isfile(file_):
520 if not os.path.isfile(file_):
521 raise util.Abort(_("revlog '%s' not found") % file_)
521 raise error.Abort(_("revlog '%s' not found") % file_)
522 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False),
522 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False),
523 file_[:-2] + ".i")
523 file_[:-2] + ".i")
524 return r
524 return r
@@ -716,17 +716,17 b' def copy(ui, repo, pats, opts, rename=Fa'
716
716
717 pats = scmutil.expandpats(pats)
717 pats = scmutil.expandpats(pats)
718 if not pats:
718 if not pats:
719 raise util.Abort(_('no source or destination specified'))
719 raise error.Abort(_('no source or destination specified'))
720 if len(pats) == 1:
720 if len(pats) == 1:
721 raise util.Abort(_('no destination specified'))
721 raise error.Abort(_('no destination specified'))
722 dest = pats.pop()
722 dest = pats.pop()
723 destdirexists = os.path.isdir(dest) and not os.path.islink(dest)
723 destdirexists = os.path.isdir(dest) and not os.path.islink(dest)
724 if not destdirexists:
724 if not destdirexists:
725 if len(pats) > 1 or matchmod.patkind(pats[0]):
725 if len(pats) > 1 or matchmod.patkind(pats[0]):
726 raise util.Abort(_('with multiple sources, destination must be an '
726 raise error.Abort(_('with multiple sources, destination must be an '
727 'existing directory'))
727 'existing directory'))
728 if util.endswithsep(dest):
728 if util.endswithsep(dest):
729 raise util.Abort(_('destination %s is not a directory') % dest)
729 raise error.Abort(_('destination %s is not a directory') % dest)
730
730
731 tfn = targetpathfn
731 tfn = targetpathfn
732 if after:
732 if after:
@@ -738,7 +738,7 b' def copy(ui, repo, pats, opts, rename=Fa'
738 continue
738 continue
739 copylist.append((tfn(pat, dest, srcs), srcs))
739 copylist.append((tfn(pat, dest, srcs), srcs))
740 if not copylist:
740 if not copylist:
741 raise util.Abort(_('no files to copy'))
741 raise error.Abort(_('no files to copy'))
742
742
743 errors = 0
743 errors = 0
744 for targetpath, srcs in copylist:
744 for targetpath, srcs in copylist:
@@ -786,7 +786,7 b' def service(opts, parentfn=None, initfn='
786 return not os.path.exists(lockpath)
786 return not os.path.exists(lockpath)
787 pid = util.rundetached(runargs, condfn)
787 pid = util.rundetached(runargs, condfn)
788 if pid < 0:
788 if pid < 0:
789 raise util.Abort(_('child process failed to start'))
789 raise error.Abort(_('child process failed to start'))
790 writepid(pid)
790 writepid(pid)
791 finally:
791 finally:
792 try:
792 try:
@@ -908,7 +908,7 b' def tryimportone(ui, repo, hunk, parents'
908 parents.append(repo[nullid])
908 parents.append(repo[nullid])
909 if opts.get('exact'):
909 if opts.get('exact'):
910 if not nodeid or not p1:
910 if not nodeid or not p1:
911 raise util.Abort(_('not a Mercurial patch'))
911 raise error.Abort(_('not a Mercurial patch'))
912 p1 = repo[p1]
912 p1 = repo[p1]
913 p2 = repo[p2 or nullid]
913 p2 = repo[p2 or nullid]
914 elif p2:
914 elif p2:
@@ -946,7 +946,7 b' def tryimportone(ui, repo, hunk, parents'
946 files=files, eolmode=None, similarity=sim / 100.0)
946 files=files, eolmode=None, similarity=sim / 100.0)
947 except patch.PatchError as e:
947 except patch.PatchError as e:
948 if not partial:
948 if not partial:
949 raise util.Abort(str(e))
949 raise error.Abort(str(e))
950 if partial:
950 if partial:
951 rejects = True
951 rejects = True
952
952
@@ -993,7 +993,7 b' def tryimportone(ui, repo, hunk, parents'
993 patch.patchrepo(ui, repo, p1, store, tmpname, strip, prefix,
993 patch.patchrepo(ui, repo, p1, store, tmpname, strip, prefix,
994 files, eolmode=None)
994 files, eolmode=None)
995 except patch.PatchError as e:
995 except patch.PatchError as e:
996 raise util.Abort(str(e))
996 raise error.Abort(str(e))
997 if opts.get('exact'):
997 if opts.get('exact'):
998 editor = None
998 editor = None
999 else:
999 else:
@@ -1012,7 +1012,7 b' def tryimportone(ui, repo, hunk, parents'
1012 # and branch bits
1012 # and branch bits
1013 ui.warn(_("warning: can't check exact import with --no-commit\n"))
1013 ui.warn(_("warning: can't check exact import with --no-commit\n"))
1014 elif opts.get('exact') and hex(n) != nodeid:
1014 elif opts.get('exact') and hex(n) != nodeid:
1015 raise util.Abort(_('patch is damaged or loses information'))
1015 raise error.Abort(_('patch is damaged or loses information'))
1016 if n:
1016 if n:
1017 # i18n: refers to a short changeset id
1017 # i18n: refers to a short changeset id
1018 msg = _('created %s') % short(n)
1018 msg = _('created %s') % short(n)
@@ -1500,9 +1500,9 b' class changeset_templater(changeset_prin'
1500 self.t(self._parts['footer'], **props))
1500 self.t(self._parts['footer'], **props))
1501 except KeyError as inst:
1501 except KeyError as inst:
1502 msg = _("%s: no key named '%s'")
1502 msg = _("%s: no key named '%s'")
1503 raise util.Abort(msg % (self.t.mapfile, inst.args[0]))
1503 raise error.Abort(msg % (self.t.mapfile, inst.args[0]))
1504 except SyntaxError as inst:
1504 except SyntaxError as inst:
1505 raise util.Abort('%s: %s' % (self.t.mapfile, inst.args[0]))
1505 raise error.Abort('%s: %s' % (self.t.mapfile, inst.args[0]))
1506
1506
1507 def gettemplate(ui, tmpl, style):
1507 def gettemplate(ui, tmpl, style):
1508 """
1508 """
@@ -1563,7 +1563,7 b' def show_changeset(ui, repo, opts, buffe'
1563 t = changeset_templater(ui, repo, matchfn, opts, tmpl, mapfile,
1563 t = changeset_templater(ui, repo, matchfn, opts, tmpl, mapfile,
1564 buffered)
1564 buffered)
1565 except SyntaxError as inst:
1565 except SyntaxError as inst:
1566 raise util.Abort(inst.args[0])
1566 raise error.Abort(inst.args[0])
1567 return t
1567 return t
1568
1568
1569 def showmarker(ui, marker):
1569 def showmarker(ui, marker):
@@ -1603,7 +1603,7 b' def finddate(ui, repo, date):'
1603 (rev, util.datestr(results[rev])))
1603 (rev, util.datestr(results[rev])))
1604 return str(rev)
1604 return str(rev)
1605
1605
1606 raise util.Abort(_("revision matching date not found"))
1606 raise error.Abort(_("revision matching date not found"))
1607
1607
1608 def increasingwindows(windowsize=8, sizelimit=512):
1608 def increasingwindows(windowsize=8, sizelimit=512):
1609 while True:
1609 while True:
@@ -1658,7 +1658,7 b' def walkfilerevs(repo, match, follow, re'
1658 for filename in match.files():
1658 for filename in match.files():
1659 if follow:
1659 if follow:
1660 if filename not in pctx:
1660 if filename not in pctx:
1661 raise util.Abort(_('cannot follow file not in parent '
1661 raise error.Abort(_('cannot follow file not in parent '
1662 'revision: "%s"') % filename)
1662 'revision: "%s"') % filename)
1663 yield filename, pctx[filename].filenode()
1663 yield filename, pctx[filename].filenode()
1664 else:
1664 else:
@@ -1673,7 +1673,7 b' def walkfilerevs(repo, match, follow, re'
1673 # A zero count may be a directory or deleted file, so
1673 # A zero count may be a directory or deleted file, so
1674 # try to find matching entries on the slow path.
1674 # try to find matching entries on the slow path.
1675 if follow:
1675 if follow:
1676 raise util.Abort(
1676 raise error.Abort(
1677 _('cannot follow nonexistent file: "%s"') % file_)
1677 _('cannot follow nonexistent file: "%s"') % file_)
1678 raise FileWalkError("Cannot walk via filelog")
1678 raise FileWalkError("Cannot walk via filelog")
1679 else:
1679 else:
@@ -1804,7 +1804,7 b' def walkchangerevs(repo, match, opts, pr'
1804 # changed files
1804 # changed files
1805
1805
1806 if follow:
1806 if follow:
1807 raise util.Abort(_('can only follow copies/renames for explicit '
1807 raise error.Abort(_('can only follow copies/renames for explicit '
1808 'filenames'))
1808 'filenames'))
1809
1809
1810 # The slow path checks files modified in every changeset.
1810 # The slow path checks files modified in every changeset.
@@ -1976,14 +1976,14 b' def _makelogrevset(repo, pats, opts, rev'
1976 slowpath = True
1976 slowpath = True
1977 continue
1977 continue
1978 else:
1978 else:
1979 raise util.Abort(_('cannot follow file not in parent '
1979 raise error.Abort(_('cannot follow file not in parent '
1980 'revision: "%s"') % f)
1980 'revision: "%s"') % f)
1981 filelog = repo.file(f)
1981 filelog = repo.file(f)
1982 if not filelog:
1982 if not filelog:
1983 # A zero count may be a directory or deleted file, so
1983 # A zero count may be a directory or deleted file, so
1984 # try to find matching entries on the slow path.
1984 # try to find matching entries on the slow path.
1985 if follow:
1985 if follow:
1986 raise util.Abort(
1986 raise error.Abort(
1987 _('cannot follow nonexistent file: "%s"') % f)
1987 _('cannot follow nonexistent file: "%s"') % f)
1988 slowpath = True
1988 slowpath = True
1989
1989
@@ -2207,7 +2207,7 b' def graphlog(ui, repo, *pats, **opts):'
2207 def checkunsupportedgraphflags(pats, opts):
2207 def checkunsupportedgraphflags(pats, opts):
2208 for op in ["newest_first"]:
2208 for op in ["newest_first"]:
2209 if op in opts and opts[op]:
2209 if op in opts and opts[op]:
2210 raise util.Abort(_("-G/--graph option is incompatible with --%s")
2210 raise error.Abort(_("-G/--graph option is incompatible with --%s")
2211 % op.replace("_", "-"))
2211 % op.replace("_", "-"))
2212
2212
2213 def graphrevs(repo, nodes, opts):
2213 def graphrevs(repo, nodes, opts):
@@ -2485,7 +2485,7 b' def commit(ui, repo, commitfunc, pats, o'
2485 # that doesn't support addremove
2485 # that doesn't support addremove
2486 if opts.get('addremove'):
2486 if opts.get('addremove'):
2487 if scmutil.addremove(repo, matcher, "", opts) != 0:
2487 if scmutil.addremove(repo, matcher, "", opts) != 0:
2488 raise util.Abort(
2488 raise error.Abort(
2489 _("failed to mark all new/missing files as added/removed"))
2489 _("failed to mark all new/missing files as added/removed"))
2490
2490
2491 return commitfunc(ui, repo, message, matcher, opts)
2491 return commitfunc(ui, repo, message, matcher, opts)
@@ -2719,7 +2719,7 b' def commitforceeditor(repo, ctx, subs, f'
2719 if finishdesc:
2719 if finishdesc:
2720 text = finishdesc(text)
2720 text = finishdesc(text)
2721 if not text.strip():
2721 if not text.strip():
2722 raise util.Abort(_("empty commit message"))
2722 raise error.Abort(_("empty commit message"))
2723
2723
2724 return text
2724 return text
2725
2725
@@ -2730,7 +2730,7 b' def buildcommittemplate(repo, ctx, subs,'
2730 try:
2730 try:
2731 t = changeset_templater(ui, repo, None, {}, tmpl, mapfile, False)
2731 t = changeset_templater(ui, repo, None, {}, tmpl, mapfile, False)
2732 except SyntaxError as inst:
2732 except SyntaxError as inst:
2733 raise util.Abort(inst.args[0])
2733 raise error.Abort(inst.args[0])
2734
2734
2735 for k, v in repo.ui.configitems('committemplate'):
2735 for k, v in repo.ui.configitems('committemplate'):
2736 if k != 'changeset':
2736 if k != 'changeset':
@@ -3097,7 +3097,7 b' def revert(ui, repo, ctx, parents, *pats'
3097 try:
3097 try:
3098 wctx.sub(sub).revert(ctx.substate[sub], *pats, **opts)
3098 wctx.sub(sub).revert(ctx.substate[sub], *pats, **opts)
3099 except KeyError:
3099 except KeyError:
3100 raise util.Abort("subrepository '%s' does not exist in %s!"
3100 raise error.Abort("subrepository '%s' does not exist in %s!"
3101 % (sub, short(ctx.node())))
3101 % (sub, short(ctx.node())))
3102 finally:
3102 finally:
3103 wlock.release()
3103 wlock.release()
@@ -3168,7 +3168,7 b' def _performrevert(repo, parents, ctx, a'
3168 chunks = patch.reversehunks(chunks)
3168 chunks = patch.reversehunks(chunks)
3169
3169
3170 except patch.PatchError as err:
3170 except patch.PatchError as err:
3171 raise util.Abort(_('error parsing patch: %s') % err)
3171 raise error.Abort(_('error parsing patch: %s') % err)
3172
3172
3173 newlyaddedandmodifiedfiles = newandmodified(chunks, originalchunks)
3173 newlyaddedandmodifiedfiles = newandmodified(chunks, originalchunks)
3174 # Apply changes
3174 # Apply changes
@@ -3181,7 +3181,7 b' def _performrevert(repo, parents, ctx, a'
3181 try:
3181 try:
3182 patch.internalpatch(repo.ui, repo, fp, 1, eolmode=None)
3182 patch.internalpatch(repo.ui, repo, fp, 1, eolmode=None)
3183 except patch.PatchError as err:
3183 except patch.PatchError as err:
3184 raise util.Abort(str(err))
3184 raise error.Abort(str(err))
3185 del fp
3185 del fp
3186 else:
3186 else:
3187 for f in actions['revert'][0]:
3187 for f in actions['revert'][0]:
@@ -3302,7 +3302,7 b' def checkunfinished(repo, commit=False):'
3302 if commit and allowcommit:
3302 if commit and allowcommit:
3303 continue
3303 continue
3304 if repo.vfs.exists(f):
3304 if repo.vfs.exists(f):
3305 raise util.Abort(msg, hint=hint)
3305 raise error.Abort(msg, hint=hint)
3306
3306
3307 def clearunfinished(repo):
3307 def clearunfinished(repo):
3308 '''Check for unfinished operations (as above), and clear the ones
3308 '''Check for unfinished operations (as above), and clear the ones
@@ -3310,7 +3310,7 b' def clearunfinished(repo):'
3310 '''
3310 '''
3311 for f, clearable, allowcommit, msg, hint in unfinishedstates:
3311 for f, clearable, allowcommit, msg, hint in unfinishedstates:
3312 if not clearable and repo.vfs.exists(f):
3312 if not clearable and repo.vfs.exists(f):
3313 raise util.Abort(msg, hint=hint)
3313 raise error.Abort(msg, hint=hint)
3314 for f, clearable, allowcommit, msg, hint in unfinishedstates:
3314 for f, clearable, allowcommit, msg, hint in unfinishedstates:
3315 if clearable and repo.vfs.exists(f):
3315 if clearable and repo.vfs.exists(f):
3316 util.unlink(repo.join(f))
3316 util.unlink(repo.join(f))
@@ -3349,7 +3349,7 b' class dirstateguard(object):'
3349 if not self._active: # already inactivated
3349 if not self._active: # already inactivated
3350 msg = (_("can't close already inactivated backup: %s")
3350 msg = (_("can't close already inactivated backup: %s")
3351 % self._filename)
3351 % self._filename)
3352 raise util.Abort(msg)
3352 raise error.Abort(msg)
3353
3353
3354 self._repo.vfs.unlink(self._filename)
3354 self._repo.vfs.unlink(self._filename)
3355 self._active = False
3355 self._active = False
@@ -3368,7 +3368,7 b' class dirstateguard(object):'
3368 if not self._active: # already inactivated
3368 if not self._active: # already inactivated
3369 msg = (_("can't release already inactivated backup: %s")
3369 msg = (_("can't release already inactivated backup: %s")
3370 % self._filename)
3370 % self._filename)
3371 raise util.Abort(msg)
3371 raise error.Abort(msg)
3372 self._abort()
3372 self._abort()
3373
3373
3374 _bundlecompspecs = {'none': None,
3374 _bundlecompspecs = {'none': None,
@@ -3402,7 +3402,7 b' def parsebundletype(repo, spec):'
3402 elif spec in _bundleversionspecs:
3402 elif spec in _bundleversionspecs:
3403 version = spec
3403 version = spec
3404 else:
3404 else:
3405 raise util.Abort(_('unknown bundle type specified with --type'))
3405 raise error.Abort(_('unknown bundle type specified with --type'))
3406
3406
3407 if comp is None:
3407 if comp is None:
3408 comp = 'BZ'
3408 comp = 'BZ'
@@ -3410,7 +3410,7 b' def parsebundletype(repo, spec):'
3410 try:
3410 try:
3411 comp = _bundlecompspecs[comp]
3411 comp = _bundlecompspecs[comp]
3412 except KeyError:
3412 except KeyError:
3413 raise util.Abort(_('unknown bundle type specified with --type'))
3413 raise error.Abort(_('unknown bundle type specified with --type'))
3414
3414
3415 if version is None:
3415 if version is None:
3416 version = '01'
3416 version = '01'
@@ -3420,6 +3420,6 b' def parsebundletype(repo, spec):'
3420 try:
3420 try:
3421 version = _bundleversionspecs[version]
3421 version = _bundleversionspecs[version]
3422 except KeyError:
3422 except KeyError:
3423 raise util.Abort(_('unknown bundle type specified with --type'))
3423 raise error.Abort(_('unknown bundle type specified with --type'))
3424
3424
3425 return version, comp
3425 return version, comp
@@ -238,9 +238,9 b' def addremove(ui, repo, *pats, **opts):'
238 try:
238 try:
239 sim = float(opts.get('similarity') or 100)
239 sim = float(opts.get('similarity') or 100)
240 except ValueError:
240 except ValueError:
241 raise util.Abort(_('similarity must be a number'))
241 raise error.Abort(_('similarity must be a number'))
242 if sim < 0 or sim > 100:
242 if sim < 0 or sim > 100:
243 raise util.Abort(_('similarity must be between 0 and 100'))
243 raise error.Abort(_('similarity must be between 0 and 100'))
244 matcher = scmutil.match(repo[None], pats, opts)
244 matcher = scmutil.match(repo[None], pats, opts)
245 return scmutil.addremove(repo, matcher, "", opts, similarity=sim / 100.0)
245 return scmutil.addremove(repo, matcher, "", opts, similarity=sim / 100.0)
246
246
@@ -276,7 +276,7 b' def annotate(ui, repo, *pats, **opts):'
276 Returns 0 on success.
276 Returns 0 on success.
277 """
277 """
278 if not pats:
278 if not pats:
279 raise util.Abort(_('at least one filename or pattern is required'))
279 raise error.Abort(_('at least one filename or pattern is required'))
280
280
281 if opts.get('follow'):
281 if opts.get('follow'):
282 # --follow is deprecated and now just an alias for -f/--file
282 # --follow is deprecated and now just an alias for -f/--file
@@ -333,7 +333,7 b' def annotate(ui, repo, *pats, **opts):'
333
333
334 linenumber = opts.get('line_number') is not None
334 linenumber = opts.get('line_number') is not None
335 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
335 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
336 raise util.Abort(_('at least one of -n/-c is required for -l'))
336 raise error.Abort(_('at least one of -n/-c is required for -l'))
337
337
338 if fm:
338 if fm:
339 def makefunc(get, fmt):
339 def makefunc(get, fmt):
@@ -348,7 +348,7 b' def annotate(ui, repo, *pats, **opts):'
348 if opts.get(op))
348 if opts.get(op))
349
349
350 def bad(x, y):
350 def bad(x, y):
351 raise util.Abort("%s: %s" % (x, y))
351 raise error.Abort("%s: %s" % (x, y))
352
352
353 m = scmutil.match(ctx, pats, opts, badfn=bad)
353 m = scmutil.match(ctx, pats, opts, badfn=bad)
354
354
@@ -438,18 +438,18 b' def archive(ui, repo, dest, **opts):'
438
438
439 ctx = scmutil.revsingle(repo, opts.get('rev'))
439 ctx = scmutil.revsingle(repo, opts.get('rev'))
440 if not ctx:
440 if not ctx:
441 raise util.Abort(_('no working directory: please specify a revision'))
441 raise error.Abort(_('no working directory: please specify a revision'))
442 node = ctx.node()
442 node = ctx.node()
443 dest = cmdutil.makefilename(repo, dest, node)
443 dest = cmdutil.makefilename(repo, dest, node)
444 if os.path.realpath(dest) == repo.root:
444 if os.path.realpath(dest) == repo.root:
445 raise util.Abort(_('repository root cannot be destination'))
445 raise error.Abort(_('repository root cannot be destination'))
446
446
447 kind = opts.get('type') or archival.guesskind(dest) or 'files'
447 kind = opts.get('type') or archival.guesskind(dest) or 'files'
448 prefix = opts.get('prefix')
448 prefix = opts.get('prefix')
449
449
450 if dest == '-':
450 if dest == '-':
451 if kind == 'files':
451 if kind == 'files':
452 raise util.Abort(_('cannot archive plain files to stdout'))
452 raise error.Abort(_('cannot archive plain files to stdout'))
453 dest = cmdutil.makefileobj(repo, dest)
453 dest = cmdutil.makefileobj(repo, dest)
454 if not prefix:
454 if not prefix:
455 prefix = os.path.basename(repo.root) + '-%h'
455 prefix = os.path.basename(repo.root) + '-%h'
@@ -504,13 +504,13 b' def backout(ui, repo, node=None, rev=Non'
504 files.
504 files.
505 '''
505 '''
506 if rev and node:
506 if rev and node:
507 raise util.Abort(_("please specify just one revision"))
507 raise error.Abort(_("please specify just one revision"))
508
508
509 if not rev:
509 if not rev:
510 rev = node
510 rev = node
511
511
512 if not rev:
512 if not rev:
513 raise util.Abort(_("please specify a revision to backout"))
513 raise error.Abort(_("please specify a revision to backout"))
514
514
515 date = opts.get('date')
515 date = opts.get('date')
516 if date:
516 if date:
@@ -522,22 +522,22 b' def backout(ui, repo, node=None, rev=Non'
522
522
523 op1, op2 = repo.dirstate.parents()
523 op1, op2 = repo.dirstate.parents()
524 if not repo.changelog.isancestor(node, op1):
524 if not repo.changelog.isancestor(node, op1):
525 raise util.Abort(_('cannot backout change that is not an ancestor'))
525 raise error.Abort(_('cannot backout change that is not an ancestor'))
526
526
527 p1, p2 = repo.changelog.parents(node)
527 p1, p2 = repo.changelog.parents(node)
528 if p1 == nullid:
528 if p1 == nullid:
529 raise util.Abort(_('cannot backout a change with no parents'))
529 raise error.Abort(_('cannot backout a change with no parents'))
530 if p2 != nullid:
530 if p2 != nullid:
531 if not opts.get('parent'):
531 if not opts.get('parent'):
532 raise util.Abort(_('cannot backout a merge changeset'))
532 raise error.Abort(_('cannot backout a merge changeset'))
533 p = repo.lookup(opts['parent'])
533 p = repo.lookup(opts['parent'])
534 if p not in (p1, p2):
534 if p not in (p1, p2):
535 raise util.Abort(_('%s is not a parent of %s') %
535 raise error.Abort(_('%s is not a parent of %s') %
536 (short(p), short(node)))
536 (short(p), short(node)))
537 parent = p
537 parent = p
538 else:
538 else:
539 if opts.get('parent'):
539 if opts.get('parent'):
540 raise util.Abort(_('cannot use --parent on non-merge changeset'))
540 raise error.Abort(_('cannot use --parent on non-merge changeset'))
541 parent = p1
541 parent = p1
542
542
543 # the backout should appear on the same branch
543 # the backout should appear on the same branch
@@ -746,9 +746,9 b' def bisect(ui, repo, rev=None, extra=Non'
746 if (good or bad or skip or reset) and interactive:
746 if (good or bad or skip or reset) and interactive:
747 return
747 return
748 if not state['good']:
748 if not state['good']:
749 raise util.Abort(_('cannot bisect (no known good revisions)'))
749 raise error.Abort(_('cannot bisect (no known good revisions)'))
750 else:
750 else:
751 raise util.Abort(_('cannot bisect (no known bad revisions)'))
751 raise error.Abort(_('cannot bisect (no known bad revisions)'))
752 return True
752 return True
753
753
754 # backward compatibility
754 # backward compatibility
@@ -762,7 +762,7 b' def bisect(ui, repo, rev=None, extra=Non'
762 else:
762 else:
763 reset = True
763 reset = True
764 elif extra or good + bad + skip + reset + extend + bool(command) > 1:
764 elif extra or good + bad + skip + reset + extend + bool(command) > 1:
765 raise util.Abort(_('incompatible arguments'))
765 raise error.Abort(_('incompatible arguments'))
766
766
767 cmdutil.checkunfinished(repo)
767 cmdutil.checkunfinished(repo)
768
768
@@ -780,12 +780,12 b' def bisect(ui, repo, rev=None, extra=Non'
780 try:
780 try:
781 node = state['current'][0]
781 node = state['current'][0]
782 except LookupError:
782 except LookupError:
783 raise util.Abort(_('current bisect revision is unknown - '
783 raise error.Abort(_('current bisect revision is unknown - '
784 'start a new bisect to fix'))
784 'start a new bisect to fix'))
785 else:
785 else:
786 node, p2 = repo.dirstate.parents()
786 node, p2 = repo.dirstate.parents()
787 if p2 != nullid:
787 if p2 != nullid:
788 raise util.Abort(_('current bisect revision is a merge'))
788 raise error.Abort(_('current bisect revision is a merge'))
789 try:
789 try:
790 while changesets:
790 while changesets:
791 # update state
791 # update state
@@ -798,9 +798,9 b' def bisect(ui, repo, rev=None, extra=Non'
798 transition = "good"
798 transition = "good"
799 # status < 0 means process was killed
799 # status < 0 means process was killed
800 elif status == 127:
800 elif status == 127:
801 raise util.Abort(_("failed to execute %s") % command)
801 raise error.Abort(_("failed to execute %s") % command)
802 elif status < 0:
802 elif status < 0:
803 raise util.Abort(_("%s killed") % command)
803 raise error.Abort(_("%s killed") % command)
804 else:
804 else:
805 transition = "bad"
805 transition = "bad"
806 ctx = scmutil.revsingle(repo, rev, node)
806 ctx = scmutil.revsingle(repo, rev, node)
@@ -854,7 +854,7 b' def bisect(ui, repo, rev=None, extra=Non'
854 return
854 return
855 cmdutil.bailifchanged(repo)
855 cmdutil.bailifchanged(repo)
856 return hg.clean(repo, extendnode.node())
856 return hg.clean(repo, extendnode.node())
857 raise util.Abort(_("nothing to extend"))
857 raise error.Abort(_("nothing to extend"))
858
858
859 if changesets == 0:
859 if changesets == 0:
860 print_result(nodes, good)
860 print_result(nodes, good)
@@ -937,7 +937,7 b' def bookmark(ui, repo, *names, **opts):'
937 def checkformat(mark):
937 def checkformat(mark):
938 mark = mark.strip()
938 mark = mark.strip()
939 if not mark:
939 if not mark:
940 raise util.Abort(_("bookmark names cannot consist entirely of "
940 raise error.Abort(_("bookmark names cannot consist entirely of "
941 "whitespace"))
941 "whitespace"))
942 scmutil.checknewlabel(repo, mark, 'bookmark')
942 scmutil.checknewlabel(repo, mark, 'bookmark')
943 return mark
943 return mark
@@ -967,21 +967,21 b' def bookmark(ui, repo, *names, **opts):'
967 ui.status(_("moving bookmark '%s' forward from %s\n") %
967 ui.status(_("moving bookmark '%s' forward from %s\n") %
968 (mark, short(bmctx.node())))
968 (mark, short(bmctx.node())))
969 return
969 return
970 raise util.Abort(_("bookmark '%s' already exists "
970 raise error.Abort(_("bookmark '%s' already exists "
971 "(use -f to force)") % mark)
971 "(use -f to force)") % mark)
972 if ((mark in repo.branchmap() or mark == repo.dirstate.branch())
972 if ((mark in repo.branchmap() or mark == repo.dirstate.branch())
973 and not force):
973 and not force):
974 raise util.Abort(
974 raise error.Abort(
975 _("a bookmark cannot have the name of an existing branch"))
975 _("a bookmark cannot have the name of an existing branch"))
976
976
977 if delete and rename:
977 if delete and rename:
978 raise util.Abort(_("--delete and --rename are incompatible"))
978 raise error.Abort(_("--delete and --rename are incompatible"))
979 if delete and rev:
979 if delete and rev:
980 raise util.Abort(_("--rev is incompatible with --delete"))
980 raise error.Abort(_("--rev is incompatible with --delete"))
981 if rename and rev:
981 if rename and rev:
982 raise util.Abort(_("--rev is incompatible with --rename"))
982 raise error.Abort(_("--rev is incompatible with --rename"))
983 if not names and (delete or rev):
983 if not names and (delete or rev):
984 raise util.Abort(_("bookmark name required"))
984 raise error.Abort(_("bookmark name required"))
985
985
986 if delete or rename or names or inactive:
986 if delete or rename or names or inactive:
987 wlock = lock = tr = None
987 wlock = lock = tr = None
@@ -994,7 +994,7 b' def bookmark(ui, repo, *names, **opts):'
994 tr = repo.transaction('bookmark')
994 tr = repo.transaction('bookmark')
995 for mark in names:
995 for mark in names:
996 if mark not in marks:
996 if mark not in marks:
997 raise util.Abort(_("bookmark '%s' does not exist") %
997 raise error.Abort(_("bookmark '%s' does not exist") %
998 mark)
998 mark)
999 if mark == repo._activebookmark:
999 if mark == repo._activebookmark:
1000 bookmarks.deactivate(repo)
1000 bookmarks.deactivate(repo)
@@ -1003,12 +1003,13 b' def bookmark(ui, repo, *names, **opts):'
1003 elif rename:
1003 elif rename:
1004 tr = repo.transaction('bookmark')
1004 tr = repo.transaction('bookmark')
1005 if not names:
1005 if not names:
1006 raise util.Abort(_("new bookmark name required"))
1006 raise error.Abort(_("new bookmark name required"))
1007 elif len(names) > 1:
1007 elif len(names) > 1:
1008 raise util.Abort(_("only one new bookmark name allowed"))
1008 raise error.Abort(_("only one new bookmark name allowed"))
1009 mark = checkformat(names[0])
1009 mark = checkformat(names[0])
1010 if rename not in marks:
1010 if rename not in marks:
1011 raise util.Abort(_("bookmark '%s' does not exist") % rename)
1011 raise error.Abort(_("bookmark '%s' does not exist")
1012 % rename)
1012 checkconflict(repo, mark, cur, force)
1013 checkconflict(repo, mark, cur, force)
1013 marks[mark] = marks[rename]
1014 marks[mark] = marks[rename]
1014 if repo._activebookmark == rename and not inactive:
1015 if repo._activebookmark == rename and not inactive:
@@ -1119,7 +1120,7 b' def branch(ui, repo, label=None, **opts)'
1119 elif label:
1120 elif label:
1120 if not opts.get('force') and label in repo.branchmap():
1121 if not opts.get('force') and label in repo.branchmap():
1121 if label not in [p.branch() for p in repo.parents()]:
1122 if label not in [p.branch() for p in repo.parents()]:
1122 raise util.Abort(_('a branch of the same name already'
1123 raise error.Abort(_('a branch of the same name already'
1123 ' exists'),
1124 ' exists'),
1124 # i18n: "it" refers to an existing branch
1125 # i18n: "it" refers to an existing branch
1125 hint=_("use 'hg update' to switch to it"))
1126 hint=_("use 'hg update' to switch to it"))
@@ -1251,7 +1252,7 b' def bundle(ui, repo, fname, dest=None, *'
1251 bundlecaps = None
1252 bundlecaps = None
1252 if base:
1253 if base:
1253 if dest:
1254 if dest:
1254 raise util.Abort(_("--base is incompatible with specifying "
1255 raise error.Abort(_("--base is incompatible with specifying "
1255 "a destination"))
1256 "a destination"))
1256 common = [repo.lookup(rev) for rev in base]
1257 common = [repo.lookup(rev) for rev in base]
1257 heads = revs and map(repo.lookup, revs) or revs
1258 heads = revs and map(repo.lookup, revs) or revs
@@ -1429,7 +1430,7 b' def clone(ui, source, dest=None, **opts)'
1429 Returns 0 on success.
1430 Returns 0 on success.
1430 """
1431 """
1431 if opts.get('noupdate') and opts.get('updaterev'):
1432 if opts.get('noupdate') and opts.get('updaterev'):
1432 raise util.Abort(_("cannot specify both --noupdate and --updaterev"))
1433 raise error.Abort(_("cannot specify both --noupdate and --updaterev"))
1433
1434
1434 r = hg.clone(ui, opts, source, dest,
1435 r = hg.clone(ui, opts, source, dest,
1435 pull=opts.get('pull'),
1436 pull=opts.get('pull'),
@@ -1501,7 +1502,7 b' def commit(ui, repo, *pats, **opts):'
1501
1502
1502 if opts.get('subrepos'):
1503 if opts.get('subrepos'):
1503 if opts.get('amend'):
1504 if opts.get('amend'):
1504 raise util.Abort(_('cannot amend with --subrepos'))
1505 raise error.Abort(_('cannot amend with --subrepos'))
1505 # Let --subrepos on the command line override config setting.
1506 # Let --subrepos on the command line override config setting.
1506 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
1507 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
1507
1508
@@ -1515,24 +1516,24 b' def commit(ui, repo, *pats, **opts):'
1515 extra['close'] = 1
1516 extra['close'] = 1
1516
1517
1517 if not bheads:
1518 if not bheads:
1518 raise util.Abort(_('can only close branch heads'))
1519 raise error.Abort(_('can only close branch heads'))
1519 elif opts.get('amend'):
1520 elif opts.get('amend'):
1520 if repo.parents()[0].p1().branch() != branch and \
1521 if repo.parents()[0].p1().branch() != branch and \
1521 repo.parents()[0].p2().branch() != branch:
1522 repo.parents()[0].p2().branch() != branch:
1522 raise util.Abort(_('can only close branch heads'))
1523 raise error.Abort(_('can only close branch heads'))
1523
1524
1524 if opts.get('amend'):
1525 if opts.get('amend'):
1525 if ui.configbool('ui', 'commitsubrepos'):
1526 if ui.configbool('ui', 'commitsubrepos'):
1526 raise util.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1527 raise error.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1527
1528
1528 old = repo['.']
1529 old = repo['.']
1529 if not old.mutable():
1530 if not old.mutable():
1530 raise util.Abort(_('cannot amend public changesets'))
1531 raise error.Abort(_('cannot amend public changesets'))
1531 if len(repo[None].parents()) > 1:
1532 if len(repo[None].parents()) > 1:
1532 raise util.Abort(_('cannot amend while merging'))
1533 raise error.Abort(_('cannot amend while merging'))
1533 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
1534 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
1534 if not allowunstable and old.children():
1535 if not allowunstable and old.children():
1535 raise util.Abort(_('cannot amend changeset with children'))
1536 raise error.Abort(_('cannot amend changeset with children'))
1536
1537
1537 # commitfunc is used only for temporary amend commit by cmdutil.amend
1538 # commitfunc is used only for temporary amend commit by cmdutil.amend
1538 def commitfunc(ui, repo, message, match, opts):
1539 def commitfunc(ui, repo, message, match, opts):
@@ -1614,11 +1615,11 b' def config(ui, repo, *values, **opts):'
1614
1615
1615 if opts.get('edit') or opts.get('local') or opts.get('global'):
1616 if opts.get('edit') or opts.get('local') or opts.get('global'):
1616 if opts.get('local') and opts.get('global'):
1617 if opts.get('local') and opts.get('global'):
1617 raise util.Abort(_("can't use --local and --global together"))
1618 raise error.Abort(_("can't use --local and --global together"))
1618
1619
1619 if opts.get('local'):
1620 if opts.get('local'):
1620 if not repo:
1621 if not repo:
1621 raise util.Abort(_("can't use --local outside a repository"))
1622 raise error.Abort(_("can't use --local outside a repository"))
1622 paths = [repo.join('hgrc')]
1623 paths = [repo.join('hgrc')]
1623 elif opts.get('global'):
1624 elif opts.get('global'):
1624 paths = scmutil.systemrcpath()
1625 paths = scmutil.systemrcpath()
@@ -1643,7 +1644,7 b' def config(ui, repo, *values, **opts):'
1643
1644
1644 editor = ui.geteditor()
1645 editor = ui.geteditor()
1645 ui.system("%s \"%s\"" % (editor, f),
1646 ui.system("%s \"%s\"" % (editor, f),
1646 onerr=util.Abort, errprefix=_("edit failed"))
1647 onerr=error.Abort, errprefix=_("edit failed"))
1647 return
1648 return
1648
1649
1649 for f in scmutil.rcpath():
1650 for f in scmutil.rcpath():
@@ -1653,7 +1654,7 b' def config(ui, repo, *values, **opts):'
1653 sections = [v for v in values if '.' not in v]
1654 sections = [v for v in values if '.' not in v]
1654 items = [v for v in values if '.' in v]
1655 items = [v for v in values if '.' in v]
1655 if len(items) > 1 or items and sections:
1656 if len(items) > 1 or items and sections:
1656 raise util.Abort(_('only one config item permitted'))
1657 raise error.Abort(_('only one config item permitted'))
1657 matched = False
1658 matched = False
1658 for section, name, value in ui.walkconfig(untrusted=untrusted):
1659 for section, name, value in ui.walkconfig(untrusted=untrusted):
1659 value = str(value).replace('\n', '\\n')
1660 value = str(value).replace('\n', '\\n')
@@ -1715,13 +1716,13 b' def debugancestor(ui, repo, *args):'
1715 lookup = r.lookup
1716 lookup = r.lookup
1716 elif len(args) == 2:
1717 elif len(args) == 2:
1717 if not repo:
1718 if not repo:
1718 raise util.Abort(_("there is no Mercurial repository here "
1719 raise error.Abort(_("there is no Mercurial repository here "
1719 "(.hg not found)"))
1720 "(.hg not found)"))
1720 rev1, rev2 = args
1721 rev1, rev2 = args
1721 r = repo.changelog
1722 r = repo.changelog
1722 lookup = repo.lookup
1723 lookup = repo.lookup
1723 else:
1724 else:
1724 raise util.Abort(_('either two or three arguments required'))
1725 raise error.Abort(_('either two or three arguments required'))
1725 a = r.ancestor(lookup(rev1), lookup(rev2))
1726 a = r.ancestor(lookup(rev1), lookup(rev2))
1726 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
1727 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
1727
1728
@@ -1772,7 +1773,7 b' def debugbuilddag(ui, repo, text=None,'
1772
1773
1773 cl = repo.changelog
1774 cl = repo.changelog
1774 if len(cl) > 0:
1775 if len(cl) > 0:
1775 raise util.Abort(_('repository is not empty'))
1776 raise error.Abort(_('repository is not empty'))
1776
1777
1777 # determine number of revs in DAG
1778 # determine number of revs in DAG
1778 total = 0
1779 total = 0
@@ -1920,7 +1921,7 b' def debugbundle(ui, bundlepath, all=None'
1920 showchunks(fname)
1921 showchunks(fname)
1921 else:
1922 else:
1922 if isinstance(gen, bundle2.unbundle20):
1923 if isinstance(gen, bundle2.unbundle20):
1923 raise util.Abort(_('use debugbundle2 for this file'))
1924 raise error.Abort(_('use debugbundle2 for this file'))
1924 chunkdata = gen.changelogheader()
1925 chunkdata = gen.changelogheader()
1925 chain = None
1926 chain = None
1926 while True:
1927 while True:
@@ -1936,7 +1937,7 b' def debugbundle(ui, bundlepath, all=None'
1936 def _debugbundle2(ui, gen, **opts):
1937 def _debugbundle2(ui, gen, **opts):
1937 """lists the contents of a bundle2"""
1938 """lists the contents of a bundle2"""
1938 if not isinstance(gen, bundle2.unbundle20):
1939 if not isinstance(gen, bundle2.unbundle20):
1939 raise util.Abort(_('not a bundle2 file'))
1940 raise error.Abort(_('not a bundle2 file'))
1940 ui.write(('Stream params: %s\n' % repr(gen.params)))
1941 ui.write(('Stream params: %s\n' % repr(gen.params)))
1941 for part in gen.iterparts():
1942 for part in gen.iterparts():
1942 ui.write('%s -- %r\n' % (part.type, repr(part.params)))
1943 ui.write('%s -- %r\n' % (part.type, repr(part.params)))
@@ -1979,7 +1980,7 b' def debugcheckstate(ui, repo):'
1979 errors += 1
1980 errors += 1
1980 if errors:
1981 if errors:
1981 error = _(".hg/dirstate inconsistent with current parent's manifest")
1982 error = _(".hg/dirstate inconsistent with current parent's manifest")
1982 raise util.Abort(error)
1983 raise error.Abort(error)
1983
1984
1984 @command('debugcommands', [], _('[COMMAND]'), norepo=True)
1985 @command('debugcommands', [], _('[COMMAND]'), norepo=True)
1985 def debugcommands(ui, cmd='', *args):
1986 def debugcommands(ui, cmd='', *args):
@@ -2067,7 +2068,7 b' def debugdag(ui, repo, file_=None, *revs'
2067 for l in ls:
2068 for l in ls:
2068 yield 'l', (r, l)
2069 yield 'l', (r, l)
2069 else:
2070 else:
2070 raise util.Abort(_('need repo for changelog dag'))
2071 raise error.Abort(_('need repo for changelog dag'))
2071
2072
2072 for line in dagparser.dagtextlines(events(),
2073 for line in dagparser.dagtextlines(events(),
2073 addspaces=spaces,
2074 addspaces=spaces,
@@ -2094,7 +2095,7 b' def debugdata(ui, repo, file_, rev=None,'
2094 try:
2095 try:
2095 ui.write(r.revision(r.lookup(rev)))
2096 ui.write(r.revision(r.lookup(rev)))
2096 except KeyError:
2097 except KeyError:
2097 raise util.Abort(_('invalid revision identifier %s') % rev)
2098 raise error.Abort(_('invalid revision identifier %s') % rev)
2098
2099
2099 @command('debugdate',
2100 @command('debugdate',
2100 [('e', 'extended', None, _('try extended date formats'))],
2101 [('e', 'extended', None, _('try extended date formats'))],
@@ -2131,7 +2132,7 b' def debugdiscovery(ui, repo, remoteurl="'
2131 def doit(localheads, remoteheads, remote=remote):
2132 def doit(localheads, remoteheads, remote=remote):
2132 if opts.get('old'):
2133 if opts.get('old'):
2133 if localheads:
2134 if localheads:
2134 raise util.Abort('cannot use localheads with old style '
2135 raise error.Abort('cannot use localheads with old style '
2135 'discovery')
2136 'discovery')
2136 if not util.safehasattr(remote, 'branches'):
2137 if not util.safehasattr(remote, 'branches'):
2137 # enable in-client legacy support
2138 # enable in-client legacy support
@@ -2259,7 +2260,7 b' def debuggetbundle(ui, repopath, bundlep'
2259 """
2260 """
2260 repo = hg.peer(ui, opts, repopath)
2261 repo = hg.peer(ui, opts, repopath)
2261 if not repo.capable('getbundle'):
2262 if not repo.capable('getbundle'):
2262 raise util.Abort("getbundle() not supported by target repository")
2263 raise error.Abort("getbundle() not supported by target repository")
2263 args = {}
2264 args = {}
2264 if common:
2265 if common:
2265 args['common'] = [bin(s) for s in common]
2266 args['common'] = [bin(s) for s in common]
@@ -2276,7 +2277,7 b' def debuggetbundle(ui, repopath, bundlep'
2276 'bundle2': 'HG20'}
2277 'bundle2': 'HG20'}
2277 bundletype = btypes.get(bundletype)
2278 bundletype = btypes.get(bundletype)
2278 if bundletype not in changegroup.bundletypes:
2279 if bundletype not in changegroup.bundletypes:
2279 raise util.Abort(_('unknown bundle type specified with --type'))
2280 raise error.Abort(_('unknown bundle type specified with --type'))
2280 changegroup.writebundle(ui, bundle, bundlepath, bundletype)
2281 changegroup.writebundle(ui, bundle, bundlepath, bundletype)
2281
2282
2282 @command('debugignore', [], '')
2283 @command('debugignore', [], '')
@@ -2287,7 +2288,7 b' def debugignore(ui, repo, *values, **opt'
2287 if includepat is not None:
2288 if includepat is not None:
2288 ui.write("%s\n" % includepat)
2289 ui.write("%s\n" % includepat)
2289 else:
2290 else:
2290 raise util.Abort(_("no ignore patterns found"))
2291 raise error.Abort(_("no ignore patterns found"))
2291
2292
2292 @command('debugindex',
2293 @command('debugindex',
2293 [('c', 'changelog', False, _('open changelog')),
2294 [('c', 'changelog', False, _('open changelog')),
@@ -2301,7 +2302,7 b' def debugindex(ui, repo, file_=None, **o'
2301 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
2302 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
2302 format = opts.get('format', 0)
2303 format = opts.get('format', 0)
2303 if format not in (0, 1):
2304 if format not in (0, 1):
2304 raise util.Abort(_("unknown format %d") % format)
2305 raise error.Abort(_("unknown format %d") % format)
2305
2306
2306 generaldelta = r.version & revlog.REVLOGGENERALDELTA
2307 generaldelta = r.version & revlog.REVLOGGENERALDELTA
2307 if generaldelta:
2308 if generaldelta:
@@ -2387,7 +2388,7 b' def debuginstall(ui):'
2387 ui.status(_("checking encoding (%s)...\n") % encoding.encoding)
2388 ui.status(_("checking encoding (%s)...\n") % encoding.encoding)
2388 try:
2389 try:
2389 encoding.fromlocal("test")
2390 encoding.fromlocal("test")
2390 except util.Abort as inst:
2391 except error.Abort as inst:
2391 ui.write(" %s\n" % inst)
2392 ui.write(" %s\n" % inst)
2392 ui.write(_(" (check that your locale is properly set)\n"))
2393 ui.write(_(" (check that your locale is properly set)\n"))
2393 problems += 1
2394 problems += 1
@@ -2453,7 +2454,7 b' def debuginstall(ui):'
2453 ui.status(_("checking username...\n"))
2454 ui.status(_("checking username...\n"))
2454 try:
2455 try:
2455 ui.username()
2456 ui.username()
2456 except util.Abort as e:
2457 except error.Abort as e:
2457 ui.write(" %s\n" % e)
2458 ui.write(" %s\n" % e)
2458 ui.write(_(" (specify a username in your configuration file)\n"))
2459 ui.write(_(" (specify a username in your configuration file)\n"))
2459 problems += 1
2460 problems += 1
@@ -2475,7 +2476,7 b' def debugknown(ui, repopath, *ids, **opt'
2475 """
2476 """
2476 repo = hg.peer(ui, opts, repopath)
2477 repo = hg.peer(ui, opts, repopath)
2477 if not repo.capable('known'):
2478 if not repo.capable('known'):
2478 raise util.Abort("known() not supported by target repository")
2479 raise error.Abort("known() not supported by target repository")
2479 flags = repo.known([bin(s) for s in ids])
2480 flags = repo.known([bin(s) for s in ids])
2480 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
2481 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
2481
2482
@@ -2663,12 +2664,12 b' def debugobsolete(ui, repo, precursor=No'
2663 raise TypeError()
2664 raise TypeError()
2664 return n
2665 return n
2665 except TypeError:
2666 except TypeError:
2666 raise util.Abort('changeset references must be full hexadecimal '
2667 raise error.Abort('changeset references must be full hexadecimal '
2667 'node identifiers')
2668 'node identifiers')
2668
2669
2669 if precursor is not None:
2670 if precursor is not None:
2670 if opts['rev']:
2671 if opts['rev']:
2671 raise util.Abort('cannot select revision when creating marker')
2672 raise error.Abort('cannot select revision when creating marker')
2672 metadata = {}
2673 metadata = {}
2673 metadata['user'] = opts['user'] or ui.username()
2674 metadata['user'] = opts['user'] or ui.username()
2674 succs = tuple(parsenodeid(succ) for succ in successors)
2675 succs = tuple(parsenodeid(succ) for succ in successors)
@@ -2685,7 +2686,7 b' def debugobsolete(ui, repo, precursor=No'
2685 parents = None
2686 parents = None
2686 if opts['record_parents']:
2687 if opts['record_parents']:
2687 if prec not in repo.unfiltered():
2688 if prec not in repo.unfiltered():
2688 raise util.Abort('cannot used --record-parents on '
2689 raise error.Abort('cannot used --record-parents on '
2689 'unknown changesets')
2690 'unknown changesets')
2690 parents = repo.unfiltered()[prec].parents()
2691 parents = repo.unfiltered()[prec].parents()
2691 parents = tuple(p.node() for p in parents)
2692 parents = tuple(p.node() for p in parents)
@@ -2694,7 +2695,7 b' def debugobsolete(ui, repo, precursor=No'
2694 metadata=metadata)
2695 metadata=metadata)
2695 tr.close()
2696 tr.close()
2696 except ValueError as exc:
2697 except ValueError as exc:
2697 raise util.Abort(_('bad obsmarker input: %s') % exc)
2698 raise error.Abort(_('bad obsmarker input: %s') % exc)
2698 finally:
2699 finally:
2699 tr.release()
2700 tr.release()
2700 finally:
2701 finally:
@@ -3319,7 +3320,7 b' def diff(ui, repo, *pats, **opts):'
3319
3320
3320 if revs and change:
3321 if revs and change:
3321 msg = _('cannot specify --rev and --change at the same time')
3322 msg = _('cannot specify --rev and --change at the same time')
3322 raise util.Abort(msg)
3323 raise error.Abort(msg)
3323 elif change:
3324 elif change:
3324 node2 = scmutil.revsingle(repo, change, None).node()
3325 node2 = scmutil.revsingle(repo, change, None).node()
3325 node1 = repo[node2].p1().node()
3326 node1 = repo[node2].p1().node()
@@ -3407,7 +3408,7 b' def export(ui, repo, *changesets, **opts'
3407 changesets = ['.']
3408 changesets = ['.']
3408 revs = scmutil.revrange(repo, changesets)
3409 revs = scmutil.revrange(repo, changesets)
3409 if not revs:
3410 if not revs:
3410 raise util.Abort(_("export requires at least one changeset"))
3411 raise error.Abort(_("export requires at least one changeset"))
3411 if len(revs) > 1:
3412 if len(revs) > 1:
3412 ui.note(_('exporting patches:\n'))
3413 ui.note(_('exporting patches:\n'))
3413 else:
3414 else:
@@ -3511,7 +3512,7 b' def forget(ui, repo, *pats, **opts):'
3511 """
3512 """
3512
3513
3513 if not pats:
3514 if not pats:
3514 raise util.Abort(_('no files specified'))
3515 raise error.Abort(_('no files specified'))
3515
3516
3516 m = scmutil.match(repo[None], pats, opts)
3517 m = scmutil.match(repo[None], pats, opts)
3517 rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0]
3518 rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0]
@@ -3602,7 +3603,7 b' def graft(ui, repo, *revs, **opts):'
3602 if opts['continue']:
3603 if opts['continue']:
3603 cont = True
3604 cont = True
3604 if revs:
3605 if revs:
3605 raise util.Abort(_("can't specify --continue and revisions"))
3606 raise error.Abort(_("can't specify --continue and revisions"))
3606 # read in unfinished revisions
3607 # read in unfinished revisions
3607 try:
3608 try:
3608 nodes = repo.vfs.read('graftstate').splitlines()
3609 nodes = repo.vfs.read('graftstate').splitlines()
@@ -3610,12 +3611,12 b' def graft(ui, repo, *revs, **opts):'
3610 except IOError as inst:
3611 except IOError as inst:
3611 if inst.errno != errno.ENOENT:
3612 if inst.errno != errno.ENOENT:
3612 raise
3613 raise
3613 raise util.Abort(_("no graft state found, can't continue"))
3614 raise error.Abort(_("no graft state found, can't continue"))
3614 else:
3615 else:
3615 cmdutil.checkunfinished(repo)
3616 cmdutil.checkunfinished(repo)
3616 cmdutil.bailifchanged(repo)
3617 cmdutil.bailifchanged(repo)
3617 if not revs:
3618 if not revs:
3618 raise util.Abort(_('no revisions specified'))
3619 raise error.Abort(_('no revisions specified'))
3619 revs = scmutil.revrange(repo, revs)
3620 revs = scmutil.revrange(repo, revs)
3620
3621
3621 skipped = set()
3622 skipped = set()
@@ -3738,7 +3739,7 b' def graft(ui, repo, *revs, **opts):'
3738 # write out state for --continue
3739 # write out state for --continue
3739 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
3740 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
3740 repo.vfs.write('graftstate', ''.join(nodelines))
3741 repo.vfs.write('graftstate', ''.join(nodelines))
3741 raise util.Abort(
3742 raise error.Abort(
3742 _("unresolved conflicts, can't continue"),
3743 _("unresolved conflicts, can't continue"),
3743 hint=_('use hg resolve and hg graft --continue'))
3744 hint=_('use hg resolve and hg graft --continue'))
3744 else:
3745 else:
@@ -4101,7 +4102,7 b' def help_(ui, name=None, **opts):'
4101 # to look for, or we could have simply failed to found "foo.bar"
4102 # to look for, or we could have simply failed to found "foo.bar"
4102 # because bar isn't a section of foo
4103 # because bar isn't a section of foo
4103 if section and not (formatted and name):
4104 if section and not (formatted and name):
4104 raise util.Abort(_("help section not found"))
4105 raise error.Abort(_("help section not found"))
4105
4106
4106 if 'verbose' in pruned:
4107 if 'verbose' in pruned:
4107 keep.append('omitted')
4108 keep.append('omitted')
@@ -4158,7 +4159,7 b' def identify(ui, repo, source=None, rev='
4158 """
4159 """
4159
4160
4160 if not repo and not source:
4161 if not repo and not source:
4161 raise util.Abort(_("there is no Mercurial repository here "
4162 raise error.Abort(_("there is no Mercurial repository here "
4162 "(.hg not found)"))
4163 "(.hg not found)"))
4163
4164
4164 if ui.debugflag:
4165 if ui.debugflag:
@@ -4177,7 +4178,7 b' def identify(ui, repo, source=None, rev='
4177
4178
4178 if not repo:
4179 if not repo:
4179 if num or branch or tags:
4180 if num or branch or tags:
4180 raise util.Abort(
4181 raise error.Abort(
4181 _("can't query remote revision number, branch, or tags"))
4182 _("can't query remote revision number, branch, or tags"))
4182 if not rev and revs:
4183 if not rev and revs:
4183 rev = revs[0]
4184 rev = revs[0]
@@ -4370,7 +4371,7 b' def import_(ui, repo, patch1=None, *patc'
4370 """
4371 """
4371
4372
4372 if not patch1:
4373 if not patch1:
4373 raise util.Abort(_('need at least one patch to import'))
4374 raise error.Abort(_('need at least one patch to import'))
4374
4375
4375 patches = (patch1,) + patches
4376 patches = (patch1,) + patches
4376
4377
@@ -4380,19 +4381,19 b' def import_(ui, repo, patch1=None, *patc'
4380
4381
4381 update = not opts.get('bypass')
4382 update = not opts.get('bypass')
4382 if not update and opts.get('no_commit'):
4383 if not update and opts.get('no_commit'):
4383 raise util.Abort(_('cannot use --no-commit with --bypass'))
4384 raise error.Abort(_('cannot use --no-commit with --bypass'))
4384 try:
4385 try:
4385 sim = float(opts.get('similarity') or 0)
4386 sim = float(opts.get('similarity') or 0)
4386 except ValueError:
4387 except ValueError:
4387 raise util.Abort(_('similarity must be a number'))
4388 raise error.Abort(_('similarity must be a number'))
4388 if sim < 0 or sim > 100:
4389 if sim < 0 or sim > 100:
4389 raise util.Abort(_('similarity must be between 0 and 100'))
4390 raise error.Abort(_('similarity must be between 0 and 100'))
4390 if sim and not update:
4391 if sim and not update:
4391 raise util.Abort(_('cannot use --similarity with --bypass'))
4392 raise error.Abort(_('cannot use --similarity with --bypass'))
4392 if opts.get('exact') and opts.get('edit'):
4393 if opts.get('exact') and opts.get('edit'):
4393 raise util.Abort(_('cannot use --exact with --edit'))
4394 raise error.Abort(_('cannot use --exact with --edit'))
4394 if opts.get('exact') and opts.get('prefix'):
4395 if opts.get('exact') and opts.get('prefix'):
4395 raise util.Abort(_('cannot use --exact with --prefix'))
4396 raise error.Abort(_('cannot use --exact with --prefix'))
4396
4397
4397 if update:
4398 if update:
4398 cmdutil.checkunfinished(repo)
4399 cmdutil.checkunfinished(repo)
@@ -4444,7 +4445,7 b' def import_(ui, repo, patch1=None, *patc'
4444 break
4445 break
4445
4446
4446 if not haspatch:
4447 if not haspatch:
4447 raise util.Abort(_('%s: no diffs found') % patchurl)
4448 raise error.Abort(_('%s: no diffs found') % patchurl)
4448
4449
4449 if tr:
4450 if tr:
4450 tr.close()
4451 tr.close()
@@ -4540,7 +4541,7 b' def incoming(ui, repo, source="default",'
4540 return 0
4541 return 0
4541
4542
4542 if opts.get('bundle') and opts.get('subrepos'):
4543 if opts.get('bundle') and opts.get('subrepos'):
4543 raise util.Abort(_('cannot combine --bundle and --subrepos'))
4544 raise error.Abort(_('cannot combine --bundle and --subrepos'))
4544
4545
4545 if opts.get('bookmarks'):
4546 if opts.get('bookmarks'):
4546 source, branches = hg.parseurl(ui.expandpath(source),
4547 source, branches = hg.parseurl(ui.expandpath(source),
@@ -4806,7 +4807,7 b' def manifest(ui, repo, node=None, rev=No'
4806
4807
4807 if opts.get('all'):
4808 if opts.get('all'):
4808 if rev or node:
4809 if rev or node:
4809 raise util.Abort(_("can't specify a revision with --all"))
4810 raise error.Abort(_("can't specify a revision with --all"))
4810
4811
4811 res = []
4812 res = []
4812 prefix = "data/"
4813 prefix = "data/"
@@ -4827,7 +4828,7 b' def manifest(ui, repo, node=None, rev=No'
4827 return
4828 return
4828
4829
4829 if rev and node:
4830 if rev and node:
4830 raise util.Abort(_("please specify just one revision"))
4831 raise error.Abort(_("please specify just one revision"))
4831
4832
4832 if not node:
4833 if not node:
4833 node = rev
4834 node = rev
@@ -4882,7 +4883,7 b' def merge(ui, repo, node=None, **opts):'
4882 """
4883 """
4883
4884
4884 if opts.get('rev') and node:
4885 if opts.get('rev') and node:
4885 raise util.Abort(_("please specify just one revision"))
4886 raise error.Abort(_("please specify just one revision"))
4886 if not node:
4887 if not node:
4887 node = opts.get('rev')
4888 node = opts.get('rev')
4888
4889
@@ -5012,7 +5013,7 b' def parents(ui, repo, file_=None, **opts'
5012 if file_:
5013 if file_:
5013 m = scmutil.match(ctx, (file_,), opts)
5014 m = scmutil.match(ctx, (file_,), opts)
5014 if m.anypats() or len(m.files()) != 1:
5015 if m.anypats() or len(m.files()) != 1:
5015 raise util.Abort(_('can only specify an explicit filename'))
5016 raise error.Abort(_('can only specify an explicit filename'))
5016 file_ = m.files()[0]
5017 file_ = m.files()[0]
5017 filenodes = []
5018 filenodes = []
5018 for cp in ctx.parents():
5019 for cp in ctx.parents():
@@ -5023,7 +5024,7 b' def parents(ui, repo, file_=None, **opts'
5023 except error.LookupError:
5024 except error.LookupError:
5024 pass
5025 pass
5025 if not filenodes:
5026 if not filenodes:
5026 raise util.Abort(_("'%s' not found in manifest!") % file_)
5027 raise error.Abort(_("'%s' not found in manifest!") % file_)
5027 p = []
5028 p = []
5028 for fn in filenodes:
5029 for fn in filenodes:
5029 fctx = repo.filectx(file_, fileid=fn)
5030 fctx = repo.filectx(file_, fileid=fn)
@@ -5112,7 +5113,7 b' def phase(ui, repo, *revs, **opts):'
5112 for idx, name in enumerate(phases.phasenames):
5113 for idx, name in enumerate(phases.phasenames):
5113 if opts[name]:
5114 if opts[name]:
5114 if targetphase is not None:
5115 if targetphase is not None:
5115 raise util.Abort(_('only one phase can be specified'))
5116 raise error.Abort(_('only one phase can be specified'))
5116 targetphase = idx
5117 targetphase = idx
5117
5118
5118 # look for specified revision
5119 # look for specified revision
@@ -5139,7 +5140,7 b' def phase(ui, repo, *revs, **opts):'
5139 tr = repo.transaction("phase")
5140 tr = repo.transaction("phase")
5140 # set phase
5141 # set phase
5141 if not revs:
5142 if not revs:
5142 raise util.Abort(_('empty revision set'))
5143 raise error.Abort(_('empty revision set'))
5143 nodes = [repo[r].node() for r in revs]
5144 nodes = [repo[r].node() for r in revs]
5144 # moving revision from public to draft may hide them
5145 # moving revision from public to draft may hide them
5145 # We have to check result on an unfiltered repository
5146 # We have to check result on an unfiltered repository
@@ -5181,7 +5182,7 b' def postincoming(ui, repo, modheads, opt'
5181 checkout, movemarkfrom = bookmarks.calculateupdate(ui, repo, checkout)
5182 checkout, movemarkfrom = bookmarks.calculateupdate(ui, repo, checkout)
5182 try:
5183 try:
5183 ret = hg.update(repo, checkout)
5184 ret = hg.update(repo, checkout)
5184 except util.Abort as inst:
5185 except error.Abort as inst:
5185 ui.warn(_("not updating: %s\n") % str(inst))
5186 ui.warn(_("not updating: %s\n") % str(inst))
5186 if inst.hint:
5187 if inst.hint:
5187 ui.warn(_("(%s)\n") % inst.hint)
5188 ui.warn(_("(%s)\n") % inst.hint)
@@ -5252,7 +5253,7 b' def pull(ui, repo, source="default", **o'
5252 pullopargs['remotebookmarks'] = remotebookmarks
5253 pullopargs['remotebookmarks'] = remotebookmarks
5253 for b in opts['bookmark']:
5254 for b in opts['bookmark']:
5254 if b not in remotebookmarks:
5255 if b not in remotebookmarks:
5255 raise util.Abort(_('remote bookmark %s not found!') % b)
5256 raise error.Abort(_('remote bookmark %s not found!') % b)
5256 revs.append(remotebookmarks[b])
5257 revs.append(remotebookmarks[b])
5257
5258
5258 if revs:
5259 if revs:
@@ -5270,7 +5271,7 b' def pull(ui, repo, source="default", **o'
5270 except error.CapabilityError:
5271 except error.CapabilityError:
5271 err = _("other repository doesn't support revision lookup, "
5272 err = _("other repository doesn't support revision lookup, "
5272 "so a rev cannot be specified.")
5273 "so a rev cannot be specified.")
5273 raise util.Abort(err)
5274 raise error.Abort(err)
5274
5275
5275 modheads = exchange.pull(repo, other, heads=revs,
5276 modheads = exchange.pull(repo, other, heads=revs,
5276 force=opts.get('force'),
5277 force=opts.get('force'),
@@ -5350,7 +5351,7 b' def push(ui, repo, dest=None, **opts):'
5350
5351
5351 path = ui.paths.getpath(dest, default='default')
5352 path = ui.paths.getpath(dest, default='default')
5352 if not path:
5353 if not path:
5353 raise util.Abort(_('default repository not configured!'),
5354 raise error.Abort(_('default repository not configured!'),
5354 hint=_('see the "path" section in "hg help config"'))
5355 hint=_('see the "path" section in "hg help config"'))
5355 dest, branches = path.pushloc, (path.branch, opts.get('branch') or [])
5356 dest, branches = path.pushloc, (path.branch, opts.get('branch') or [])
5356 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
5357 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
@@ -5360,7 +5361,7 b' def push(ui, repo, dest=None, **opts):'
5360 if revs:
5361 if revs:
5361 revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
5362 revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
5362 if not revs:
5363 if not revs:
5363 raise util.Abort(_("specified revisions evaluate to an empty set"),
5364 raise error.Abort(_("specified revisions evaluate to an empty set"),
5364 hint=_("use different revision arguments"))
5365 hint=_("use different revision arguments"))
5365
5366
5366 repo._subtoppath = dest
5367 repo._subtoppath = dest
@@ -5450,7 +5451,7 b' def remove(ui, repo, *pats, **opts):'
5450
5451
5451 after, force = opts.get('after'), opts.get('force')
5452 after, force = opts.get('after'), opts.get('force')
5452 if not pats and not after:
5453 if not pats and not after:
5453 raise util.Abort(_('no files specified'))
5454 raise error.Abort(_('no files specified'))
5454
5455
5455 m = scmutil.match(repo[None], pats, opts)
5456 m = scmutil.match(repo[None], pats, opts)
5456 subrepos = opts.get('subrepos')
5457 subrepos = opts.get('subrepos')
@@ -5534,11 +5535,11 b' def resolve(ui, repo, *pats, **opts):'
5534 [opts.get(o) for o in 'all mark unmark list no_status'.split()]
5535 [opts.get(o) for o in 'all mark unmark list no_status'.split()]
5535
5536
5536 if (show and (mark or unmark)) or (mark and unmark):
5537 if (show and (mark or unmark)) or (mark and unmark):
5537 raise util.Abort(_("too many options specified"))
5538 raise error.Abort(_("too many options specified"))
5538 if pats and all:
5539 if pats and all:
5539 raise util.Abort(_("can't specify --all and patterns"))
5540 raise error.Abort(_("can't specify --all and patterns"))
5540 if not (all or pats or show or mark or unmark):
5541 if not (all or pats or show or mark or unmark):
5541 raise util.Abort(_('no files or directories specified'),
5542 raise error.Abort(_('no files or directories specified'),
5542 hint=('use --all to re-merge all unresolved files'))
5543 hint=('use --all to re-merge all unresolved files'))
5543
5544
5544 if show:
5545 if show:
@@ -5560,7 +5561,7 b' def resolve(ui, repo, *pats, **opts):'
5560 ms = mergemod.mergestate(repo)
5561 ms = mergemod.mergestate(repo)
5561
5562
5562 if not (ms.active() or repo.dirstate.p2() != nullid):
5563 if not (ms.active() or repo.dirstate.p2() != nullid):
5563 raise util.Abort(
5564 raise error.Abort(
5564 _('resolve command not applicable when not merging'))
5565 _('resolve command not applicable when not merging'))
5565
5566
5566 m = scmutil.match(repo[None], pats, opts)
5567 m = scmutil.match(repo[None], pats, opts)
@@ -5656,13 +5657,13 b' def revert(ui, repo, *pats, **opts):'
5656
5657
5657 if opts.get("date"):
5658 if opts.get("date"):
5658 if opts.get("rev"):
5659 if opts.get("rev"):
5659 raise util.Abort(_("you can't specify a revision and a date"))
5660 raise error.Abort(_("you can't specify a revision and a date"))
5660 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
5661 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
5661
5662
5662 parent, p2 = repo.dirstate.parents()
5663 parent, p2 = repo.dirstate.parents()
5663 if not opts.get('rev') and p2 != nullid:
5664 if not opts.get('rev') and p2 != nullid:
5664 # revert after merge is a trap for new users (issue2915)
5665 # revert after merge is a trap for new users (issue2915)
5665 raise util.Abort(_('uncommitted merge with no revision specified'),
5666 raise error.Abort(_('uncommitted merge with no revision specified'),
5666 hint=_('use "hg update" or see "hg help revert"'))
5667 hint=_('use "hg update" or see "hg help revert"'))
5667
5668
5668 ctx = scmutil.revsingle(repo, opts.get('rev'))
5669 ctx = scmutil.revsingle(repo, opts.get('rev'))
@@ -5673,7 +5674,7 b' def revert(ui, repo, *pats, **opts):'
5673 if p2 != nullid:
5674 if p2 != nullid:
5674 hint = _("uncommitted merge, use --all to discard all changes,"
5675 hint = _("uncommitted merge, use --all to discard all changes,"
5675 " or 'hg update -C .' to abort the merge")
5676 " or 'hg update -C .' to abort the merge")
5676 raise util.Abort(msg, hint=hint)
5677 raise error.Abort(msg, hint=hint)
5677 dirty = any(repo.status())
5678 dirty = any(repo.status())
5678 node = ctx.node()
5679 node = ctx.node()
5679 if node != parent:
5680 if node != parent:
@@ -5687,7 +5688,7 b' def revert(ui, repo, *pats, **opts):'
5687 hint = _("uncommitted changes, use --all to discard all changes")
5688 hint = _("uncommitted changes, use --all to discard all changes")
5688 else:
5689 else:
5689 hint = _("use --all to revert all files")
5690 hint = _("use --all to revert all files")
5690 raise util.Abort(msg, hint=hint)
5691 raise error.Abort(msg, hint=hint)
5691
5692
5692 return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts)
5693 return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts)
5693
5694
@@ -5799,7 +5800,7 b' def serve(ui, repo, **opts):'
5799 """
5800 """
5800
5801
5801 if opts["stdio"] and opts["cmdserver"]:
5802 if opts["stdio"] and opts["cmdserver"]:
5802 raise util.Abort(_("cannot use --stdio with --cmdserver"))
5803 raise error.Abort(_("cannot use --stdio with --cmdserver"))
5803
5804
5804 if opts["stdio"]:
5805 if opts["stdio"]:
5805 if repo is None:
5806 if repo is None:
@@ -5968,7 +5969,7 b' def status(ui, repo, *pats, **opts):'
5968
5969
5969 if revs and change:
5970 if revs and change:
5970 msg = _('cannot specify --rev and --change at the same time')
5971 msg = _('cannot specify --rev and --change at the same time')
5971 raise util.Abort(msg)
5972 raise error.Abort(msg)
5972 elif change:
5973 elif change:
5973 node2 = scmutil.revsingle(repo, change, None).node()
5974 node2 = scmutil.revsingle(repo, change, None).node()
5974 node1 = repo[node2].p1().node()
5975 node1 = repo[node2].p1().node()
@@ -6320,14 +6321,14 b' def tag(ui, repo, name1, *names, **opts)'
6320 rev_ = "."
6321 rev_ = "."
6321 names = [t.strip() for t in (name1,) + names]
6322 names = [t.strip() for t in (name1,) + names]
6322 if len(names) != len(set(names)):
6323 if len(names) != len(set(names)):
6323 raise util.Abort(_('tag names must be unique'))
6324 raise error.Abort(_('tag names must be unique'))
6324 for n in names:
6325 for n in names:
6325 scmutil.checknewlabel(repo, n, 'tag')
6326 scmutil.checknewlabel(repo, n, 'tag')
6326 if not n:
6327 if not n:
6327 raise util.Abort(_('tag names cannot consist entirely of '
6328 raise error.Abort(_('tag names cannot consist entirely of '
6328 'whitespace'))
6329 'whitespace'))
6329 if opts.get('rev') and opts.get('remove'):
6330 if opts.get('rev') and opts.get('remove'):
6330 raise util.Abort(_("--rev and --remove are incompatible"))
6331 raise error.Abort(_("--rev and --remove are incompatible"))
6331 if opts.get('rev'):
6332 if opts.get('rev'):
6332 rev_ = opts['rev']
6333 rev_ = opts['rev']
6333 message = opts.get('message')
6334 message = opts.get('message')
@@ -6339,12 +6340,12 b' def tag(ui, repo, name1, *names, **opts)'
6339
6340
6340 for n in names:
6341 for n in names:
6341 if not repo.tagtype(n):
6342 if not repo.tagtype(n):
6342 raise util.Abort(_("tag '%s' does not exist") % n)
6343 raise error.Abort(_("tag '%s' does not exist") % n)
6343 if repo.tagtype(n) != expectedtype:
6344 if repo.tagtype(n) != expectedtype:
6344 if expectedtype == 'global':
6345 if expectedtype == 'global':
6345 raise util.Abort(_("tag '%s' is not a global tag") % n)
6346 raise error.Abort(_("tag '%s' is not a global tag") % n)
6346 else:
6347 else:
6347 raise util.Abort(_("tag '%s' is not a local tag") % n)
6348 raise error.Abort(_("tag '%s' is not a local tag") % n)
6348 rev_ = 'null'
6349 rev_ = 'null'
6349 if not message:
6350 if not message:
6350 # we don't translate commit messages
6351 # we don't translate commit messages
@@ -6352,15 +6353,15 b' def tag(ui, repo, name1, *names, **opts)'
6352 elif not opts.get('force'):
6353 elif not opts.get('force'):
6353 for n in names:
6354 for n in names:
6354 if n in repo.tags():
6355 if n in repo.tags():
6355 raise util.Abort(_("tag '%s' already exists "
6356 raise error.Abort(_("tag '%s' already exists "
6356 "(use -f to force)") % n)
6357 "(use -f to force)") % n)
6357 if not opts.get('local'):
6358 if not opts.get('local'):
6358 p1, p2 = repo.dirstate.parents()
6359 p1, p2 = repo.dirstate.parents()
6359 if p2 != nullid:
6360 if p2 != nullid:
6360 raise util.Abort(_('uncommitted merge'))
6361 raise error.Abort(_('uncommitted merge'))
6361 bheads = repo.branchheads()
6362 bheads = repo.branchheads()
6362 if not opts.get('force') and bheads and p1 not in bheads:
6363 if not opts.get('force') and bheads and p1 not in bheads:
6363 raise util.Abort(_('not at a branch head (use -f to force)'))
6364 raise error.Abort(_('not at a branch head (use -f to force)'))
6364 r = scmutil.revsingle(repo, rev_).node()
6365 r = scmutil.revsingle(repo, rev_).node()
6365
6366
6366 if not message:
6367 if not message:
@@ -6381,7 +6382,7 b' def tag(ui, repo, name1, *names, **opts)'
6381 # don't allow tagging the null rev
6382 # don't allow tagging the null rev
6382 if (not opts.get('remove') and
6383 if (not opts.get('remove') and
6383 scmutil.revsingle(repo, rev_).rev() == nullrev):
6384 scmutil.revsingle(repo, rev_).rev() == nullrev):
6384 raise util.Abort(_("cannot tag null revision"))
6385 raise error.Abort(_("cannot tag null revision"))
6385
6386
6386 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date,
6387 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date,
6387 editor=editor)
6388 editor=editor)
@@ -6470,7 +6471,7 b' def unbundle(ui, repo, fname1, *fnames, '
6470 op = bundle2.processbundle(repo, gen, lambda: tr)
6471 op = bundle2.processbundle(repo, gen, lambda: tr)
6471 tr.close()
6472 tr.close()
6472 except error.BundleUnknownFeatureError as exc:
6473 except error.BundleUnknownFeatureError as exc:
6473 raise util.Abort(_('%s: unknown bundle feature, %s')
6474 raise error.Abort(_('%s: unknown bundle feature, %s')
6474 % (fname, exc),
6475 % (fname, exc),
6475 hint=_("see https://mercurial-scm.org/"
6476 hint=_("see https://mercurial-scm.org/"
6476 "wiki/BundleFeature for more "
6477 "wiki/BundleFeature for more "
@@ -6549,7 +6550,7 b' def update(ui, repo, node=None, rev=None'
6549 Returns 0 on success, 1 if there are unresolved files.
6550 Returns 0 on success, 1 if there are unresolved files.
6550 """
6551 """
6551 if rev and node:
6552 if rev and node:
6552 raise util.Abort(_("please specify just one revision"))
6553 raise error.Abort(_("please specify just one revision"))
6553
6554
6554 if rev is None or rev == '':
6555 if rev is None or rev == '':
6555 rev = node
6556 rev = node
@@ -6560,7 +6561,7 b' def update(ui, repo, node=None, rev=None'
6560
6561
6561 if date:
6562 if date:
6562 if rev is not None:
6563 if rev is not None:
6563 raise util.Abort(_("you can't specify a revision and a date"))
6564 raise error.Abort(_("you can't specify a revision and a date"))
6564 rev = cmdutil.finddate(ui, repo, date)
6565 rev = cmdutil.finddate(ui, repo, date)
6565
6566
6566 # with no argument, we also move the active bookmark, if any
6567 # with no argument, we also move the active bookmark, if any
@@ -6571,7 +6572,8 b' def update(ui, repo, node=None, rev=None'
6571 rev = scmutil.revsingle(repo, rev, rev).rev()
6572 rev = scmutil.revsingle(repo, rev, rev).rev()
6572
6573
6573 if check and clean:
6574 if check and clean:
6574 raise util.Abort(_("cannot specify both -c/--check and -C/--clean"))
6575 raise error.Abort(_("cannot specify both -c/--check and -C/--clean")
6576 )
6575
6577
6576 if check:
6578 if check:
6577 cmdutil.bailifchanged(repo, merge=False)
6579 cmdutil.bailifchanged(repo, merge=False)
@@ -8,7 +8,7 b''
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
@@ -222,7 +222,7 b' class server(object):'
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
@@ -301,7 +301,7 b' class _requesthandler(SocketServer.Strea'
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:
@@ -323,9 +323,9 b' class unixservice(object):'
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):
@@ -351,4 +351,4 b' def createservice(ui, repo, opts):'
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)
@@ -1060,7 +1060,7 b' class filectx(basefilectx):'
1060 except error.CensoredNodeError:
1060 except error.CensoredNodeError:
1061 if self._repo.ui.config("censor", "policy", "abort") == "ignore":
1061 if self._repo.ui.config("censor", "policy", "abort") == "ignore":
1062 return ""
1062 return ""
1063 raise util.Abort(_("censored node: %s") % short(self._filenode),
1063 raise error.Abort(_("censored node: %s") % short(self._filenode),
1064 hint=_("set censor.policy to ignore errors"))
1064 hint=_("set censor.policy to ignore errors"))
1065
1065
1066 def size(self):
1066 def size(self):
@@ -1120,7 +1120,7 b' class committablectx(basectx):'
1120 try:
1120 try:
1121 branch = encoding.fromlocal(self._repo.dirstate.branch())
1121 branch = encoding.fromlocal(self._repo.dirstate.branch())
1122 except UnicodeDecodeError:
1122 except UnicodeDecodeError:
1123 raise util.Abort(_('branch name not in UTF-8!'))
1123 raise error.Abort(_('branch name not in UTF-8!'))
1124 self._extra['branch'] = branch
1124 self._extra['branch'] = branch
1125 if self._extra['branch'] == '':
1125 if self._extra['branch'] == '':
1126 self._extra['branch'] = 'default'
1126 self._extra['branch'] = 'default'
@@ -22,8 +22,8 b' import tempfile'
22 from .i18n import _
22 from .i18n import _
23 from . import (
23 from . import (
24 encoding,
24 encoding,
25 error,
25 patch as patchmod,
26 patch as patchmod,
26 util,
27 )
27 )
28
28
29 # This is required for ncurses to display non-ASCII characters in default user
29 # This is required for ncurses to display non-ASCII characters in default user
@@ -47,7 +47,7 b' try:'
47 curses
47 curses
48 except NameError:
48 except NameError:
49 if os.name != 'nt': # Temporary hack to get running on Windows again
49 if os.name != 'nt': # Temporary hack to get running on Windows again
50 raise util.Abort(
50 raise error.Abort(
51 _('the python curses/wcurses module is not available/installed'))
51 _('the python curses/wcurses module is not available/installed'))
52
52
53 _origstdout = sys.__stdout__ # used by gethw()
53 _origstdout = sys.__stdout__ # used by gethw()
@@ -498,7 +498,7 b' def chunkselector(ui, headerlist):'
498 f = signal.getsignal(signal.SIGTSTP)
498 f = signal.getsignal(signal.SIGTSTP)
499 curses.wrapper(chunkselector.main)
499 curses.wrapper(chunkselector.main)
500 if chunkselector.initerr is not None:
500 if chunkselector.initerr is not None:
501 raise util.Abort(chunkselector.initerr)
501 raise error.Abort(chunkselector.initerr)
502 # ncurses does not restore signal handler for SIGTSTP
502 # ncurses does not restore signal handler for SIGTSTP
503 signal.signal(signal.SIGTSTP, f)
503 signal.signal(signal.SIGTSTP, f)
504
504
@@ -1566,7 +1566,7 b' are you sure you want to review/edit and'
1566 elif keypressed in ["H", "KEY_SLEFT"]:
1566 elif keypressed in ["H", "KEY_SLEFT"]:
1567 self.leftarrowshiftevent()
1567 self.leftarrowshiftevent()
1568 elif keypressed in ["q"]:
1568 elif keypressed in ["q"]:
1569 raise util.Abort(_('user quit'))
1569 raise error.Abort(_('user quit'))
1570 elif keypressed in ["c"]:
1570 elif keypressed in ["c"]:
1571 if self.confirmcommit():
1571 if self.confirmcommit():
1572 return True
1572 return True
@@ -11,7 +11,7 b' import re'
11 import string
11 import string
12
12
13 from .i18n import _
13 from .i18n import _
14 from . import util
14 from . import error
15
15
16 def parsedag(desc):
16 def parsedag(desc):
17 '''parses a DAG from a concise textual description; generates events
17 '''parses a DAG from a concise textual description; generates events
@@ -269,7 +269,7 b' def parsedag(desc):'
269 s += c
269 s += c
270 i += 1
270 i += 1
271 c = nextch()
271 c = nextch()
272 raise util.Abort(_('invalid character in dag description: '
272 raise error.Abort(_('invalid character in dag description: '
273 '%s...') % s)
273 '%s...') % s)
274
274
275 def dagtextlines(events,
275 def dagtextlines(events,
@@ -298,13 +298,13 b' def dagtextlines(events,'
298
298
299 # sanity check
299 # sanity check
300 if r != wantr:
300 if r != wantr:
301 raise util.Abort(_("expected id %i, got %i") % (wantr, r))
301 raise error.Abort(_("expected id %i, got %i") % (wantr, r))
302 if not ps:
302 if not ps:
303 ps = [-1]
303 ps = [-1]
304 else:
304 else:
305 for p in ps:
305 for p in ps:
306 if p >= r:
306 if p >= r:
307 raise util.Abort(_("parent id %i is larger than "
307 raise error.Abort(_("parent id %i is larger than "
308 "current id %i") % (p, r))
308 "current id %i") % (p, r))
309 wantr += 1
309 wantr += 1
310
310
@@ -366,7 +366,7 b' def dagtextlines(events,'
366 yield '#' + data
366 yield '#' + data
367 yield '\n'
367 yield '\n'
368 else:
368 else:
369 raise util.Abort(_("invalid event type in dag: %s")
369 raise error.Abort(_("invalid event type in dag: %s")
370 % str((type, data)))
370 % str((type, data)))
371 if run:
371 if run:
372 yield '+' + str(run)
372 yield '+' + str(run)
@@ -8,7 +8,6 b''
8 from .i18n import _
8 from .i18n import _
9 from . import (
9 from . import (
10 error,
10 error,
11 util,
12 obsolete,
11 obsolete,
13 )
12 )
14
13
@@ -26,7 +25,7 b' def destupdate(repo):'
26 if wc.branch() == 'default': # no default branch!
25 if wc.branch() == 'default': # no default branch!
27 node = repo.lookup('tip') # update to tip
26 node = repo.lookup('tip') # update to tip
28 else:
27 else:
29 raise util.Abort(_("branch %s not found") % wc.branch())
28 raise error.Abort(_("branch %s not found") % wc.branch())
30
29
31 if p1.obsolete() and not p1.children():
30 if p1.obsolete() and not p1.children():
32 # allow updating to successors
31 # allow updating to successors
@@ -7,7 +7,7 b''
7
7
8 from node import nullid
8 from node import nullid
9 from i18n import _
9 from i18n import _
10 import scmutil, util, osutil, parsers, encoding, pathutil
10 import scmutil, util, osutil, parsers, encoding, pathutil, error
11 import os, stat, errno
11 import os, stat, errno
12 import match as matchmod
12 import match as matchmod
13
13
@@ -134,7 +134,7 b' class dirstate(object):'
134 if l == 40:
134 if l == 40:
135 return st[:20], st[20:40]
135 return st[:20], st[20:40]
136 elif l > 0 and l < 40:
136 elif l > 0 and l < 40:
137 raise util.Abort(_('working directory state appears damaged!'))
137 raise error.Abort(_('working directory state appears damaged!'))
138 except IOError as err:
138 except IOError as err:
139 if err.errno != errno.ENOENT:
139 if err.errno != errno.ENOENT:
140 raise
140 raise
@@ -412,13 +412,13 b' class dirstate(object):'
412 if state == 'a' or oldstate == 'r':
412 if state == 'a' or oldstate == 'r':
413 scmutil.checkfilename(f)
413 scmutil.checkfilename(f)
414 if f in self._dirs:
414 if f in self._dirs:
415 raise util.Abort(_('directory %r already in dirstate') % f)
415 raise error.Abort(_('directory %r already in dirstate') % f)
416 # shadows
416 # shadows
417 for d in util.finddirs(f):
417 for d in util.finddirs(f):
418 if d in self._dirs:
418 if d in self._dirs:
419 break
419 break
420 if d in self._map and self[d] != 'r':
420 if d in self._map and self[d] != 'r':
421 raise util.Abort(
421 raise error.Abort(
422 _('file %r in dirstate clashes with %r') % (d, f))
422 _('file %r in dirstate clashes with %r') % (d, f))
423 if oldstate in "?r" and "_dirs" in self.__dict__:
423 if oldstate in "?r" and "_dirs" in self.__dict__:
424 self._dirs.addpath(f)
424 self._dirs.addpath(f)
@@ -464,7 +464,7 b' class dirstate(object):'
464 def otherparent(self, f):
464 def otherparent(self, f):
465 '''Mark as coming from the other parent, always dirty.'''
465 '''Mark as coming from the other parent, always dirty.'''
466 if self._pl[1] == nullid:
466 if self._pl[1] == nullid:
467 raise util.Abort(_("setting %r to other parent "
467 raise error.Abort(_("setting %r to other parent "
468 "only allowed in merges") % f)
468 "only allowed in merges") % f)
469 if f in self and self[f] == 'n':
469 if f in self and self[f] == 'n':
470 # merge-like
470 # merge-like
@@ -16,6 +16,7 b' from .node import ('
16 from . import (
16 from . import (
17 bookmarks,
17 bookmarks,
18 branchmap,
18 branchmap,
19 error,
19 obsolete,
20 obsolete,
20 phases,
21 phases,
21 setdiscovery,
22 setdiscovery,
@@ -262,7 +263,7 b' def checkheads(repo, remote, outgoing, r'
262 # 1. Check for new branches on the remote.
263 # 1. Check for new branches on the remote.
263 if newbranches and not newbranch: # new branch requires --new-branch
264 if newbranches and not newbranch: # new branch requires --new-branch
264 branchnames = ', '.join(sorted(newbranches))
265 branchnames = ', '.join(sorted(newbranches))
265 raise util.Abort(_("push creates new remote branches: %s!")
266 raise error.Abort(_("push creates new remote branches: %s!")
266 % branchnames,
267 % branchnames,
267 hint=_("use 'hg push --new-branch' to create"
268 hint=_("use 'hg push --new-branch' to create"
268 " new remote branches"))
269 " new remote branches"))
@@ -390,4 +391,4 b' def checkheads(repo, remote, outgoing, r'
390 for h in dhs:
391 for h in dhs:
391 repo.ui.note((" %s\n") % short(h))
392 repo.ui.note((" %s\n") % short(h))
392 if errormsg:
393 if errormsg:
393 raise util.Abort(errormsg, hint=hint)
394 raise error.Abort(errormsg, hint=hint)
@@ -100,7 +100,7 b' def dispatch(req):'
100 req.ui.fout = req.fout
100 req.ui.fout = req.fout
101 if req.ferr:
101 if req.ferr:
102 req.ui.ferr = req.ferr
102 req.ui.ferr = req.ferr
103 except util.Abort as inst:
103 except error.Abort as inst:
104 ferr.write(_("abort: %s\n") % inst)
104 ferr.write(_("abort: %s\n") % inst)
105 if inst.hint:
105 if inst.hint:
106 ferr.write(_("(%s)\n") % inst.hint)
106 ferr.write(_("(%s)\n") % inst.hint)
@@ -253,7 +253,7 b' def _runcatch(req):'
253 # check if the command is in a disabled extension
253 # check if the command is in a disabled extension
254 # (but don't check for extensions themselves)
254 # (but don't check for extensions themselves)
255 commands.help_(ui, inst.args[0], unknowncmd=True)
255 commands.help_(ui, inst.args[0], unknowncmd=True)
256 except (error.UnknownCommand, util.Abort):
256 except (error.UnknownCommand, error.Abort):
257 suggested = False
257 suggested = False
258 if len(inst.args) == 2:
258 if len(inst.args) == 2:
259 sim = _getsimilar(inst.args[1], inst.args[0])
259 sim = _getsimilar(inst.args[1], inst.args[0])
@@ -266,7 +266,7 b' def _runcatch(req):'
266 except error.InterventionRequired as inst:
266 except error.InterventionRequired as inst:
267 ui.warn("%s\n" % inst)
267 ui.warn("%s\n" % inst)
268 return 1
268 return 1
269 except util.Abort as inst:
269 except error.Abort as inst:
270 ui.warn(_("abort: %s\n") % inst)
270 ui.warn(_("abort: %s\n") % inst)
271 if inst.hint:
271 if inst.hint:
272 ui.warn(_("(%s)\n") % inst.hint)
272 ui.warn(_("(%s)\n") % inst.hint)
@@ -398,7 +398,7 b' def aliasargs(fn, givenargs):'
398 nums.append(num)
398 nums.append(num)
399 if num < len(givenargs):
399 if num < len(givenargs):
400 return givenargs[num]
400 return givenargs[num]
401 raise util.Abort(_('too few arguments for command alias'))
401 raise error.Abort(_('too few arguments for command alias'))
402 cmd = re.sub(r'\$(\d+|\$)', replacer, cmd)
402 cmd = re.sub(r'\$(\d+|\$)', replacer, cmd)
403 givenargs = [x for i, x in enumerate(givenargs)
403 givenargs = [x for i, x in enumerate(givenargs)
404 if i not in nums]
404 if i not in nums]
@@ -525,7 +525,7 b' class cmdalias(object):'
525 hint = _("'%s' is provided by '%s' extension") % (cmd, ext)
525 hint = _("'%s' is provided by '%s' extension") % (cmd, ext)
526 except error.UnknownCommand:
526 except error.UnknownCommand:
527 pass
527 pass
528 raise util.Abort(self.badalias, hint=hint)
528 raise error.Abort(self.badalias, hint=hint)
529 if self.shadows:
529 if self.shadows:
530 ui.debug("alias '%s' shadows command '%s'\n" %
530 ui.debug("alias '%s' shadows command '%s'\n" %
531 (self.name, self.cmdname))
531 (self.name, self.cmdname))
@@ -614,7 +614,7 b' def _parseconfig(ui, config):'
614 ui.setconfig(section, name, value, '--config')
614 ui.setconfig(section, name, value, '--config')
615 configs.append((section, name, value))
615 configs.append((section, name, value))
616 except (IndexError, ValueError):
616 except (IndexError, ValueError):
617 raise util.Abort(_('malformed --config option: %r '
617 raise error.Abort(_('malformed --config option: %r '
618 '(use --config section.name=value)') % cfg)
618 '(use --config section.name=value)') % cfg)
619
619
620 return configs
620 return configs
@@ -690,7 +690,7 b' def _getlocal(ui, rpath):'
690 try:
690 try:
691 wd = os.getcwd()
691 wd = os.getcwd()
692 except OSError as e:
692 except OSError as e:
693 raise util.Abort(_("error getting current working directory: %s") %
693 raise error.Abort(_("error getting current working directory: %s") %
694 e.strerror)
694 e.strerror)
695 path = cmdutil.findrepo(wd) or ""
695 path = cmdutil.findrepo(wd) or ""
696 if not path:
696 if not path:
@@ -813,11 +813,11 b' def _dispatch(req):'
813 cmd, func, args, options, cmdoptions = _parse(lui, args)
813 cmd, func, args, options, cmdoptions = _parse(lui, args)
814
814
815 if options["config"]:
815 if options["config"]:
816 raise util.Abort(_("option --config may not be abbreviated!"))
816 raise error.Abort(_("option --config may not be abbreviated!"))
817 if options["cwd"]:
817 if options["cwd"]:
818 raise util.Abort(_("option --cwd may not be abbreviated!"))
818 raise error.Abort(_("option --cwd may not be abbreviated!"))
819 if options["repository"]:
819 if options["repository"]:
820 raise util.Abort(_(
820 raise error.Abort(_(
821 "option -R has to be separated from other options (e.g. not -qR) "
821 "option -R has to be separated from other options (e.g. not -qR) "
822 "and --repository may only be abbreviated as --repo!"))
822 "and --repository may only be abbreviated as --repo!"))
823
823
@@ -884,7 +884,7 b' def _dispatch(req):'
884 try:
884 try:
885 repo = hg.repository(ui, path=path)
885 repo = hg.repository(ui, path=path)
886 if not repo.local():
886 if not repo.local():
887 raise util.Abort(_("repository '%s' is not local") % path)
887 raise error.Abort(_("repository '%s' is not local") % path)
888 repo.ui.setconfig("bundle", "mainreporoot", repo.root, 'repo')
888 repo.ui.setconfig("bundle", "mainreporoot", repo.root, 'repo')
889 except error.RequirementError:
889 except error.RequirementError:
890 raise
890 raise
@@ -936,7 +936,7 b' def lsprofile(ui, func, fp):'
936 try:
936 try:
937 from . import lsprof
937 from . import lsprof
938 except ImportError:
938 except ImportError:
939 raise util.Abort(_(
939 raise error.Abort(_(
940 'lsprof not available - install from '
940 'lsprof not available - install from '
941 'http://codespeak.net/svn/user/arigo/hack/misc/lsprof/'))
941 'http://codespeak.net/svn/user/arigo/hack/misc/lsprof/'))
942 p = lsprof.Profiler()
942 p = lsprof.Profiler()
@@ -960,7 +960,7 b' def flameprofile(ui, func, fp):'
960 try:
960 try:
961 from flamegraph import flamegraph
961 from flamegraph import flamegraph
962 except ImportError:
962 except ImportError:
963 raise util.Abort(_(
963 raise error.Abort(_(
964 'flamegraph not available - install from '
964 'flamegraph not available - install from '
965 'https://github.com/evanhempel/python-flamegraph'))
965 'https://github.com/evanhempel/python-flamegraph'))
966 # developer config: profiling.freq
966 # developer config: profiling.freq
@@ -985,7 +985,7 b' def statprofile(ui, func, fp):'
985 try:
985 try:
986 import statprof
986 import statprof
987 except ImportError:
987 except ImportError:
988 raise util.Abort(_(
988 raise error.Abort(_(
989 'statprof not available - install using "easy_install statprof"'))
989 'statprof not available - install using "easy_install statprof"'))
990
990
991 freq = ui.configint('profiling', 'freq', default=1000)
991 freq = ui.configint('profiling', 'freq', default=1000)
@@ -30,7 +30,7 b' def readbundle(ui, fh, fname, vfs=None):'
30 magic, version = header[0:2], header[2:4]
30 magic, version = header[0:2], header[2:4]
31
31
32 if magic != 'HG':
32 if magic != 'HG':
33 raise util.Abort(_('%s: not a Mercurial bundle') % fname)
33 raise error.Abort(_('%s: not a Mercurial bundle') % fname)
34 if version == '10':
34 if version == '10':
35 if alg is None:
35 if alg is None:
36 alg = changegroup.readexactly(fh, 2)
36 alg = changegroup.readexactly(fh, 2)
@@ -38,7 +38,7 b' def readbundle(ui, fh, fname, vfs=None):'
38 elif version.startswith('2'):
38 elif version.startswith('2'):
39 return bundle2.getunbundler(ui, fh, magicstring=magic + version)
39 return bundle2.getunbundler(ui, fh, magicstring=magic + version)
40 else:
40 else:
41 raise util.Abort(_('%s: unknown bundle version %s') % (fname, version))
41 raise error.Abort(_('%s: unknown bundle version %s') % (fname, version))
42
42
43 def buildobsmarkerspart(bundler, markers):
43 def buildobsmarkerspart(bundler, markers):
44 """add an obsmarker part to the bundler with <markers>
44 """add an obsmarker part to the bundler with <markers>
@@ -193,7 +193,7 b' def push(repo, remote, force=False, revs'
193 msg = _("required features are not"
193 msg = _("required features are not"
194 " supported in the destination:"
194 " supported in the destination:"
195 " %s") % (', '.join(sorted(missing)))
195 " %s") % (', '.join(sorted(missing)))
196 raise util.Abort(msg)
196 raise error.Abort(msg)
197
197
198 # there are two ways to push to remote repo:
198 # there are two ways to push to remote repo:
199 #
199 #
@@ -204,7 +204,7 b' def push(repo, remote, force=False, revs'
204 # servers, http servers).
204 # servers, http servers).
205
205
206 if not pushop.remote.canpush():
206 if not pushop.remote.canpush():
207 raise util.Abort(_("destination does not support push"))
207 raise error.Abort(_("destination does not support push"))
208 # get local lock as we might write phase data
208 # get local lock as we might write phase data
209 localwlock = locallock = None
209 localwlock = locallock = None
210 try:
210 try:
@@ -435,9 +435,9 b' def _pushcheckoutgoing(pushop):'
435 for node in outgoing.missingheads:
435 for node in outgoing.missingheads:
436 ctx = unfi[node]
436 ctx = unfi[node]
437 if ctx.obsolete():
437 if ctx.obsolete():
438 raise util.Abort(mso % ctx)
438 raise error.Abort(mso % ctx)
439 elif ctx.troubled():
439 elif ctx.troubled():
440 raise util.Abort(mst[ctx.troubles()[0]] % ctx)
440 raise error.Abort(mst[ctx.troubles()[0]] % ctx)
441
441
442 # internal config: bookmarks.pushing
442 # internal config: bookmarks.pushing
443 newbm = pushop.ui.configlist('bookmarks', 'pushing')
443 newbm = pushop.ui.configlist('bookmarks', 'pushing')
@@ -658,14 +658,14 b' def _pushbundle2(pushop):'
658 try:
658 try:
659 reply = pushop.remote.unbundle(stream, ['force'], 'push')
659 reply = pushop.remote.unbundle(stream, ['force'], 'push')
660 except error.BundleValueError as exc:
660 except error.BundleValueError as exc:
661 raise util.Abort('missing support for %s' % exc)
661 raise error.Abort('missing support for %s' % exc)
662 try:
662 try:
663 trgetter = None
663 trgetter = None
664 if pushback:
664 if pushback:
665 trgetter = pushop.trmanager.transaction
665 trgetter = pushop.trmanager.transaction
666 op = bundle2.processbundle(pushop.repo, reply, trgetter)
666 op = bundle2.processbundle(pushop.repo, reply, trgetter)
667 except error.BundleValueError as exc:
667 except error.BundleValueError as exc:
668 raise util.Abort('missing support for %s' % exc)
668 raise error.Abort('missing support for %s' % exc)
669 except error.PushkeyFailed as exc:
669 except error.PushkeyFailed as exc:
670 partid = int(exc.partid)
670 partid = int(exc.partid)
671 if partid not in pushop.pkfailcb:
671 if partid not in pushop.pkfailcb:
@@ -967,7 +967,7 b' def pull(repo, remote, heads=None, force'
967 msg = _("required features are not"
967 msg = _("required features are not"
968 " supported in the destination:"
968 " supported in the destination:"
969 " %s") % (', '.join(sorted(missing)))
969 " %s") % (', '.join(sorted(missing)))
970 raise util.Abort(msg)
970 raise error.Abort(msg)
971
971
972 lock = pullop.repo.lock()
972 lock = pullop.repo.lock()
973 try:
973 try:
@@ -1108,7 +1108,7 b' def _pullbundle2(pullop):'
1108 try:
1108 try:
1109 op = bundle2.processbundle(pullop.repo, bundle, pullop.gettransaction)
1109 op = bundle2.processbundle(pullop.repo, bundle, pullop.gettransaction)
1110 except error.BundleValueError as exc:
1110 except error.BundleValueError as exc:
1111 raise util.Abort('missing support for %s' % exc)
1111 raise error.Abort('missing support for %s' % exc)
1112
1112
1113 if pullop.fetch:
1113 if pullop.fetch:
1114 results = [cg['return'] for cg in op.records['changegroup']]
1114 results = [cg['return'] for cg in op.records['changegroup']]
@@ -1158,7 +1158,7 b' def _pullchangeset(pullop):'
1158 elif pullop.heads is None:
1158 elif pullop.heads is None:
1159 cg = pullop.remote.changegroup(pullop.fetch, 'pull')
1159 cg = pullop.remote.changegroup(pullop.fetch, 'pull')
1160 elif not pullop.remote.capable('changegroupsubset'):
1160 elif not pullop.remote.capable('changegroupsubset'):
1161 raise util.Abort(_("partial pull cannot be done because "
1161 raise error.Abort(_("partial pull cannot be done because "
1162 "other repository doesn't support "
1162 "other repository doesn't support "
1163 "changegroupsubset."))
1163 "changegroupsubset."))
1164 else:
1164 else:
@@ -10,7 +10,7 b' from __future__ import absolute_import'
10 import getopt
10 import getopt
11
11
12 from .i18n import _
12 from .i18n import _
13 from . import util
13 from . import error
14
14
15 def gnugetopt(args, options, longoptions):
15 def gnugetopt(args, options, longoptions):
16 """Parse options mostly like getopt.gnu_getopt.
16 """Parse options mostly like getopt.gnu_getopt.
@@ -114,7 +114,7 b' def fancyopts(args, options, state, gnu='
114 try:
114 try:
115 state[name] = int(val)
115 state[name] = int(val)
116 except ValueError:
116 except ValueError:
117 raise util.Abort(_('invalid value %r for option %s, '
117 raise error.Abort(_('invalid value %r for option %s, '
118 'expected int') % (val, opt))
118 'expected int') % (val, opt))
119 elif t is type(''):
119 elif t is type(''):
120 state[name] = val
120 state[name] = val
@@ -363,7 +363,7 b' def encoding(mctx, x):'
363 try:
363 try:
364 d.decode(enc)
364 d.decode(enc)
365 except LookupError:
365 except LookupError:
366 raise util.Abort(_("unknown encoding '%s'") % enc)
366 raise error.Abort(_("unknown encoding '%s'") % enc)
367 except UnicodeDecodeError:
367 except UnicodeDecodeError:
368 continue
368 continue
369 s.append(f)
369 s.append(f)
@@ -18,8 +18,8 b' from .node import ('
18
18
19 from . import (
19 from . import (
20 encoding,
20 encoding,
21 error,
21 templater,
22 templater,
22 util,
23 )
23 )
24
24
25 class baseformatter(object):
25 class baseformatter(object):
@@ -179,7 +179,7 b' def lookuptemplate(ui, topic, tmpl):'
179
179
180 if tmpl == 'list':
180 if tmpl == 'list':
181 ui.write(_("available styles: %s\n") % templater.stylelist())
181 ui.write(_("available styles: %s\n") % templater.stylelist())
182 raise util.Abort(_("specify a template"))
182 raise error.Abort(_("specify a template"))
183
183
184 # perhaps it's a path to a map or a template
184 # perhaps it's a path to a map or a template
185 if ('/' in tmpl or '\\' in tmpl) and os.path.isfile(tmpl):
185 if ('/' in tmpl or '\\' in tmpl) and os.path.isfile(tmpl):
@@ -20,7 +20,6 b' from .node import ('
20 )
20 )
21 from . import (
21 from . import (
22 error,
22 error,
23 util,
24 )
23 )
25
24
26 def bisect(changelog, state):
25 def bisect(changelog, state):
@@ -74,8 +73,8 b' def bisect(changelog, state):'
74 if not ancestors: # now we're confused
73 if not ancestors: # now we're confused
75 if (len(state['bad']) == 1 and len(state['good']) == 1 and
74 if (len(state['bad']) == 1 and len(state['good']) == 1 and
76 state['bad'] != state['good']):
75 state['bad'] != state['good']):
77 raise util.Abort(_("starting revisions are not directly related"))
76 raise error.Abort(_("starting revisions are not directly related"))
78 raise util.Abort(_("inconsistent state, %s:%s is good and bad")
77 raise error.Abort(_("inconsistent state, %s:%s is good and bad")
79 % (badrev, short(bad)))
78 % (badrev, short(bad)))
80
79
81 # build children dict
80 # build children dict
@@ -149,7 +148,7 b' def load_state(repo):'
149 kind, node = l[:-1].split()
148 kind, node = l[:-1].split()
150 node = repo.lookup(node)
149 node = repo.lookup(node)
151 if kind not in state:
150 if kind not in state:
152 raise util.Abort(_("unknown bisect kind %s") % kind)
151 raise error.Abort(_("unknown bisect kind %s") % kind)
153 state[kind].append(node)
152 state[kind].append(node)
154 return state
153 return state
155
154
@@ -502,7 +502,7 b' def help_(ui, name, unknowncmd=False, fu'
502 if not rst:
502 if not rst:
503 msg = _('no matches')
503 msg = _('no matches')
504 hint = _('try "hg help" for a list of topics')
504 hint = _('try "hg help" for a list of topics')
505 raise util.Abort(msg, hint=hint)
505 raise error.Abort(msg, hint=hint)
506 elif name and name != 'shortlist':
506 elif name and name != 'shortlist':
507 queries = []
507 queries = []
508 if unknowncmd:
508 if unknowncmd:
@@ -525,7 +525,7 b' def help_(ui, name, unknowncmd=False, fu'
525 else:
525 else:
526 msg = _('no such help topic: %s') % name
526 msg = _('no such help topic: %s') % name
527 hint = _('try "hg help --keyword %s"') % name
527 hint = _('try "hg help --keyword %s"') % name
528 raise util.Abort(msg, hint=hint)
528 raise error.Abort(msg, hint=hint)
529 else:
529 else:
530 # program name
530 # program name
531 if not ui.quiet:
531 if not ui.quiet:
@@ -65,7 +65,7 b' def addbranchrevs(lrepo, other, branches'
65
65
66 if not peer.capable('branchmap'):
66 if not peer.capable('branchmap'):
67 if branches:
67 if branches:
68 raise util.Abort(_("remote branch lookup not supported"))
68 raise error.Abort(_("remote branch lookup not supported"))
69 revs.append(hashbranch)
69 revs.append(hashbranch)
70 return revs, revs[0]
70 return revs, revs[0]
71 branchmap = peer.branchmap()
71 branchmap = peer.branchmap()
@@ -73,7 +73,7 b' def addbranchrevs(lrepo, other, branches'
73 def primary(branch):
73 def primary(branch):
74 if branch == '.':
74 if branch == '.':
75 if not lrepo:
75 if not lrepo:
76 raise util.Abort(_("dirstate branch not accessible"))
76 raise error.Abort(_("dirstate branch not accessible"))
77 branch = lrepo.dirstate.branch()
77 branch = lrepo.dirstate.branch()
78 if branch in branchmap:
78 if branch in branchmap:
79 revs.extend(node.hex(r) for r in reversed(branchmap[branch]))
79 revs.extend(node.hex(r) for r in reversed(branchmap[branch]))
@@ -160,7 +160,7 b" def repository(ui, path='', create=False"
160 peer = _peerorrepo(ui, path, create)
160 peer = _peerorrepo(ui, path, create)
161 repo = peer.local()
161 repo = peer.local()
162 if not repo:
162 if not repo:
163 raise util.Abort(_("repository '%s' is not local") %
163 raise error.Abort(_("repository '%s' is not local") %
164 (path or peer.url()))
164 (path or peer.url()))
165 return repo.filtered('visible')
165 return repo.filtered('visible')
166
166
@@ -194,7 +194,7 b' def share(ui, source, dest=None, update='
194 '''create a shared repository'''
194 '''create a shared repository'''
195
195
196 if not islocal(source):
196 if not islocal(source):
197 raise util.Abort(_('can only share local repositories'))
197 raise error.Abort(_('can only share local repositories'))
198
198
199 if not dest:
199 if not dest:
200 dest = defaultdest(source)
200 dest = defaultdest(source)
@@ -217,7 +217,7 b' def share(ui, source, dest=None, update='
217 destvfs = scmutil.vfs(os.path.join(destwvfs.base, '.hg'), realpath=True)
217 destvfs = scmutil.vfs(os.path.join(destwvfs.base, '.hg'), realpath=True)
218
218
219 if destvfs.lexists():
219 if destvfs.lexists():
220 raise util.Abort(_('destination already exists'))
220 raise error.Abort(_('destination already exists'))
221
221
222 if not destwvfs.isdir():
222 if not destwvfs.isdir():
223 destwvfs.mkdir()
223 destwvfs.mkdir()
@@ -320,7 +320,7 b' def clonewithshare(ui, peeropts, sharepa'
320 revs = None
320 revs = None
321 if rev:
321 if rev:
322 if not srcpeer.capable('lookup'):
322 if not srcpeer.capable('lookup'):
323 raise util.Abort(_("src repository does not support "
323 raise error.Abort(_("src repository does not support "
324 "revision lookup and so doesn't "
324 "revision lookup and so doesn't "
325 "support clone by revision"))
325 "support clone by revision"))
326 revs = [srcpeer.lookup(r) for r in rev]
326 revs = [srcpeer.lookup(r) for r in rev]
@@ -416,14 +416,14 b' def clone(ui, peeropts, source, dest=Non'
416 source = util.urllocalpath(source)
416 source = util.urllocalpath(source)
417
417
418 if not dest:
418 if not dest:
419 raise util.Abort(_("empty destination path is not valid"))
419 raise error.Abort(_("empty destination path is not valid"))
420
420
421 destvfs = scmutil.vfs(dest, expandpath=True)
421 destvfs = scmutil.vfs(dest, expandpath=True)
422 if destvfs.lexists():
422 if destvfs.lexists():
423 if not destvfs.isdir():
423 if not destvfs.isdir():
424 raise util.Abort(_("destination '%s' already exists") % dest)
424 raise error.Abort(_("destination '%s' already exists") % dest)
425 elif destvfs.listdir():
425 elif destvfs.listdir():
426 raise util.Abort(_("destination '%s' is not empty") % dest)
426 raise error.Abort(_("destination '%s' is not empty") % dest)
427
427
428 shareopts = shareopts or {}
428 shareopts = shareopts or {}
429 sharepool = shareopts.get('pool')
429 sharepool = shareopts.get('pool')
@@ -448,7 +448,7 b' def clone(ui, peeropts, source, dest=Non'
448 elif sharenamemode == 'remote':
448 elif sharenamemode == 'remote':
449 sharepath = os.path.join(sharepool, util.sha1(source).hexdigest())
449 sharepath = os.path.join(sharepool, util.sha1(source).hexdigest())
450 else:
450 else:
451 raise util.Abort('unknown share naming mode: %s' % sharenamemode)
451 raise error.Abort('unknown share naming mode: %s' % sharenamemode)
452
452
453 if sharepath:
453 if sharepath:
454 return clonewithshare(ui, peeropts, sharepath, source, srcpeer,
454 return clonewithshare(ui, peeropts, sharepath, source, srcpeer,
@@ -494,7 +494,7 b' def clone(ui, peeropts, source, dest=Non'
494 except OSError as inst:
494 except OSError as inst:
495 if inst.errno == errno.EEXIST:
495 if inst.errno == errno.EEXIST:
496 cleandir = None
496 cleandir = None
497 raise util.Abort(_("destination '%s' already exists")
497 raise error.Abort(_("destination '%s' already exists")
498 % dest)
498 % dest)
499 raise
499 raise
500
500
@@ -534,14 +534,14 b' def clone(ui, peeropts, source, dest=Non'
534 except OSError as inst:
534 except OSError as inst:
535 if inst.errno == errno.EEXIST:
535 if inst.errno == errno.EEXIST:
536 cleandir = None
536 cleandir = None
537 raise util.Abort(_("destination '%s' already exists")
537 raise error.Abort(_("destination '%s' already exists")
538 % dest)
538 % dest)
539 raise
539 raise
540
540
541 revs = None
541 revs = None
542 if rev:
542 if rev:
543 if not srcpeer.capable('lookup'):
543 if not srcpeer.capable('lookup'):
544 raise util.Abort(_("src repository does not support "
544 raise error.Abort(_("src repository does not support "
545 "revision lookup and so doesn't "
545 "revision lookup and so doesn't "
546 "support clone by revision"))
546 "support clone by revision"))
547 revs = [srcpeer.lookup(r) for r in rev]
547 revs = [srcpeer.lookup(r) for r in rev]
@@ -557,7 +557,8 b' def clone(ui, peeropts, source, dest=Non'
557 exchange.push(srcrepo, destpeer, revs=revs,
557 exchange.push(srcrepo, destpeer, revs=revs,
558 bookmarks=srcrepo._bookmarks.keys())
558 bookmarks=srcrepo._bookmarks.keys())
559 else:
559 else:
560 raise util.Abort(_("clone from remote to remote not supported"))
560 raise error.Abort(_("clone from remote to remote not supported")
561 )
561
562
562 cleandir = None
563 cleandir = None
563
564
@@ -118,7 +118,7 b' class hgwebdir(object):'
118 if not isinstance(self.conf, (dict, list, tuple)):
118 if not isinstance(self.conf, (dict, list, tuple)):
119 map = {'paths': 'hgweb-paths'}
119 map = {'paths': 'hgweb-paths'}
120 if not os.path.exists(self.conf):
120 if not os.path.exists(self.conf):
121 raise util.Abort(_('config file %s not found!') % self.conf)
121 raise error.Abort(_('config file %s not found!') % self.conf)
122 u.readconfig(self.conf, remap=map, trust=True)
122 u.readconfig(self.conf, remap=map, trust=True)
123 paths = []
123 paths = []
124 for name, ignored in u.configitems('hgweb-paths'):
124 for name, ignored in u.configitems('hgweb-paths'):
@@ -208,7 +208,7 b' class _httprequesthandleropenssl(_httpre'
208 import OpenSSL
208 import OpenSSL
209 OpenSSL.SSL.Context
209 OpenSSL.SSL.Context
210 except ImportError:
210 except ImportError:
211 raise util.Abort(_("SSL support is unavailable"))
211 raise error.Abort(_("SSL support is unavailable"))
212 ctx = OpenSSL.SSL.Context(OpenSSL.SSL.TLSv1_METHOD)
212 ctx = OpenSSL.SSL.Context(OpenSSL.SSL.TLSv1_METHOD)
213 ctx.use_privatekey_file(ssl_cert)
213 ctx.use_privatekey_file(ssl_cert)
214 ctx.use_certificate_file(ssl_cert)
214 ctx.use_certificate_file(ssl_cert)
@@ -249,7 +249,7 b' class _httprequesthandlerssl(_httpreques'
249 import ssl
249 import ssl
250 ssl.wrap_socket
250 ssl.wrap_socket
251 except ImportError:
251 except ImportError:
252 raise util.Abort(_("SSL support is unavailable"))
252 raise error.Abort(_("SSL support is unavailable"))
253 httpserver.socket = ssl.wrap_socket(
253 httpserver.socket = ssl.wrap_socket(
254 httpserver.socket, server_side=True,
254 httpserver.socket, server_side=True,
255 certfile=ssl_cert, ssl_version=ssl.PROTOCOL_TLSv1)
255 certfile=ssl_cert, ssl_version=ssl.PROTOCOL_TLSv1)
@@ -345,5 +345,5 b' def create_server(ui, app):'
345 try:
345 try:
346 return cls(ui, app, (address, port), handler)
346 return cls(ui, app, (address, port), handler)
347 except socket.error as inst:
347 except socket.error as inst:
348 raise util.Abort(_("cannot start server at '%s:%d': %s")
348 raise error.Abort(_("cannot start server at '%s:%d': %s")
349 % (address, port, inst.args[1]))
349 % (address, port, inst.args[1]))
@@ -35,7 +35,7 b' def _pythonhook(ui, repo, name, hname, f'
35 else:
35 else:
36 d = funcname.rfind('.')
36 d = funcname.rfind('.')
37 if d == -1:
37 if d == -1:
38 raise util.Abort(_('%s hook is invalid ("%s" not in '
38 raise error.Abort(_('%s hook is invalid ("%s" not in '
39 'a module)') % (hname, funcname))
39 'a module)') % (hname, funcname))
40 modname = funcname[:d]
40 modname = funcname[:d]
41 oldpaths = sys.path
41 oldpaths = sys.path
@@ -63,7 +63,7 b' def _pythonhook(ui, repo, name, hname, f'
63 ui.warn(_('exception from second failed import '
63 ui.warn(_('exception from second failed import '
64 'attempt:\n'))
64 'attempt:\n'))
65 ui.traceback(e2)
65 ui.traceback(e2)
66 raise util.Abort(_('%s hook is invalid '
66 raise error.Abort(_('%s hook is invalid '
67 '(import of "%s" failed)') %
67 '(import of "%s" failed)') %
68 (hname, modname))
68 (hname, modname))
69 sys.path = oldpaths
69 sys.path = oldpaths
@@ -71,11 +71,11 b' def _pythonhook(ui, repo, name, hname, f'
71 for p in funcname.split('.')[1:]:
71 for p in funcname.split('.')[1:]:
72 obj = getattr(obj, p)
72 obj = getattr(obj, p)
73 except AttributeError:
73 except AttributeError:
74 raise util.Abort(_('%s hook is invalid '
74 raise error.Abort(_('%s hook is invalid '
75 '("%s" is not defined)') %
75 '("%s" is not defined)') %
76 (hname, funcname))
76 (hname, funcname))
77 if not callable(obj):
77 if not callable(obj):
78 raise util.Abort(_('%s hook is invalid '
78 raise error.Abort(_('%s hook is invalid '
79 '("%s" is not callable)') %
79 '("%s" is not callable)') %
80 (hname, funcname))
80 (hname, funcname))
81
81
@@ -91,7 +91,7 b' def _pythonhook(ui, repo, name, hname, f'
91
91
92 r = obj(ui=ui, repo=repo, hooktype=name, **args)
92 r = obj(ui=ui, repo=repo, hooktype=name, **args)
93 except Exception as exc:
93 except Exception as exc:
94 if isinstance(exc, util.Abort):
94 if isinstance(exc, error.Abort):
95 ui.warn(_('error: %s hook failed: %s\n') %
95 ui.warn(_('error: %s hook failed: %s\n') %
96 (hname, exc.args[0]))
96 (hname, exc.args[0]))
97 else:
97 else:
@@ -49,7 +49,7 b' class httppeer(wireproto.wirepeer):'
49 self.requestbuilder = None
49 self.requestbuilder = None
50 u = util.url(path)
50 u = util.url(path)
51 if u.query or u.fragment:
51 if u.query or u.fragment:
52 raise util.Abort(_('unsupported URL component: "%s"') %
52 raise error.Abort(_('unsupported URL component: "%s"') %
53 (u.query or u.fragment))
53 (u.query or u.fragment))
54
54
55 # urllib cannot handle URLs with embedded user or passwd
55 # urllib cannot handle URLs with embedded user or passwd
@@ -86,7 +86,7 b' class httppeer(wireproto.wirepeer):'
86 return self.caps
86 return self.caps
87
87
88 def lock(self):
88 def lock(self):
89 raise util.Abort(_('operation not supported over http'))
89 raise error.Abort(_('operation not supported over http'))
90
90
91 def _callstream(self, cmd, **args):
91 def _callstream(self, cmd, **args):
92 if cmd == 'pushkey':
92 if cmd == 'pushkey':
@@ -137,7 +137,7 b' class httppeer(wireproto.wirepeer):'
137 resp = self.urlopener.open(req)
137 resp = self.urlopener.open(req)
138 except urllib2.HTTPError as inst:
138 except urllib2.HTTPError as inst:
139 if inst.code == 401:
139 if inst.code == 401:
140 raise util.Abort(_('authorization failed'))
140 raise error.Abort(_('authorization failed'))
141 raise
141 raise
142 except httplib.HTTPException as inst:
142 except httplib.HTTPException as inst:
143 self.ui.debug('http error while sending %s command\n' % cmd)
143 self.ui.debug('http error while sending %s command\n' % cmd)
@@ -145,7 +145,7 b' class httppeer(wireproto.wirepeer):'
145 raise IOError(None, inst)
145 raise IOError(None, inst)
146 except IndexError:
146 except IndexError:
147 # this only happens with Python 2.3, later versions raise URLError
147 # this only happens with Python 2.3, later versions raise URLError
148 raise util.Abort(_('http error, possibly caused by proxy setting'))
148 raise error.Abort(_('http error, possibly caused by proxy setting'))
149 # record the url we got redirected to
149 # record the url we got redirected to
150 resp_url = resp.geturl()
150 resp_url = resp.geturl()
151 if resp_url.endswith(qs):
151 if resp_url.endswith(qs):
@@ -223,8 +223,8 b' class httppeer(wireproto.wirepeer):'
223 return vals
223 return vals
224 except socket.error as err:
224 except socket.error as err:
225 if err.args[0] in (errno.ECONNRESET, errno.EPIPE):
225 if err.args[0] in (errno.ECONNRESET, errno.EPIPE):
226 raise util.Abort(_('push failed: %s') % err.args[1])
226 raise error.Abort(_('push failed: %s') % err.args[1])
227 raise util.Abort(err.args[1])
227 raise error.Abort(err.args[1])
228 finally:
228 finally:
229 fp.close()
229 fp.close()
230 os.unlink(tempname)
230 os.unlink(tempname)
@@ -263,13 +263,13 b' class httppeer(wireproto.wirepeer):'
263 class httpspeer(httppeer):
263 class httpspeer(httppeer):
264 def __init__(self, ui, path):
264 def __init__(self, ui, path):
265 if not url.has_https:
265 if not url.has_https:
266 raise util.Abort(_('Python support for SSL and HTTPS '
266 raise error.Abort(_('Python support for SSL and HTTPS '
267 'is not installed'))
267 'is not installed'))
268 httppeer.__init__(self, ui, path)
268 httppeer.__init__(self, ui, path)
269
269
270 def instance(ui, path, create):
270 def instance(ui, path, create):
271 if create:
271 if create:
272 raise util.Abort(_('cannot create new http repository'))
272 raise error.Abort(_('cannot create new http repository'))
273 try:
273 try:
274 if path.startswith('https:'):
274 if path.startswith('https:'):
275 inst = httpspeer(ui, path)
275 inst = httpspeer(ui, path)
@@ -640,7 +640,7 b' class localrepository(object):'
640 if not local:
640 if not local:
641 m = matchmod.exact(self.root, '', ['.hgtags'])
641 m = matchmod.exact(self.root, '', ['.hgtags'])
642 if any(self.status(match=m, unknown=True, ignored=True)):
642 if any(self.status(match=m, unknown=True, ignored=True)):
643 raise util.Abort(_('working copy of .hgtags is changed'),
643 raise error.Abort(_('working copy of .hgtags is changed'),
644 hint=_('please commit .hgtags manually'))
644 hint=_('please commit .hgtags manually'))
645
645
646 self.tags() # instantiate the cache
646 self.tags() # instantiate the cache
@@ -1119,7 +1119,7 b' class localrepository(object):'
1119 desc = None
1119 desc = None
1120
1120
1121 if not force and self['.'] != self['tip'] and desc == 'commit':
1121 if not force and self['.'] != self['tip'] and desc == 'commit':
1122 raise util.Abort(
1122 raise error.Abort(
1123 _('rollback of last commit while not checked out '
1123 _('rollback of last commit while not checked out '
1124 'may lose data'), hint=_('use -f to force'))
1124 'may lose data'), hint=_('use -f to force'))
1125
1125
@@ -1433,7 +1433,7 b' class localrepository(object):'
1433 extra = {}
1433 extra = {}
1434
1434
1435 def fail(f, msg):
1435 def fail(f, msg):
1436 raise util.Abort('%s: %s' % (f, msg))
1436 raise error.Abort('%s: %s' % (f, msg))
1437
1437
1438 if not match:
1438 if not match:
1439 match = matchmod.always(self.root, '')
1439 match = matchmod.always(self.root, '')
@@ -1449,7 +1449,7 b' class localrepository(object):'
1449 merge = len(wctx.parents()) > 1
1449 merge = len(wctx.parents()) > 1
1450
1450
1451 if not force and merge and match.ispartial():
1451 if not force and merge and match.ispartial():
1452 raise util.Abort(_('cannot partially commit a merge '
1452 raise error.Abort(_('cannot partially commit a merge '
1453 '(do not specify files or patterns)'))
1453 '(do not specify files or patterns)'))
1454
1454
1455 status = self.status(match=match, clean=force)
1455 status = self.status(match=match, clean=force)
@@ -1477,12 +1477,12 b' class localrepository(object):'
1477 newstate[s] = oldstate[s]
1477 newstate[s] = oldstate[s]
1478 continue
1478 continue
1479 if not force:
1479 if not force:
1480 raise util.Abort(
1480 raise error.Abort(
1481 _("commit with new subrepo %s excluded") % s)
1481 _("commit with new subrepo %s excluded") % s)
1482 dirtyreason = wctx.sub(s).dirtyreason(True)
1482 dirtyreason = wctx.sub(s).dirtyreason(True)
1483 if dirtyreason:
1483 if dirtyreason:
1484 if not self.ui.configbool('ui', 'commitsubrepos'):
1484 if not self.ui.configbool('ui', 'commitsubrepos'):
1485 raise util.Abort(dirtyreason,
1485 raise error.Abort(dirtyreason,
1486 hint=_("use --subrepos for recursive commit"))
1486 hint=_("use --subrepos for recursive commit"))
1487 subs.append(s)
1487 subs.append(s)
1488 commitsubs.add(s)
1488 commitsubs.add(s)
@@ -1499,7 +1499,7 b' class localrepository(object):'
1499 if subs:
1499 if subs:
1500 if (not match('.hgsub') and
1500 if (not match('.hgsub') and
1501 '.hgsub' in (wctx.modified() + wctx.added())):
1501 '.hgsub' in (wctx.modified() + wctx.added())):
1502 raise util.Abort(
1502 raise error.Abort(
1503 _("can't commit subrepos without .hgsub"))
1503 _("can't commit subrepos without .hgsub"))
1504 status.modified.insert(0, '.hgsubstate')
1504 status.modified.insert(0, '.hgsubstate')
1505
1505
@@ -1541,12 +1541,12 b' class localrepository(object):'
1541 return None
1541 return None
1542
1542
1543 if merge and cctx.deleted():
1543 if merge and cctx.deleted():
1544 raise util.Abort(_("cannot commit merge with missing files"))
1544 raise error.Abort(_("cannot commit merge with missing files"))
1545
1545
1546 ms = mergemod.mergestate(self)
1546 ms = mergemod.mergestate(self)
1547 for f in status.modified:
1547 for f in status.modified:
1548 if f in ms and ms[f] == 'u':
1548 if f in ms and ms[f] == 'u':
1549 raise util.Abort(_('unresolved merge conflicts '
1549 raise error.Abort(_('unresolved merge conflicts '
1550 '(see "hg help resolve")'))
1550 '(see "hg help resolve")'))
1551
1551
1552 if editor:
1552 if editor:
@@ -18,6 +18,7 b' import time'
18 from .i18n import _
18 from .i18n import _
19 from . import (
19 from . import (
20 encoding,
20 encoding,
21 error,
21 sslutil,
22 sslutil,
22 util,
23 util,
23 )
24 )
@@ -93,7 +94,7 b" if util.safehasattr(smtplib.SMTP, '_get_"
93 return new_socket
94 return new_socket
94 else:
95 else:
95 def SMTPS(sslkwargs, keyfile=None, certfile=None, **kwargs):
96 def SMTPS(sslkwargs, keyfile=None, certfile=None, **kwargs):
96 raise util.Abort(_('SMTPS requires Python 2.6 or later'))
97 raise error.Abort(_('SMTPS requires Python 2.6 or later'))
97
98
98 def _smtp(ui):
99 def _smtp(ui):
99 '''build an smtp connection and return a function to send mail'''
100 '''build an smtp connection and return a function to send mail'''
@@ -103,14 +104,14 b' def _smtp(ui):'
103 starttls = tls == 'starttls' or util.parsebool(tls)
104 starttls = tls == 'starttls' or util.parsebool(tls)
104 smtps = tls == 'smtps'
105 smtps = tls == 'smtps'
105 if (starttls or smtps) and not util.safehasattr(socket, 'ssl'):
106 if (starttls or smtps) and not util.safehasattr(socket, 'ssl'):
106 raise util.Abort(_("can't use TLS: Python SSL support not installed"))
107 raise error.Abort(_("can't use TLS: Python SSL support not installed"))
107 mailhost = ui.config('smtp', 'host')
108 mailhost = ui.config('smtp', 'host')
108 if not mailhost:
109 if not mailhost:
109 raise util.Abort(_('smtp.host not configured - cannot send mail'))
110 raise error.Abort(_('smtp.host not configured - cannot send mail'))
110 verifycert = ui.config('smtp', 'verifycert', 'strict')
111 verifycert = ui.config('smtp', 'verifycert', 'strict')
111 if verifycert not in ['strict', 'loose']:
112 if verifycert not in ['strict', 'loose']:
112 if util.parsebool(verifycert) is not False:
113 if util.parsebool(verifycert) is not False:
113 raise util.Abort(_('invalid smtp.verifycert configuration: %s')
114 raise error.Abort(_('invalid smtp.verifycert configuration: %s')
114 % (verifycert))
115 % (verifycert))
115 verifycert = False
116 verifycert = False
116 if (starttls or smtps) and verifycert:
117 if (starttls or smtps) and verifycert:
@@ -151,16 +152,16 b' def _smtp(ui):'
151 try:
152 try:
152 s.login(username, password)
153 s.login(username, password)
153 except smtplib.SMTPException as inst:
154 except smtplib.SMTPException as inst:
154 raise util.Abort(inst)
155 raise error.Abort(inst)
155
156
156 def send(sender, recipients, msg):
157 def send(sender, recipients, msg):
157 try:
158 try:
158 return s.sendmail(sender, recipients, msg)
159 return s.sendmail(sender, recipients, msg)
159 except smtplib.SMTPRecipientsRefused as inst:
160 except smtplib.SMTPRecipientsRefused as inst:
160 recipients = [r[1] for r in inst.recipients.values()]
161 recipients = [r[1] for r in inst.recipients.values()]
161 raise util.Abort('\n' + '\n'.join(recipients))
162 raise error.Abort('\n' + '\n'.join(recipients))
162 except smtplib.SMTPException as inst:
163 except smtplib.SMTPException as inst:
163 raise util.Abort(inst)
164 raise error.Abort(inst)
164
165
165 return send
166 return send
166
167
@@ -174,7 +175,7 b' def _sendmail(ui, sender, recipients, ms'
174 fp.write(msg)
175 fp.write(msg)
175 ret = fp.close()
176 ret = fp.close()
176 if ret:
177 if ret:
177 raise util.Abort('%s %s' % (
178 raise error.Abort('%s %s' % (
178 os.path.basename(program.split(None, 1)[0]),
179 os.path.basename(program.split(None, 1)[0]),
179 util.explainexit(ret)[0]))
180 util.explainexit(ret)[0]))
180
181
@@ -208,11 +209,11 b' def validateconfig(ui):'
208 method = ui.config('email', 'method', 'smtp')
209 method = ui.config('email', 'method', 'smtp')
209 if method == 'smtp':
210 if method == 'smtp':
210 if not ui.config('smtp', 'host'):
211 if not ui.config('smtp', 'host'):
211 raise util.Abort(_('smtp specified as email transport, '
212 raise error.Abort(_('smtp specified as email transport, '
212 'but no smtp host configured'))
213 'but no smtp host configured'))
213 else:
214 else:
214 if not util.findexe(method):
215 if not util.findexe(method):
215 raise util.Abort(_('%r specified as email transport, '
216 raise error.Abort(_('%r specified as email transport, '
216 'but not in PATH') % method)
217 'but not in PATH') % method)
217
218
218 def mimetextpatch(s, subtype='plain', display=False):
219 def mimetextpatch(s, subtype='plain', display=False):
@@ -302,13 +303,13 b' def _addressencode(ui, name, addr, chars'
302 dom = dom.decode(encoding.encoding).encode('idna')
303 dom = dom.decode(encoding.encoding).encode('idna')
303 addr = '%s@%s' % (acc, dom)
304 addr = '%s@%s' % (acc, dom)
304 except UnicodeDecodeError:
305 except UnicodeDecodeError:
305 raise util.Abort(_('invalid email address: %s') % addr)
306 raise error.Abort(_('invalid email address: %s') % addr)
306 except ValueError:
307 except ValueError:
307 try:
308 try:
308 # too strict?
309 # too strict?
309 addr = addr.encode('ascii')
310 addr = addr.encode('ascii')
310 except UnicodeDecodeError:
311 except UnicodeDecodeError:
311 raise util.Abort(_('invalid local address: %s') % addr)
312 raise error.Abort(_('invalid local address: %s') % addr)
312 return email.Utils.formataddr((name, addr))
313 return email.Utils.formataddr((name, addr))
313
314
314 def addressencode(ui, address, charsets=None, display=False):
315 def addressencode(ui, address, charsets=None, display=False):
@@ -13,6 +13,7 b' import re'
13
13
14 from .i18n import _
14 from .i18n import _
15 from . import (
15 from . import (
16 error,
16 pathutil,
17 pathutil,
17 util,
18 util,
18 )
19 )
@@ -37,7 +38,7 b' def _expandsets(kindpats, ctx, listsubre'
37 for kind, pat, source in kindpats:
38 for kind, pat, source in kindpats:
38 if kind == 'set':
39 if kind == 'set':
39 if not ctx:
40 if not ctx:
40 raise util.Abort("fileset expression with no context")
41 raise error.Abort("fileset expression with no context")
41 s = ctx.getfileset(pat)
42 s = ctx.getfileset(pat)
42 fset.update(s)
43 fset.update(s)
43
44
@@ -290,7 +291,7 b' class match(object):'
290 files = files.splitlines()
291 files = files.splitlines()
291 files = [f for f in files if f]
292 files = [f for f in files if f]
292 except EnvironmentError:
293 except EnvironmentError:
293 raise util.Abort(_("unable to read file list (%s)") % pat)
294 raise error.Abort(_("unable to read file list (%s)") % pat)
294 for k, p, source in self._normalize(files, default, root, cwd,
295 for k, p, source in self._normalize(files, default, root, cwd,
295 auditor):
296 auditor):
296 kindpats.append((k, p, pat))
297 kindpats.append((k, p, pat))
@@ -302,8 +303,8 b' class match(object):'
302 for k, p, source in self._normalize(includepats, default,
303 for k, p, source in self._normalize(includepats, default,
303 root, cwd, auditor):
304 root, cwd, auditor):
304 kindpats.append((k, p, source or pat))
305 kindpats.append((k, p, source or pat))
305 except util.Abort as inst:
306 except error.Abort as inst:
306 raise util.Abort('%s: %s' % (pat, inst[0]))
307 raise error.Abort('%s: %s' % (pat, inst[0]))
307 except IOError as inst:
308 except IOError as inst:
308 if self._warn:
309 if self._warn:
309 self._warn(_("skipping unreadable pattern file "
310 self._warn(_("skipping unreadable pattern file "
@@ -587,11 +588,11 b' def _buildregexmatch(kindpats, globsuffi'
587 _rematcher('(?:%s)' % _regex(k, p, globsuffix))
588 _rematcher('(?:%s)' % _regex(k, p, globsuffix))
588 except re.error:
589 except re.error:
589 if s:
590 if s:
590 raise util.Abort(_("%s: invalid pattern (%s): %s") %
591 raise error.Abort(_("%s: invalid pattern (%s): %s") %
591 (s, k, p))
592 (s, k, p))
592 else:
593 else:
593 raise util.Abort(_("invalid pattern (%s): %s") % (k, p))
594 raise error.Abort(_("invalid pattern (%s): %s") % (k, p))
594 raise util.Abort(_("invalid pattern"))
595 raise error.Abort(_("invalid pattern"))
595
596
596 def _roots(kindpats):
597 def _roots(kindpats):
597 '''return roots and exact explicitly listed files from patterns
598 '''return roots and exact explicitly listed files from patterns
@@ -6,7 +6,7 b''
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 bdiff, mpatch, util, base85
9 import bdiff, mpatch, util, base85, error
10 import re, struct, zlib
10 import re, struct, zlib
11
11
12 def splitnewlines(text):
12 def splitnewlines(text):
@@ -59,7 +59,7 b' class diffopts(object):'
59 try:
59 try:
60 self.context = int(self.context)
60 self.context = int(self.context)
61 except ValueError:
61 except ValueError:
62 raise util.Abort(_('diff context lines count must be '
62 raise error.Abort(_('diff context lines count must be '
63 'an integer, not %r') % self.context)
63 'an integer, not %r') % self.context)
64
64
65 def copy(self, **kwargs):
65 def copy(self, **kwargs):
@@ -22,6 +22,7 b' from .node import ('
22 from . import (
22 from . import (
23 copies,
23 copies,
24 destutil,
24 destutil,
25 error,
25 filemerge,
26 filemerge,
26 obsolete,
27 obsolete,
27 subrepo,
28 subrepo,
@@ -98,7 +99,7 b' class mergestate(object):'
98 bits = record.split('\0')
99 bits = record.split('\0')
99 self._state[bits[0]] = bits[1:]
100 self._state[bits[0]] = bits[1:]
100 elif not rtype.islower():
101 elif not rtype.islower():
101 raise util.Abort(_('unsupported merge state record: %s')
102 raise error.Abort(_('unsupported merge state record: %s')
102 % rtype)
103 % rtype)
103 self._dirty = False
104 self._dirty = False
104
105
@@ -346,7 +347,7 b' def _checkunknownfiles(repo, wctx, mctx,'
346 for f in sorted(aborts):
347 for f in sorted(aborts):
347 repo.ui.warn(_("%s: untracked file differs\n") % f)
348 repo.ui.warn(_("%s: untracked file differs\n") % f)
348 if aborts:
349 if aborts:
349 raise util.Abort(_("untracked files in working directory differ "
350 raise error.Abort(_("untracked files in working directory differ "
350 "from files in requested revision"))
351 "from files in requested revision"))
351
352
352 for f, (m, args, msg) in actions.iteritems():
353 for f, (m, args, msg) in actions.iteritems():
@@ -419,7 +420,7 b' def _checkcollision(repo, wmf, actions):'
419 for f in sorted(pmmf):
420 for f in sorted(pmmf):
420 fold = util.normcase(f)
421 fold = util.normcase(f)
421 if fold in foldmap:
422 if fold in foldmap:
422 raise util.Abort(_("case-folding collision between %s and %s")
423 raise error.Abort(_("case-folding collision between %s and %s")
423 % (f, foldmap[fold]))
424 % (f, foldmap[fold]))
424 foldmap[fold] = f
425 foldmap[fold] = f
425
426
@@ -1011,18 +1012,18 b' def update(repo, node, branchmerge, forc'
1011
1012
1012 ### check phase
1013 ### check phase
1013 if not overwrite and len(pl) > 1:
1014 if not overwrite and len(pl) > 1:
1014 raise util.Abort(_("outstanding uncommitted merge"))
1015 raise error.Abort(_("outstanding uncommitted merge"))
1015 if branchmerge:
1016 if branchmerge:
1016 if pas == [p2]:
1017 if pas == [p2]:
1017 raise util.Abort(_("merging with a working directory ancestor"
1018 raise error.Abort(_("merging with a working directory ancestor"
1018 " has no effect"))
1019 " has no effect"))
1019 elif pas == [p1]:
1020 elif pas == [p1]:
1020 if not mergeancestor and p1.branch() == p2.branch():
1021 if not mergeancestor and p1.branch() == p2.branch():
1021 raise util.Abort(_("nothing to merge"),
1022 raise error.Abort(_("nothing to merge"),
1022 hint=_("use 'hg update' "
1023 hint=_("use 'hg update' "
1023 "or check 'hg heads'"))
1024 "or check 'hg heads'"))
1024 if not force and (wc.files() or wc.deleted()):
1025 if not force and (wc.files() or wc.deleted()):
1025 raise util.Abort(_("uncommitted changes"),
1026 raise error.Abort(_("uncommitted changes"),
1026 hint=_("use 'hg status' to list changes"))
1027 hint=_("use 'hg status' to list changes"))
1027 for s in sorted(wc.substate):
1028 for s in sorted(wc.substate):
1028 wc.sub(s).bailifchanged()
1029 wc.sub(s).bailifchanged()
@@ -1051,11 +1052,11 b' def update(repo, node, branchmerge, forc'
1051 else:
1052 else:
1052 hint = _("commit or update --clean to discard"
1053 hint = _("commit or update --clean to discard"
1053 " changes")
1054 " changes")
1054 raise util.Abort(msg, hint=hint)
1055 raise error.Abort(msg, hint=hint)
1055 else: # node is none
1056 else: # node is none
1056 msg = _("not a linear update")
1057 msg = _("not a linear update")
1057 hint = _("merge or update --check to force update")
1058 hint = _("merge or update --check to force update")
1058 raise util.Abort(msg, hint=hint)
1059 raise error.Abort(msg, hint=hint)
1059 else:
1060 else:
1060 # Allow jumping branches if clean and specific rev given
1061 # Allow jumping branches if clean and specific rev given
1061 pas = [p1]
1062 pas = [p1]
@@ -68,7 +68,7 b' comment associated with each format for '
68
68
69 """
69 """
70 import errno, struct
70 import errno, struct
71 import util, base85, node, parsers
71 import util, base85, node, parsers, error
72 import phases
72 import phases
73 from i18n import _
73 from i18n import _
74
74
@@ -164,7 +164,7 b' def _fm0readmarkers(data, off):'
164 # (metadata will be decoded on demand)
164 # (metadata will be decoded on demand)
165 metadata = data[off:off + mdsize]
165 metadata = data[off:off + mdsize]
166 if len(metadata) != mdsize:
166 if len(metadata) != mdsize:
167 raise util.Abort(_('parsing obsolete marker: metadata is too '
167 raise error.Abort(_('parsing obsolete marker: metadata is too '
168 'short, %d bytes expected, got %d')
168 'short, %d bytes expected, got %d')
169 % (mdsize, len(metadata)))
169 % (mdsize, len(metadata)))
170 off += mdsize
170 off += mdsize
@@ -200,7 +200,7 b' def _fm0readmarkers(data, off):'
200 def _fm0encodeonemarker(marker):
200 def _fm0encodeonemarker(marker):
201 pre, sucs, flags, metadata, date, parents = marker
201 pre, sucs, flags, metadata, date, parents = marker
202 if flags & usingsha256:
202 if flags & usingsha256:
203 raise util.Abort(_('cannot handle sha256 with old obsstore format'))
203 raise error.Abort(_('cannot handle sha256 with old obsstore format'))
204 metadata = dict(metadata)
204 metadata = dict(metadata)
205 time, tz = date
205 time, tz = date
206 metadata['date'] = '%r %i' % (time, tz)
206 metadata['date'] = '%r %i' % (time, tz)
@@ -414,7 +414,7 b' def _readmarkers(data):'
414 diskversion = _unpack('>B', data[off:off + 1])[0]
414 diskversion = _unpack('>B', data[off:off + 1])[0]
415 off += 1
415 off += 1
416 if diskversion not in formats:
416 if diskversion not in formats:
417 raise util.Abort(_('parsing obsolete marker: unknown version %r')
417 raise error.Abort(_('parsing obsolete marker: unknown version %r')
418 % diskversion)
418 % diskversion)
419 return diskversion, formats[diskversion][0](data, off)
419 return diskversion, formats[diskversion][0](data, off)
420
420
@@ -496,7 +496,7 b' def _checkinvalidmarkers(markers):'
496 """
496 """
497 for mark in markers:
497 for mark in markers:
498 if node.nullid in mark[1]:
498 if node.nullid in mark[1]:
499 raise util.Abort(_('bad obsolescence marker detected: '
499 raise error.Abort(_('bad obsolescence marker detected: '
500 'invalid successors nullid'))
500 'invalid successors nullid'))
501
501
502 class obsstore(object):
502 class obsstore(object):
@@ -583,8 +583,8 b' class obsstore(object):'
583 Take care of filtering duplicate.
583 Take care of filtering duplicate.
584 Return the number of new marker."""
584 Return the number of new marker."""
585 if self._readonly:
585 if self._readonly:
586 raise util.Abort('creating obsolete markers is not enabled on this '
586 raise error.Abort('creating obsolete markers is not enabled on '
587 'repo')
587 'this repo')
588 known = set(self._all)
588 known = set(self._all)
589 new = []
589 new = []
590 for m in markers:
590 for m in markers:
@@ -1217,7 +1217,7 b' def createmarkers(repo, relations, flag='
1217 localmetadata.update(rel[2])
1217 localmetadata.update(rel[2])
1218
1218
1219 if not prec.mutable():
1219 if not prec.mutable():
1220 raise util.Abort("cannot obsolete public changeset: %s"
1220 raise error.Abort("cannot obsolete public changeset: %s"
1221 % prec,
1221 % prec,
1222 hint='see "hg help phases" for details')
1222 hint='see "hg help phases" for details')
1223 nprec = prec.node()
1223 nprec = prec.node()
@@ -1226,7 +1226,7 b' def createmarkers(repo, relations, flag='
1226 if not nsucs:
1226 if not nsucs:
1227 npare = tuple(p.node() for p in prec.parents())
1227 npare = tuple(p.node() for p in prec.parents())
1228 if nprec in nsucs:
1228 if nprec in nsucs:
1229 raise util.Abort("changeset %s cannot obsolete itself" % prec)
1229 raise error.Abort("changeset %s cannot obsolete itself" % prec)
1230 repo.obsstore.create(tr, nprec, nsucs, flag, parents=npare,
1230 repo.obsstore.create(tr, nprec, nsucs, flag, parents=npare,
1231 date=date, metadata=localmetadata)
1231 date=date, metadata=localmetadata)
1232 repo.filteredrevcache.clear()
1232 repo.filteredrevcache.clear()
@@ -1250,7 +1250,7 b' def isenabled(repo, option):'
1250 # createmarkers must be enabled if other options are enabled
1250 # createmarkers must be enabled if other options are enabled
1251 if ((allowunstableopt in result or exchangeopt in result) and
1251 if ((allowunstableopt in result or exchangeopt in result) and
1252 not createmarkersopt in result):
1252 not createmarkersopt in result):
1253 raise util.Abort(_("'createmarkers' obsolete option must be enabled "
1253 raise error.Abort(_("'createmarkers' obsolete option must be enabled "
1254 "if other obsolete options are enabled"))
1254 "if other obsolete options are enabled"))
1255
1255
1256 return option in result
1256 return option in result
@@ -1056,7 +1056,7 b' the hunk is left unchanged.'
1056 elif r == 6: # all
1056 elif r == 6: # all
1057 ret = skipall = True
1057 ret = skipall = True
1058 elif r == 7: # quit
1058 elif r == 7: # quit
1059 raise util.Abort(_('user quit'))
1059 raise error.Abort(_('user quit'))
1060 return ret, skipfile, skipall, newpatches
1060 return ret, skipfile, skipall, newpatches
1061
1061
1062 seen = set()
1062 seen = set()
@@ -1964,7 +1964,7 b' def _applydiff(ui, fp, patcher, backend,'
1964 else:
1964 else:
1965 store.setfile(path, data, mode)
1965 store.setfile(path, data, mode)
1966 else:
1966 else:
1967 raise util.Abort(_('unsupported parser state: %s') % state)
1967 raise error.Abort(_('unsupported parser state: %s') % state)
1968
1968
1969 if current_file:
1969 if current_file:
1970 rejects += current_file.close()
1970 rejects += current_file.close()
@@ -2022,7 +2022,7 b' def patchbackend(ui, backend, patchobj, '
2022 if eolmode is None:
2022 if eolmode is None:
2023 eolmode = ui.config('patch', 'eol', 'strict')
2023 eolmode = ui.config('patch', 'eol', 'strict')
2024 if eolmode.lower() not in eolmodes:
2024 if eolmode.lower() not in eolmodes:
2025 raise util.Abort(_('unsupported line endings type: %s') % eolmode)
2025 raise error.Abort(_('unsupported line endings type: %s') % eolmode)
2026 eolmode = eolmode.lower()
2026 eolmode = eolmode.lower()
2027
2027
2028 store = filestore()
2028 store = filestore()
@@ -2095,7 +2095,7 b' def changedfiles(ui, repo, patchpath, st'
2095 if gp.op == 'RENAME':
2095 if gp.op == 'RENAME':
2096 changed.add(gp.oldpath)
2096 changed.add(gp.oldpath)
2097 elif state not in ('hunk', 'git'):
2097 elif state not in ('hunk', 'git'):
2098 raise util.Abort(_('unsupported parser state: %s') % state)
2098 raise error.Abort(_('unsupported parser state: %s') % state)
2099 return changed
2099 return changed
2100 finally:
2100 finally:
2101 fp.close()
2101 fp.close()
@@ -8,6 +8,7 b' import stat'
8 from .i18n import _
8 from .i18n import _
9 from . import (
9 from . import (
10 encoding,
10 encoding,
11 error,
11 util,
12 util,
12 )
13 )
13
14
@@ -47,18 +48,18 b' class pathauditor(object):'
47 return
48 return
48 # AIX ignores "/" at end of path, others raise EISDIR.
49 # AIX ignores "/" at end of path, others raise EISDIR.
49 if util.endswithsep(path):
50 if util.endswithsep(path):
50 raise util.Abort(_("path ends in directory separator: %s") % path)
51 raise error.Abort(_("path ends in directory separator: %s") % path)
51 parts = util.splitpath(path)
52 parts = util.splitpath(path)
52 if (os.path.splitdrive(path)[0]
53 if (os.path.splitdrive(path)[0]
53 or _lowerclean(parts[0]) in ('.hg', '.hg.', '')
54 or _lowerclean(parts[0]) in ('.hg', '.hg.', '')
54 or os.pardir in parts):
55 or os.pardir in parts):
55 raise util.Abort(_("path contains illegal component: %s") % path)
56 raise error.Abort(_("path contains illegal component: %s") % path)
56 # Windows shortname aliases
57 # Windows shortname aliases
57 for p in parts:
58 for p in parts:
58 if "~" in p:
59 if "~" in p:
59 first, last = p.split("~", 1)
60 first, last = p.split("~", 1)
60 if last.isdigit() and first.upper() in ["HG", "HG8B6C"]:
61 if last.isdigit() and first.upper() in ["HG", "HG8B6C"]:
61 raise util.Abort(_("path contains illegal component: %s")
62 raise error.Abort(_("path contains illegal component: %s")
62 % path)
63 % path)
63 if '.hg' in _lowerclean(path):
64 if '.hg' in _lowerclean(path):
64 lparts = [_lowerclean(p.lower()) for p in parts]
65 lparts = [_lowerclean(p.lower()) for p in parts]
@@ -66,7 +67,7 b' class pathauditor(object):'
66 if p in lparts[1:]:
67 if p in lparts[1:]:
67 pos = lparts.index(p)
68 pos = lparts.index(p)
68 base = os.path.join(*parts[:pos])
69 base = os.path.join(*parts[:pos])
69 raise util.Abort(_("path '%s' is inside nested repo %r")
70 raise error.Abort(_("path '%s' is inside nested repo %r")
70 % (path, base))
71 % (path, base))
71
72
72 normparts = util.splitpath(normpath)
73 normparts = util.splitpath(normpath)
@@ -90,13 +91,13 b' class pathauditor(object):'
90 raise
91 raise
91 else:
92 else:
92 if stat.S_ISLNK(st.st_mode):
93 if stat.S_ISLNK(st.st_mode):
93 raise util.Abort(
94 raise error.Abort(
94 _('path %r traverses symbolic link %r')
95 _('path %r traverses symbolic link %r')
95 % (path, prefix))
96 % (path, prefix))
96 elif (stat.S_ISDIR(st.st_mode) and
97 elif (stat.S_ISDIR(st.st_mode) and
97 os.path.isdir(os.path.join(curpath, '.hg'))):
98 os.path.isdir(os.path.join(curpath, '.hg'))):
98 if not self.callback or not self.callback(curpath):
99 if not self.callback or not self.callback(curpath):
99 raise util.Abort(_("path '%s' is inside nested "
100 raise error.Abort(_("path '%s' is inside nested "
100 "repo %r")
101 "repo %r")
101 % (path, prefix))
102 % (path, prefix))
102 prefixes.append(normprefix)
103 prefixes.append(normprefix)
@@ -112,7 +113,7 b' class pathauditor(object):'
112 try:
113 try:
113 self(path)
114 self(path)
114 return True
115 return True
115 except (OSError, util.Abort):
116 except (OSError, error.Abort):
116 return False
117 return False
117
118
118 def canonpath(root, cwd, myname, auditor=None):
119 def canonpath(root, cwd, myname, auditor=None):
@@ -167,10 +168,10 b' def canonpath(root, cwd, myname, auditor'
167 canonpath(root, root, myname, auditor)
168 canonpath(root, root, myname, auditor)
168 hint = (_("consider using '--cwd %s'")
169 hint = (_("consider using '--cwd %s'")
169 % os.path.relpath(root, cwd))
170 % os.path.relpath(root, cwd))
170 except util.Abort:
171 except error.Abort:
171 pass
172 pass
172
173
173 raise util.Abort(_("%s not under root '%s'") % (myname, root),
174 raise error.Abort(_("%s not under root '%s'") % (myname, root),
174 hint=hint)
175 hint=hint)
175
176
176 def normasprefix(path):
177 def normasprefix(path):
@@ -115,7 +115,6 b' from .node import ('
115 )
115 )
116 from . import (
116 from . import (
117 error,
117 error,
118 util,
119 )
118 )
120
119
121 allphases = public, draft, secret = range(3)
120 allphases = public, draft, secret = range(3)
@@ -306,7 +305,7 b' class phasecache(object):'
306 if self.phase(repo, repo[n].rev()) < targetphase]
305 if self.phase(repo, repo[n].rev()) < targetphase]
307 if newroots:
306 if newroots:
308 if nullid in newroots:
307 if nullid in newroots:
309 raise util.Abort(_('cannot change null revision phase'))
308 raise error.Abort(_('cannot change null revision phase'))
310 currentroots = currentroots.copy()
309 currentroots = currentroots.copy()
311 currentroots.update(newroots)
310 currentroots.update(newroots)
312 ctxs = repo.set('roots(%ln::)', currentroots)
311 ctxs = repo.set('roots(%ln::)', currentroots)
@@ -15,6 +15,7 b' from .node import short'
15 from . import (
15 from . import (
16 bundle2,
16 bundle2,
17 changegroup,
17 changegroup,
18 error,
18 exchange,
19 exchange,
19 util,
20 util,
20 )
21 )
@@ -156,7 +157,7 b' def strip(ui, repo, nodelist, backup=Tru'
156 if curtr is not None:
157 if curtr is not None:
157 del curtr # avoid carrying reference to transaction for nothing
158 del curtr # avoid carrying reference to transaction for nothing
158 msg = _('programming error: cannot strip from inside a transaction')
159 msg = _('programming error: cannot strip from inside a transaction')
159 raise util.Abort(msg, hint=_('contact your extension maintainer'))
160 raise error.Abort(msg, hint=_('contact your extension maintainer'))
160
161
161 tr = repo.transaction("strip")
162 tr = repo.transaction("strip")
162 offset = len(tr.entries)
163 offset = len(tr.entries)
@@ -480,11 +480,11 b' def _mergedefaultdest(repo, subset, x):'
480 else:
480 else:
481 node = bmheads[0]
481 node = bmheads[0]
482 elif len(bmheads) > 2:
482 elif len(bmheads) > 2:
483 raise util.Abort(_("multiple matching bookmarks to merge - "
483 raise error.Abort(_("multiple matching bookmarks to merge - "
484 "please merge with an explicit rev or bookmark"),
484 "please merge with an explicit rev or bookmark"),
485 hint=_("run 'hg heads' to see all heads"))
485 hint=_("run 'hg heads' to see all heads"))
486 elif len(bmheads) <= 1:
486 elif len(bmheads) <= 1:
487 raise util.Abort(_("no matching bookmark to merge - "
487 raise error.Abort(_("no matching bookmark to merge - "
488 "please merge with an explicit rev or bookmark"),
488 "please merge with an explicit rev or bookmark"),
489 hint=_("run 'hg heads' to see all heads"))
489 hint=_("run 'hg heads' to see all heads"))
490 else:
490 else:
@@ -493,7 +493,7 b' def _mergedefaultdest(repo, subset, x):'
493 nbhs = [bh for bh in bheads if not repo[bh].bookmarks()]
493 nbhs = [bh for bh in bheads if not repo[bh].bookmarks()]
494
494
495 if len(nbhs) > 2:
495 if len(nbhs) > 2:
496 raise util.Abort(_("branch '%s' has %d heads - "
496 raise error.Abort(_("branch '%s' has %d heads - "
497 "please merge with an explicit rev")
497 "please merge with an explicit rev")
498 % (branch, len(bheads)),
498 % (branch, len(bheads)),
499 hint=_("run 'hg heads .' to see heads"))
499 hint=_("run 'hg heads .' to see heads"))
@@ -501,21 +501,21 b' def _mergedefaultdest(repo, subset, x):'
501 parent = repo.dirstate.p1()
501 parent = repo.dirstate.p1()
502 if len(nbhs) <= 1:
502 if len(nbhs) <= 1:
503 if len(bheads) > 1:
503 if len(bheads) > 1:
504 raise util.Abort(_("heads are bookmarked - "
504 raise error.Abort(_("heads are bookmarked - "
505 "please merge with an explicit rev"),
505 "please merge with an explicit rev"),
506 hint=_("run 'hg heads' to see all heads"))
506 hint=_("run 'hg heads' to see all heads"))
507 if len(repo.heads()) > 1:
507 if len(repo.heads()) > 1:
508 raise util.Abort(_("branch '%s' has one head - "
508 raise error.Abort(_("branch '%s' has one head - "
509 "please merge with an explicit rev")
509 "please merge with an explicit rev")
510 % branch,
510 % branch,
511 hint=_("run 'hg heads' to see all heads"))
511 hint=_("run 'hg heads' to see all heads"))
512 msg, hint = _('nothing to merge'), None
512 msg, hint = _('nothing to merge'), None
513 if parent != repo.lookup(branch):
513 if parent != repo.lookup(branch):
514 hint = _("use 'hg update' instead")
514 hint = _("use 'hg update' instead")
515 raise util.Abort(msg, hint=hint)
515 raise error.Abort(msg, hint=hint)
516
516
517 if parent not in bheads:
517 if parent not in bheads:
518 raise util.Abort(_('working directory not at a head revision'),
518 raise error.Abort(_('working directory not at a head revision'),
519 hint=_("use 'hg update' or merge with an "
519 hint=_("use 'hg update' or merge with an "
520 "explicit revision"))
520 "explicit revision"))
521 if parent == nbhs[0]:
521 if parent == nbhs[0]:
@@ -721,7 +721,7 b' def bundle(repo, subset, x):'
721 try:
721 try:
722 bundlerevs = repo.changelog.bundlerevs
722 bundlerevs = repo.changelog.bundlerevs
723 except AttributeError:
723 except AttributeError:
724 raise util.Abort(_("no bundle provided - specify with -R"))
724 raise error.Abort(_("no bundle provided - specify with -R"))
725 return subset & bundlerevs
725 return subset & bundlerevs
726
726
727 def checkstatus(repo, subset, pat, field):
727 def checkstatus(repo, subset, pat, field):
@@ -2669,7 +2669,7 b' def _expandaliases(aliases, tree, expand'
2669 alias = _getalias(aliases, tree)
2669 alias = _getalias(aliases, tree)
2670 if alias is not None:
2670 if alias is not None:
2671 if alias.error:
2671 if alias.error:
2672 raise util.Abort(alias.error)
2672 raise error.Abort(alias.error)
2673 if alias in expanding:
2673 if alias in expanding:
2674 raise error.ParseError(_('infinite expansion of revset alias "%s" '
2674 raise error.ParseError(_('infinite expansion of revset alias "%s" '
2675 'detected') % alias.name)
2675 'detected') % alias.name)
@@ -2868,7 +2868,7 b' def formatspec(expr, *args):'
2868 ret += listexp(list(args[arg]), d)
2868 ret += listexp(list(args[arg]), d)
2869 arg += 1
2869 arg += 1
2870 else:
2870 else:
2871 raise util.Abort('unexpected revspec format character %s' % d)
2871 raise error.Abort('unexpected revspec format character %s' % d)
2872 else:
2872 else:
2873 ret += c
2873 ret += c
2874 pos += 1
2874 pos += 1
@@ -123,20 +123,20 b' def checknewlabel(repo, lbl, kind):'
123 # Do not use the "kind" parameter in ui output.
123 # Do not use the "kind" parameter in ui output.
124 # It makes strings difficult to translate.
124 # It makes strings difficult to translate.
125 if lbl in ['tip', '.', 'null']:
125 if lbl in ['tip', '.', 'null']:
126 raise util.Abort(_("the name '%s' is reserved") % lbl)
126 raise error.Abort(_("the name '%s' is reserved") % lbl)
127 for c in (':', '\0', '\n', '\r'):
127 for c in (':', '\0', '\n', '\r'):
128 if c in lbl:
128 if c in lbl:
129 raise util.Abort(_("%r cannot be used in a name") % c)
129 raise error.Abort(_("%r cannot be used in a name") % c)
130 try:
130 try:
131 int(lbl)
131 int(lbl)
132 raise util.Abort(_("cannot use an integer as a name"))
132 raise error.Abort(_("cannot use an integer as a name"))
133 except ValueError:
133 except ValueError:
134 pass
134 pass
135
135
136 def checkfilename(f):
136 def checkfilename(f):
137 '''Check that the filename f is an acceptable filename for a tracked file'''
137 '''Check that the filename f is an acceptable filename for a tracked file'''
138 if '\r' in f or '\n' in f:
138 if '\r' in f or '\n' in f:
139 raise util.Abort(_("'\\n' and '\\r' disallowed in filenames: %r") % f)
139 raise error.Abort(_("'\\n' and '\\r' disallowed in filenames: %r") % f)
140
140
141 def checkportable(ui, f):
141 def checkportable(ui, f):
142 '''Check if filename f is portable and warn or abort depending on config'''
142 '''Check if filename f is portable and warn or abort depending on config'''
@@ -147,7 +147,7 b' def checkportable(ui, f):'
147 if msg:
147 if msg:
148 msg = "%s: %r" % (msg, f)
148 msg = "%s: %r" % (msg, f)
149 if abort:
149 if abort:
150 raise util.Abort(msg)
150 raise error.Abort(msg)
151 ui.warn(_("warning: %s\n") % msg)
151 ui.warn(_("warning: %s\n") % msg)
152
152
153 def checkportabilityalert(ui):
153 def checkportabilityalert(ui):
@@ -182,7 +182,7 b' class casecollisionauditor(object):'
182 if fl in self._loweredfiles and f not in self._dirstate:
182 if fl in self._loweredfiles and f not in self._dirstate:
183 msg = _('possible case-folding collision for %s') % f
183 msg = _('possible case-folding collision for %s') % f
184 if self._abort:
184 if self._abort:
185 raise util.Abort(msg)
185 raise error.Abort(msg)
186 self._ui.warn(_("warning: %s\n") % msg)
186 self._ui.warn(_("warning: %s\n") % msg)
187 self._loweredfiles.add(fl)
187 self._loweredfiles.add(fl)
188 self._newfiles.add(f)
188 self._newfiles.add(f)
@@ -475,7 +475,7 b' class vfs(abstractvfs):'
475 if self._audit:
475 if self._audit:
476 r = util.checkosfilename(path)
476 r = util.checkosfilename(path)
477 if r:
477 if r:
478 raise util.Abort("%s: %r" % (r, path))
478 raise error.Abort("%s: %r" % (r, path))
479 self.audit(path)
479 self.audit(path)
480 f = self.join(path)
480 f = self.join(path)
481
481
@@ -583,7 +583,7 b' class readonlyvfs(abstractvfs, auditvfs)'
583
583
584 def __call__(self, path, mode='r', *args, **kw):
584 def __call__(self, path, mode='r', *args, **kw):
585 if mode not in ('r', 'rb'):
585 if mode not in ('r', 'rb'):
586 raise util.Abort('this vfs is read only')
586 raise error.Abort('this vfs is read only')
587 return self.vfs(path, mode, *args, **kw)
587 return self.vfs(path, mode, *args, **kw)
588
588
589 def join(self, path, *insidef):
589 def join(self, path, *insidef):
@@ -689,7 +689,7 b" def revsingle(repo, revspec, default='.'"
689
689
690 l = revrange(repo, [revspec])
690 l = revrange(repo, [revspec])
691 if not l:
691 if not l:
692 raise util.Abort(_('empty revision set'))
692 raise error.Abort(_('empty revision set'))
693 return repo[l.last()]
693 return repo[l.last()]
694
694
695 def _pairspec(revspec):
695 def _pairspec(revspec):
@@ -716,7 +716,7 b' def revpair(repo, revs):'
716 second = l.last()
716 second = l.last()
717
717
718 if first is None:
718 if first is None:
719 raise util.Abort(_('empty revision range'))
719 raise error.Abort(_('empty revision range'))
720
720
721 # if top-level is range expression, the result must always be a pair
721 # if top-level is range expression, the result must always be a pair
722 if first == second and len(revs) == 1 and not _pairspec(revs[0]):
722 if first == second and len(revs) == 1 and not _pairspec(revs[0]):
@@ -52,7 +52,7 b' from .node import ('
52 )
52 )
53 from . import (
53 from . import (
54 dagutil,
54 dagutil,
55 util,
55 error,
56 )
56 )
57
57
58 def _updatesample(dag, nodes, sample, quicksamplesize=0):
58 def _updatesample(dag, nodes, sample, quicksamplesize=0):
@@ -241,7 +241,7 b' def findcommonheads(ui, local, remote,'
241
241
242 if not result and srvheadhashes != [nullid]:
242 if not result and srvheadhashes != [nullid]:
243 if abortwhenunrelated:
243 if abortwhenunrelated:
244 raise util.Abort(_("repository is unrelated"))
244 raise error.Abort(_("repository is unrelated"))
245 else:
245 else:
246 ui.warn(_("warning: repository is unrelated\n"))
246 ui.warn(_("warning: repository is unrelated\n"))
247 return (set([nullid]), True, srvheadhashes,)
247 return (set([nullid]), True, srvheadhashes,)
@@ -23,6 +23,7 b' import sys'
23
23
24 from .i18n import _
24 from .i18n import _
25 from . import (
25 from . import (
26 error,
26 mdiff,
27 mdiff,
27 scmutil,
28 scmutil,
28 util,
29 util,
@@ -361,7 +362,7 b' def simplemerge(ui, local, base, other, '
361 if not opts.get('quiet'):
362 if not opts.get('quiet'):
362 ui.warn(_('warning: %s\n') % msg)
363 ui.warn(_('warning: %s\n') % msg)
363 if not opts.get('text'):
364 if not opts.get('text'):
364 raise util.Abort(msg)
365 raise error.Abort(msg)
365 return text
366 return text
366
367
367 mode = opts.get('mode','merge')
368 mode = opts.get('mode','merge')
@@ -381,13 +382,13 b' def simplemerge(ui, local, base, other, '
381 if len(labels) > 2:
382 if len(labels) > 2:
382 name_base = labels[2]
383 name_base = labels[2]
383 if len(labels) > 3:
384 if len(labels) > 3:
384 raise util.Abort(_("can only specify three labels."))
385 raise error.Abort(_("can only specify three labels."))
385
386
386 try:
387 try:
387 localtext = readfile(local)
388 localtext = readfile(local)
388 basetext = readfile(base)
389 basetext = readfile(base)
389 othertext = readfile(other)
390 othertext = readfile(other)
390 except util.Abort:
391 except error.Abort:
391 return 1
392 return 1
392
393
393 local = os.path.realpath(local)
394 local = os.path.realpath(local)
@@ -277,7 +277,7 b' class sshpeer(wireproto.wirepeer):'
277 r = self._call(cmd, **args)
277 r = self._call(cmd, **args)
278 if r:
278 if r:
279 # XXX needs to be made better
279 # XXX needs to be made better
280 raise util.Abort('unexpected remote reply: %s' % r)
280 raise error.Abort('unexpected remote reply: %s' % r)
281 while True:
281 while True:
282 d = fp.read(4096)
282 d = fp.read(4096)
283 if not d:
283 if not d:
@@ -12,6 +12,7 b' import os'
12 import sys
12 import sys
13
13
14 from . import (
14 from . import (
15 error,
15 hook,
16 hook,
16 util,
17 util,
17 wireproto,
18 wireproto,
@@ -39,7 +40,7 b' class sshserver(wireproto.abstractserver'
39 argline = self.fin.readline()[:-1]
40 argline = self.fin.readline()[:-1]
40 arg, l = argline.split()
41 arg, l = argline.split()
41 if arg not in keys:
42 if arg not in keys:
42 raise util.Abort("unexpected parameter %r" % arg)
43 raise error.Abort("unexpected parameter %r" % arg)
43 if arg == '*':
44 if arg == '*':
44 star = {}
45 star = {}
45 for k in xrange(int(l)):
46 for k in xrange(int(l)):
@@ -14,7 +14,7 b' import ssl'
14 import sys
14 import sys
15
15
16 from .i18n import _
16 from .i18n import _
17 from . import util
17 from . import error, util
18
18
19 _canloaddefaultcerts = False
19 _canloaddefaultcerts = False
20 try:
20 try:
@@ -50,7 +50,7 b' try:'
50 # closed
50 # closed
51 # - see http://bugs.python.org/issue13721
51 # - see http://bugs.python.org/issue13721
52 if not sslsocket.cipher():
52 if not sslsocket.cipher():
53 raise util.Abort(_('ssl connection failed'))
53 raise error.Abort(_('ssl connection failed'))
54 return sslsocket
54 return sslsocket
55 except AttributeError:
55 except AttributeError:
56 def wrapsocket(sock, keyfile, certfile, ui, cert_reqs=ssl.CERT_NONE,
56 def wrapsocket(sock, keyfile, certfile, ui, cert_reqs=ssl.CERT_NONE,
@@ -62,7 +62,7 b' except AttributeError:'
62 # closed
62 # closed
63 # - see http://bugs.python.org/issue13721
63 # - see http://bugs.python.org/issue13721
64 if not sslsocket.cipher():
64 if not sslsocket.cipher():
65 raise util.Abort(_('ssl connection failed'))
65 raise error.Abort(_('ssl connection failed'))
66 return sslsocket
66 return sslsocket
67
67
68 def _verifycert(cert, hostname):
68 def _verifycert(cert, hostname):
@@ -140,7 +140,7 b' def sslkwargs(ui, host):'
140 elif cacerts:
140 elif cacerts:
141 cacerts = util.expandpath(cacerts)
141 cacerts = util.expandpath(cacerts)
142 if not os.path.exists(cacerts):
142 if not os.path.exists(cacerts):
143 raise util.Abort(_('could not find web.cacerts: %s') % cacerts)
143 raise error.Abort(_('could not find web.cacerts: %s') % cacerts)
144 else:
144 else:
145 cacerts = _defaultcacerts()
145 cacerts = _defaultcacerts()
146 if cacerts and cacerts != '!':
146 if cacerts and cacerts != '!':
@@ -163,15 +163,15 b' class validator(object):'
163 hostfingerprint = self.ui.config('hostfingerprints', host)
163 hostfingerprint = self.ui.config('hostfingerprints', host)
164
164
165 if not sock.cipher(): # work around http://bugs.python.org/issue13721
165 if not sock.cipher(): # work around http://bugs.python.org/issue13721
166 raise util.Abort(_('%s ssl connection error') % host)
166 raise error.Abort(_('%s ssl connection error') % host)
167 try:
167 try:
168 peercert = sock.getpeercert(True)
168 peercert = sock.getpeercert(True)
169 peercert2 = sock.getpeercert()
169 peercert2 = sock.getpeercert()
170 except AttributeError:
170 except AttributeError:
171 raise util.Abort(_('%s ssl connection error') % host)
171 raise error.Abort(_('%s ssl connection error') % host)
172
172
173 if not peercert:
173 if not peercert:
174 raise util.Abort(_('%s certificate error: '
174 raise error.Abort(_('%s certificate error: '
175 'no certificate received') % host)
175 'no certificate received') % host)
176 peerfingerprint = util.sha1(peercert).hexdigest()
176 peerfingerprint = util.sha1(peercert).hexdigest()
177 nicefingerprint = ":".join([peerfingerprint[x:x + 2]
177 nicefingerprint = ":".join([peerfingerprint[x:x + 2]
@@ -179,7 +179,7 b' class validator(object):'
179 if hostfingerprint:
179 if hostfingerprint:
180 if peerfingerprint.lower() != \
180 if peerfingerprint.lower() != \
181 hostfingerprint.replace(':', '').lower():
181 hostfingerprint.replace(':', '').lower():
182 raise util.Abort(_('certificate for %s has unexpected '
182 raise error.Abort(_('certificate for %s has unexpected '
183 'fingerprint %s') % (host, nicefingerprint),
183 'fingerprint %s') % (host, nicefingerprint),
184 hint=_('check hostfingerprint configuration'))
184 hint=_('check hostfingerprint configuration'))
185 self.ui.debug('%s certificate matched fingerprint %s\n' %
185 self.ui.debug('%s certificate matched fingerprint %s\n' %
@@ -187,13 +187,13 b' class validator(object):'
187 elif cacerts != '!':
187 elif cacerts != '!':
188 msg = _verifycert(peercert2, host)
188 msg = _verifycert(peercert2, host)
189 if msg:
189 if msg:
190 raise util.Abort(_('%s certificate error: %s') % (host, msg),
190 raise error.Abort(_('%s certificate error: %s') % (host, msg),
191 hint=_('configure hostfingerprint %s or use '
191 hint=_('configure hostfingerprint %s or use '
192 '--insecure to connect insecurely') %
192 '--insecure to connect insecurely') %
193 nicefingerprint)
193 nicefingerprint)
194 self.ui.debug('%s certificate successfully verified\n' % host)
194 self.ui.debug('%s certificate successfully verified\n' % host)
195 elif strict:
195 elif strict:
196 raise util.Abort(_('%s certificate with fingerprint %s not '
196 raise error.Abort(_('%s certificate with fingerprint %s not '
197 'verified') % (host, nicefingerprint),
197 'verified') % (host, nicefingerprint),
198 hint=_('check hostfingerprints or web.cacerts '
198 hint=_('check hostfingerprints or web.cacerts '
199 'config setting'))
199 'config setting'))
@@ -171,9 +171,9 b' class statichttprepository(localrepo.loc'
171 return statichttppeer(self)
171 return statichttppeer(self)
172
172
173 def lock(self, wait=True):
173 def lock(self, wait=True):
174 raise util.Abort(_('cannot lock static-http repository'))
174 raise error.Abort(_('cannot lock static-http repository'))
175
175
176 def instance(ui, path, create):
176 def instance(ui, path, create):
177 if create:
177 if create:
178 raise util.Abort(_('cannot create new static-http repository'))
178 raise error.Abort(_('cannot create new static-http repository'))
179 return statichttprepository(ui, path[7:])
179 return statichttprepository(ui, path[7:])
@@ -6,7 +6,7 b''
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 scmutil, util, parsers
9 import scmutil, util, parsers, error
10 import os, stat, errno
10 import os, stat, errno
11
11
12 _sha = util.sha1
12 _sha = util.sha1
@@ -405,7 +405,7 b' class fncache(object):'
405 for n, line in enumerate(fp):
405 for n, line in enumerate(fp):
406 if not line.rstrip('\n'):
406 if not line.rstrip('\n'):
407 t = _('invalid entry in fncache, line %s') % (n + 1)
407 t = _('invalid entry in fncache, line %s') % (n + 1)
408 raise util.Abort(t)
408 raise error.Abort(t)
409 fp.close()
409 fp.close()
410
410
411 def write(self, tr):
411 def write(self, tr):
@@ -123,11 +123,11 b' def maybeperformlegacystreamclone(pullop'
123 raise error.ResponseError(
123 raise error.ResponseError(
124 _('unexpected response from remote server:'), l)
124 _('unexpected response from remote server:'), l)
125 if resp == 1:
125 if resp == 1:
126 raise util.Abort(_('operation forbidden by server'))
126 raise error.Abort(_('operation forbidden by server'))
127 elif resp == 2:
127 elif resp == 2:
128 raise util.Abort(_('locking the remote repository failed'))
128 raise error.Abort(_('locking the remote repository failed'))
129 elif resp != 0:
129 elif resp != 0:
130 raise util.Abort(_('the server sent an unknown error code'))
130 raise error.Abort(_('the server sent an unknown error code'))
131
131
132 l = fp.readline()
132 l = fp.readline()
133 try:
133 try:
@@ -95,7 +95,7 b' def state(ctx, ui):'
95 return
95 return
96 p.parse(f, data, sections, remap, read)
96 p.parse(f, data, sections, remap, read)
97 else:
97 else:
98 raise util.Abort(_("subrepo spec file \'%s\' not found") %
98 raise error.Abort(_("subrepo spec file \'%s\' not found") %
99 repo.pathto(f))
99 repo.pathto(f))
100 if '.hgsub' in ctx:
100 if '.hgsub' in ctx:
101 read('.hgsub')
101 read('.hgsub')
@@ -113,7 +113,7 b' def state(ctx, ui):'
113 try:
113 try:
114 revision, path = l.split(" ", 1)
114 revision, path = l.split(" ", 1)
115 except ValueError:
115 except ValueError:
116 raise util.Abort(_("invalid subrepository revision "
116 raise error.Abort(_("invalid subrepository revision "
117 "specifier in \'%s\' line %d")
117 "specifier in \'%s\' line %d")
118 % (repo.pathto('.hgsubstate'), (i + 1)))
118 % (repo.pathto('.hgsubstate'), (i + 1)))
119 rev[path] = revision
119 rev[path] = revision
@@ -133,7 +133,7 b' def state(ctx, ui):'
133 try:
133 try:
134 src = re.sub(pattern, repl, src, 1)
134 src = re.sub(pattern, repl, src, 1)
135 except re.error as e:
135 except re.error as e:
136 raise util.Abort(_("bad subrepository pattern in %s: %s")
136 raise error.Abort(_("bad subrepository pattern in %s: %s")
137 % (p.source('subpaths', pattern), e))
137 % (p.source('subpaths', pattern), e))
138 return src
138 return src
139
139
@@ -142,7 +142,7 b' def state(ctx, ui):'
142 kind = 'hg'
142 kind = 'hg'
143 if src.startswith('['):
143 if src.startswith('['):
144 if ']' not in src:
144 if ']' not in src:
145 raise util.Abort(_('missing ] in subrepo source'))
145 raise error.Abort(_('missing ] in subrepo source'))
146 kind, src = src.split(']', 1)
146 kind, src = src.split(']', 1)
147 kind = kind[1:]
147 kind = kind[1:]
148 src = src.lstrip() # strip any extra whitespace after ']'
148 src = src.lstrip() # strip any extra whitespace after ']'
@@ -324,7 +324,7 b' def _abssource(repo, push=False, abort=T'
324 # chop off the .hg component to get the default path form
324 # chop off the .hg component to get the default path form
325 return os.path.dirname(repo.sharedpath)
325 return os.path.dirname(repo.sharedpath)
326 if abort:
326 if abort:
327 raise util.Abort(_("default path for subrepository not found"))
327 raise error.Abort(_("default path for subrepository not found"))
328
328
329 def _sanitize(ui, vfs, ignore):
329 def _sanitize(ui, vfs, ignore):
330 for dirname, dirs, names in vfs.walk():
330 for dirname, dirs, names in vfs.walk():
@@ -353,7 +353,7 b' def subrepo(ctx, path, allowwdir=False):'
353 pathutil.pathauditor(ctx.repo().root)(path)
353 pathutil.pathauditor(ctx.repo().root)(path)
354 state = ctx.substate[path]
354 state = ctx.substate[path]
355 if state[2] not in types:
355 if state[2] not in types:
356 raise util.Abort(_('unknown subrepo type %s') % state[2])
356 raise error.Abort(_('unknown subrepo type %s') % state[2])
357 if allowwdir:
357 if allowwdir:
358 state = (state[0], ctx.subrev(path), state[2])
358 state = (state[0], ctx.subrev(path), state[2])
359 return types[state[2]](ctx, path, state[:2])
359 return types[state[2]](ctx, path, state[:2])
@@ -371,7 +371,7 b' def nullsubrepo(ctx, path, pctx):'
371 pathutil.pathauditor(ctx.repo().root)(path)
371 pathutil.pathauditor(ctx.repo().root)(path)
372 state = ctx.substate[path]
372 state = ctx.substate[path]
373 if state[2] not in types:
373 if state[2] not in types:
374 raise util.Abort(_('unknown subrepo type %s') % state[2])
374 raise error.Abort(_('unknown subrepo type %s') % state[2])
375 subrev = ''
375 subrev = ''
376 if state[2] == 'hg':
376 if state[2] == 'hg':
377 subrev = "0" * 40
377 subrev = "0" * 40
@@ -384,7 +384,7 b' def newcommitphase(ui, ctx):'
384 return commitphase
384 return commitphase
385 check = ui.config('phases', 'checksubrepos', 'follow')
385 check = ui.config('phases', 'checksubrepos', 'follow')
386 if check not in ('ignore', 'follow', 'abort'):
386 if check not in ('ignore', 'follow', 'abort'):
387 raise util.Abort(_('invalid phases.checksubrepos configuration: %s')
387 raise error.Abort(_('invalid phases.checksubrepos configuration: %s')
388 % (check))
388 % (check))
389 if check == 'ignore':
389 if check == 'ignore':
390 return commitphase
390 return commitphase
@@ -398,7 +398,7 b' def newcommitphase(ui, ctx):'
398 maxsub = s
398 maxsub = s
399 if commitphase < maxphase:
399 if commitphase < maxphase:
400 if check == 'abort':
400 if check == 'abort':
401 raise util.Abort(_("can't commit in %s phase"
401 raise error.Abort(_("can't commit in %s phase"
402 " conflicting %s from subrepository %s") %
402 " conflicting %s from subrepository %s") %
403 (phases.phasenames[commitphase],
403 (phases.phasenames[commitphase],
404 phases.phasenames[maxphase], maxsub))
404 phases.phasenames[maxphase], maxsub))
@@ -456,7 +456,7 b' class abstractsubrepo(object):'
456 """
456 """
457 dirtyreason = self.dirtyreason(ignoreupdate=ignoreupdate)
457 dirtyreason = self.dirtyreason(ignoreupdate=ignoreupdate)
458 if dirtyreason:
458 if dirtyreason:
459 raise util.Abort(dirtyreason)
459 raise error.Abort(dirtyreason)
460
460
461 def basestate(self):
461 def basestate(self):
462 """current working directory base state, disregarding .hgsubstate
462 """current working directory base state, disregarding .hgsubstate
@@ -1073,7 +1073,7 b' class svnsubrepo(abstractsubrepo):'
1073 self._state = state
1073 self._state = state
1074 self._exe = util.findexe('svn')
1074 self._exe = util.findexe('svn')
1075 if not self._exe:
1075 if not self._exe:
1076 raise util.Abort(_("'svn' executable not found for subrepo '%s'")
1076 raise error.Abort(_("'svn' executable not found for subrepo '%s'")
1077 % self._path)
1077 % self._path)
1078
1078
1079 def _svncommand(self, commands, filename='', failok=False):
1079 def _svncommand(self, commands, filename='', failok=False):
@@ -1108,7 +1108,8 b' class svnsubrepo(abstractsubrepo):'
1108 stderr = stderr.strip()
1108 stderr = stderr.strip()
1109 if not failok:
1109 if not failok:
1110 if p.returncode:
1110 if p.returncode:
1111 raise util.Abort(stderr or 'exited with code %d' % p.returncode)
1111 raise error.Abort(stderr or 'exited with code %d'
1112 % p.returncode)
1112 if stderr:
1113 if stderr:
1113 self.ui.warn(stderr + '\n')
1114 self.ui.warn(stderr + '\n')
1114 return stdout, stderr
1115 return stdout, stderr
@@ -1118,7 +1119,7 b' class svnsubrepo(abstractsubrepo):'
1118 output, err = self._svncommand(['--version', '--quiet'], filename=None)
1119 output, err = self._svncommand(['--version', '--quiet'], filename=None)
1119 m = re.search(r'^(\d+)\.(\d+)', output)
1120 m = re.search(r'^(\d+)\.(\d+)', output)
1120 if not m:
1121 if not m:
1121 raise util.Abort(_('cannot retrieve svn tool version'))
1122 raise error.Abort(_('cannot retrieve svn tool version'))
1122 return (int(m.group(1)), int(m.group(2)))
1123 return (int(m.group(1)), int(m.group(2)))
1123
1124
1124 def _wcrevs(self):
1125 def _wcrevs(self):
@@ -1196,11 +1197,11 b' class svnsubrepo(abstractsubrepo):'
1196 return self.basestate()
1197 return self.basestate()
1197 if extchanged:
1198 if extchanged:
1198 # Do not try to commit externals
1199 # Do not try to commit externals
1199 raise util.Abort(_('cannot commit svn externals'))
1200 raise error.Abort(_('cannot commit svn externals'))
1200 if missing:
1201 if missing:
1201 # svn can commit with missing entries but aborting like hg
1202 # svn can commit with missing entries but aborting like hg
1202 # seems a better approach.
1203 # seems a better approach.
1203 raise util.Abort(_('cannot commit missing svn entries'))
1204 raise error.Abort(_('cannot commit missing svn entries'))
1204 commitinfo, err = self._svncommand(['commit', '-m', text])
1205 commitinfo, err = self._svncommand(['commit', '-m', text])
1205 self.ui.status(commitinfo)
1206 self.ui.status(commitinfo)
1206 newrev = re.search('Committed revision ([0-9]+).', commitinfo)
1207 newrev = re.search('Committed revision ([0-9]+).', commitinfo)
@@ -1210,8 +1211,8 b' class svnsubrepo(abstractsubrepo):'
1210 # svn one. For instance, svn ignores missing files
1211 # svn one. For instance, svn ignores missing files
1211 # when committing. If there are only missing files, no
1212 # when committing. If there are only missing files, no
1212 # commit is made, no output and no error code.
1213 # commit is made, no output and no error code.
1213 raise util.Abort(_('failed to commit svn changes'))
1214 raise error.Abort(_('failed to commit svn changes'))
1214 raise util.Abort(commitinfo.splitlines()[-1])
1215 raise error.Abort(commitinfo.splitlines()[-1])
1215 newrev = newrev.groups()[0]
1216 newrev = newrev.groups()[0]
1216 self.ui.status(self._svncommand(['update', '-r', newrev])[0])
1217 self.ui.status(self._svncommand(['update', '-r', newrev])[0])
1217 return newrev
1218 return newrev
@@ -1250,7 +1251,7 b' class svnsubrepo(abstractsubrepo):'
1250 self.remove()
1251 self.remove()
1251 self.get(state, overwrite=False)
1252 self.get(state, overwrite=False)
1252 return
1253 return
1253 raise util.Abort((status or err).splitlines()[-1])
1254 raise error.Abort((status or err).splitlines()[-1])
1254 self.ui.status(status)
1255 self.ui.status(status)
1255
1256
1256 @annotatesubrepoerror
1257 @annotatesubrepoerror
@@ -1307,7 +1308,7 b' class gitsubrepo(abstractsubrepo):'
1307 if versionstatus == 'unknown':
1308 if versionstatus == 'unknown':
1308 self.ui.warn(_('cannot retrieve git version\n'))
1309 self.ui.warn(_('cannot retrieve git version\n'))
1309 elif versionstatus == 'abort':
1310 elif versionstatus == 'abort':
1310 raise util.Abort(_('git subrepo requires at least 1.6.0 or later'))
1311 raise error.Abort(_('git subrepo requires at least 1.6.0 or later'))
1311 elif versionstatus == 'warning':
1312 elif versionstatus == 'warning':
1312 self.ui.warn(_('git subrepo requires at least 1.6.0 or later\n'))
1313 self.ui.warn(_('git subrepo requires at least 1.6.0 or later\n'))
1313
1314
@@ -1394,7 +1395,7 b' class gitsubrepo(abstractsubrepo):'
1394 if command in ('cat-file', 'symbolic-ref'):
1395 if command in ('cat-file', 'symbolic-ref'):
1395 return retdata, p.returncode
1396 return retdata, p.returncode
1396 # for all others, abort
1397 # for all others, abort
1397 raise util.Abort('git %s error %d in %s' %
1398 raise error.Abort('git %s error %d in %s' %
1398 (command, p.returncode, self._relpath))
1399 (command, p.returncode, self._relpath))
1399
1400
1400 return retdata, p.returncode
1401 return retdata, p.returncode
@@ -1491,7 +1492,7 b' class gitsubrepo(abstractsubrepo):'
1491 # try only origin: the originally cloned repo
1492 # try only origin: the originally cloned repo
1492 self._gitcommand(['fetch'])
1493 self._gitcommand(['fetch'])
1493 if not self._githavelocally(revision):
1494 if not self._githavelocally(revision):
1494 raise util.Abort(_("revision %s does not exist in subrepo %s\n") %
1495 raise error.Abort(_("revision %s does not exist in subrepo %s\n") %
1495 (revision, self._relpath))
1496 (revision, self._relpath))
1496
1497
1497 @annotatesubrepoerror
1498 @annotatesubrepoerror
@@ -1600,7 +1601,7 b' class gitsubrepo(abstractsubrepo):'
1600 @annotatesubrepoerror
1601 @annotatesubrepoerror
1601 def commit(self, text, user, date):
1602 def commit(self, text, user, date):
1602 if self._gitmissing():
1603 if self._gitmissing():
1603 raise util.Abort(_("subrepo %s is missing") % self._relpath)
1604 raise error.Abort(_("subrepo %s is missing") % self._relpath)
1604 cmd = ['commit', '-a', '-m', text]
1605 cmd = ['commit', '-a', '-m', text]
1605 env = os.environ.copy()
1606 env = os.environ.copy()
1606 if user:
1607 if user:
@@ -1646,7 +1647,7 b' class gitsubrepo(abstractsubrepo):'
1646 if not self._state[1]:
1647 if not self._state[1]:
1647 return True
1648 return True
1648 if self._gitmissing():
1649 if self._gitmissing():
1649 raise util.Abort(_("subrepo %s is missing") % self._relpath)
1650 raise error.Abort(_("subrepo %s is missing") % self._relpath)
1650 # if a branch in origin contains the revision, nothing to do
1651 # if a branch in origin contains the revision, nothing to do
1651 branch2rev, rev2branch = self._gitbranchmap()
1652 branch2rev, rev2branch = self._gitbranchmap()
1652 if self._state[1] in rev2branch:
1653 if self._state[1] in rev2branch:
@@ -270,7 +270,7 b' def runfilter(context, mapping, data):'
270 dt = arg[1][1]
270 dt = arg[1][1]
271 else:
271 else:
272 dt = arg[1]
272 dt = arg[1]
273 raise util.Abort(_("template filter '%s' is not compatible with "
273 raise error.Abort(_("template filter '%s' is not compatible with "
274 "keyword '%s'") % (filt.func_name, dt))
274 "keyword '%s'") % (filt.func_name, dt))
275
275
276 def buildmap(exp, context):
276 def buildmap(exp, context):
@@ -840,7 +840,7 b' def stylelist():'
840 stylelist.append(split[1])
840 stylelist.append(split[1])
841 return ", ".join(sorted(stylelist))
841 return ", ".join(sorted(stylelist))
842
842
843 class TemplateNotFound(util.Abort):
843 class TemplateNotFound(error.Abort):
844 pass
844 pass
845
845
846 class templater(object):
846 class templater(object):
@@ -873,7 +873,7 b' class templater(object):'
873 if not mapfile:
873 if not mapfile:
874 return
874 return
875 if not os.path.exists(mapfile):
875 if not os.path.exists(mapfile):
876 raise util.Abort(_("style '%s' not found") % mapfile,
876 raise error.Abort(_("style '%s' not found") % mapfile,
877 hint=_("available styles: %s") % stylelist())
877 hint=_("available styles: %s") % stylelist())
878
878
879 conf = config.config(includepaths=templatepaths())
879 conf = config.config(includepaths=templatepaths())
@@ -71,7 +71,7 b' def _playback(journal, report, opener, v'
71 except (IOError, OSError) as inst:
71 except (IOError, OSError) as inst:
72 if inst.errno != errno.ENOENT:
72 if inst.errno != errno.ENOENT:
73 raise
73 raise
74 except (IOError, OSError, util.Abort) as inst:
74 except (IOError, OSError, error.Abort) as inst:
75 if not c:
75 if not c:
76 raise
76 raise
77
77
@@ -83,7 +83,7 b' def _playback(journal, report, opener, v'
83 for f in backupfiles:
83 for f in backupfiles:
84 if opener.exists(f):
84 if opener.exists(f):
85 opener.unlink(f)
85 opener.unlink(f)
86 except (IOError, OSError, util.Abort) as inst:
86 except (IOError, OSError, error.Abort) as inst:
87 # only pure backup file remains, it is sage to ignore any error
87 # only pure backup file remains, it is sage to ignore any error
88 pass
88 pass
89
89
@@ -417,7 +417,7 b' class transaction(object):'
417 if not f and b and vfs.exists(b):
417 if not f and b and vfs.exists(b):
418 try:
418 try:
419 vfs.unlink(b)
419 vfs.unlink(b)
420 except (IOError, OSError, util.Abort) as inst:
420 except (IOError, OSError, error.Abort) as inst:
421 if not c:
421 if not c:
422 raise
422 raise
423 # Abort may be raise by read only opener
423 # Abort may be raise by read only opener
@@ -440,7 +440,7 b' class transaction(object):'
440 if b and vfs.exists(b):
440 if b and vfs.exists(b):
441 try:
441 try:
442 vfs.unlink(b)
442 vfs.unlink(b)
443 except (IOError, OSError, util.Abort) as inst:
443 except (IOError, OSError, error.Abort) as inst:
444 if not c:
444 if not c:
445 raise
445 raise
446 # Abort may be raise by read only opener
446 # Abort may be raise by read only opener
@@ -16,7 +16,6 b' from .node import ('
16 )
16 )
17 from . import (
17 from . import (
18 error,
18 error,
19 util,
20 )
19 )
21
20
22 def findcommonincoming(repo, remote, heads=None, force=False):
21 def findcommonincoming(repo, remote, heads=None, force=False):
@@ -149,7 +148,7 b' def findcommonincoming(repo, remote, hea'
149 if force:
148 if force:
150 repo.ui.warn(_("warning: repository is unrelated\n"))
149 repo.ui.warn(_("warning: repository is unrelated\n"))
151 else:
150 else:
152 raise util.Abort(_("repository is unrelated"))
151 raise error.Abort(_("repository is unrelated"))
153
152
154 repo.ui.debug("found new changesets starting at " +
153 repo.ui.debug("found new changesets starting at " +
155 " ".join([short(f) for f in fetch]) + "\n")
154 " ".join([short(f) for f in fetch]) + "\n")
@@ -535,11 +535,12 b' class ui(object):'
535 except KeyError:
535 except KeyError:
536 pass
536 pass
537 if not user:
537 if not user:
538 raise util.Abort(_('no username supplied'),
538 raise error.Abort(_('no username supplied'),
539 hint=_('use "hg config --edit" '
539 hint=_('use "hg config --edit" '
540 'to set your username'))
540 'to set your username'))
541 if "\n" in user:
541 if "\n" in user:
542 raise util.Abort(_("username %s contains a newline\n") % repr(user))
542 raise error.Abort(_("username %s contains a newline\n")
543 % repr(user))
543 return user
544 return user
544
545
545 def shortuser(self, user):
546 def shortuser(self, user):
@@ -755,7 +756,7 b' class ui(object):'
755 self.write(r, "\n")
756 self.write(r, "\n")
756 return r
757 return r
757 except EOFError:
758 except EOFError:
758 raise util.Abort(_('response expected'))
759 raise error.Abort(_('response expected'))
759
760
760 @staticmethod
761 @staticmethod
761 def extractchoices(prompt):
762 def extractchoices(prompt):
@@ -802,7 +803,7 b' class ui(object):'
802 else:
803 else:
803 return getpass.getpass('')
804 return getpass.getpass('')
804 except EOFError:
805 except EOFError:
805 raise util.Abort(_('response expected'))
806 raise error.Abort(_('response expected'))
806 def status(self, *msg, **opts):
807 def status(self, *msg, **opts):
807 '''write status message to output (if ui.quiet is False)
808 '''write status message to output (if ui.quiet is False)
808
809
@@ -858,7 +859,7 b' class ui(object):'
858
859
859 self.system("%s \"%s\"" % (editor, name),
860 self.system("%s \"%s\"" % (editor, name),
860 environ=environ,
861 environ=environ,
861 onerr=util.Abort, errprefix=_("edit failed"))
862 onerr=error.Abort, errprefix=_("edit failed"))
862
863
863 f = open(name)
864 f = open(name)
864 t = f.read()
865 t = f.read()
@@ -21,6 +21,7 b' from .node import nullid'
21 from . import (
21 from . import (
22 changelog,
22 changelog,
23 cmdutil,
23 cmdutil,
24 error,
24 filelog,
25 filelog,
25 localrepo,
26 localrepo,
26 manifest,
27 manifest,
@@ -231,7 +232,7 b' class unionrepository(localrepo.localrep'
231
232
232 def instance(ui, path, create):
233 def instance(ui, path, create):
233 if create:
234 if create:
234 raise util.Abort(_('cannot create new union repository'))
235 raise error.Abort(_('cannot create new union repository'))
235 parentpath = ui.config("bundle", "mainreporoot", "")
236 parentpath = ui.config("bundle", "mainreporoot", "")
236 if not parentpath:
237 if not parentpath:
237 # try to find the correct path to the working directory repo
238 # try to find the correct path to the working directory repo
@@ -19,6 +19,7 b' import urllib2'
19
19
20 from .i18n import _
20 from .i18n import _
21 from . import (
21 from . import (
22 error,
22 httpconnection as httpconnectionmod,
23 httpconnection as httpconnectionmod,
23 keepalive,
24 keepalive,
24 sslutil,
25 sslutil,
@@ -48,7 +49,7 b' class passwordmgr(urllib2.HTTPPasswordMg'
48 u = util.url(authuri)
49 u = util.url(authuri)
49 u.query = None
50 u.query = None
50 if not self.ui.interactive():
51 if not self.ui.interactive():
51 raise util.Abort(_('http authorization required for %s') %
52 raise error.Abort(_('http authorization required for %s') %
52 util.hidepassword(str(u)))
53 util.hidepassword(str(u)))
53
54
54 self.ui.write(_("http authorization required for %s\n") %
55 self.ui.write(_("http authorization required for %s\n") %
@@ -1925,7 +1925,7 b' def getport(port):'
1925
1925
1926 If port is an integer, it's returned as is. If it's a string, it's
1926 If port is an integer, it's returned as is. If it's a string, it's
1927 looked up using socket.getservbyname(). If there's no matching
1927 looked up using socket.getservbyname(). If there's no matching
1928 service, util.Abort is raised.
1928 service, error.Abort is raised.
1929 """
1929 """
1930 try:
1930 try:
1931 return int(port)
1931 return int(port)
@@ -50,7 +50,7 b' def _verify(repo):'
50 lrugetctx = util.lrucachefunc(repo.changectx)
50 lrugetctx = util.lrucachefunc(repo.changectx)
51
51
52 if not repo.url().startswith('file:'):
52 if not repo.url().startswith('file:'):
53 raise util.Abort(_("cannot verify bundle or remote repos"))
53 raise error.Abort(_("cannot verify bundle or remote repos"))
54
54
55 def err(linkrev, msg, filename=None):
55 def err(linkrev, msg, filename=None):
56 if linkrev is not None:
56 if linkrev is not None:
@@ -690,7 +690,7 b' def pushkey(repo, proto, namespace, key,'
690 try:
690 try:
691 r = repo.pushkey(encoding.tolocal(namespace), encoding.tolocal(key),
691 r = repo.pushkey(encoding.tolocal(namespace), encoding.tolocal(key),
692 encoding.tolocal(old), new) or False
692 encoding.tolocal(old), new) or False
693 except util.Abort:
693 except error.Abort:
694 r = False
694 r = False
695
695
696 output = proto.restore()
696 output = proto.restore()
@@ -752,12 +752,12 b' def unbundle(repo, proto, heads):'
752 fp.close()
752 fp.close()
753 os.unlink(tempname)
753 os.unlink(tempname)
754
754
755 except (error.BundleValueError, util.Abort, error.PushRaced) as exc:
755 except (error.BundleValueError, error.Abort, error.PushRaced) as exc:
756 # handle non-bundle2 case first
756 # handle non-bundle2 case first
757 if not getattr(exc, 'duringunbundle2', False):
757 if not getattr(exc, 'duringunbundle2', False):
758 try:
758 try:
759 raise
759 raise
760 except util.Abort:
760 except error.Abort:
761 # The old code we moved used sys.stderr directly.
761 # The old code we moved used sys.stderr directly.
762 # We did not change it to minimise code change.
762 # We did not change it to minimise code change.
763 # This need to be moved to something proper.
763 # This need to be moved to something proper.
@@ -798,7 +798,7 b' def unbundle(repo, proto, heads):'
798 errpart.addparam('parttype', exc.parttype)
798 errpart.addparam('parttype', exc.parttype)
799 if exc.params:
799 if exc.params:
800 errpart.addparam('params', '\0'.join(exc.params))
800 errpart.addparam('params', '\0'.join(exc.params))
801 except util.Abort as exc:
801 except error.Abort as exc:
802 manargs = [('message', str(exc))]
802 manargs = [('message', str(exc))]
803 advargs = []
803 advargs = []
804 if exc.hint is not None:
804 if exc.hint is not None:
@@ -14,7 +14,7 b' import sys'
14 import threading
14 import threading
15
15
16 from .i18n import _
16 from .i18n import _
17 from . import util
17 from . import error
18
18
19 def countcpus():
19 def countcpus():
20 '''try to count the number of CPUs on the system'''
20 '''try to count the number of CPUs on the system'''
@@ -45,7 +45,7 b' def _numworkers(ui):'
45 if n >= 1:
45 if n >= 1:
46 return n
46 return n
47 except ValueError:
47 except ValueError:
48 raise util.Abort(_('number of cpus must be an integer'))
48 raise error.Abort(_('number of cpus must be an integer'))
49 return min(max(countcpus(), 4), 32)
49 return min(max(countcpus(), 4), 32)
50
50
51 if os.name == 'posix':
51 if os.name == 'posix':
@@ -1,7 +1,7 b''
1 # Extension dedicated to test patch.diff() upgrade modes
1 # Extension dedicated to test patch.diff() upgrade modes
2 #
2 #
3 #
3 #
4 from mercurial import cmdutil, scmutil, patch, util
4 from mercurial import cmdutil, scmutil, patch, error
5
5
6 cmdtable = {}
6 cmdtable = {}
7 command = cmdutil.command(cmdtable)
7 command = cmdutil.command(cmdtable)
@@ -30,9 +30,9 b' def autodiff(ui, repo, *pats, **opts):'
30 diffopts.git = False
30 diffopts.git = False
31 diffopts.upgrade = True
31 diffopts.upgrade = True
32 def losedatafn(fn=None, **kwargs):
32 def losedatafn(fn=None, **kwargs):
33 raise util.Abort('losing data for %s' % fn)
33 raise error.Abort('losing data for %s' % fn)
34 else:
34 else:
35 raise util.Abort('--git must be yes, no or auto')
35 raise error.Abort('--git must be yes, no or auto')
36
36
37 node1, node2 = scmutil.revpair(repo, [])
37 node1, node2 = scmutil.revpair(repo, [])
38 m = scmutil.match(repo[node2], pats, opts)
38 m = scmutil.match(repo[node2], pats, opts)
@@ -1,7 +1,7 b''
1 $ cat > abortcommit.py <<EOF
1 $ cat > abortcommit.py <<EOF
2 > from mercurial import util
2 > from mercurial import error
3 > def hook(**args):
3 > def hook(**args):
4 > raise util.Abort("no commits allowed")
4 > raise error.Abort("no commits allowed")
5 > def reposetup(ui, repo):
5 > def reposetup(ui, repo):
6 > repo.ui.setconfig("hooks", "pretxncommit.nocommits", hook)
6 > repo.ui.setconfig("hooks", "pretxncommit.nocommits", hook)
7 > EOF
7 > EOF
@@ -69,7 +69,7 b' should all fail'
69
69
70 $ cd ..
70 $ cd ..
71
71
72 Issue1527: repeated addremove causes util.Abort
72 Issue1527: repeated addremove causes Abort
73
73
74 $ hg init rep3; cd rep3
74 $ hg init rep3; cd rep3
75 $ mkdir d
75 $ mkdir d
@@ -299,7 +299,7 b' and (2) the extension to allow filelog m'
299 and its ancestor by overriding "repo._filecommit".
299 and its ancestor by overriding "repo._filecommit".
300
300
301 $ cat > ../legacyrepo.py <<EOF
301 $ cat > ../legacyrepo.py <<EOF
302 > from mercurial import node, util
302 > from mercurial import node, error
303 > def reposetup(ui, repo):
303 > def reposetup(ui, repo):
304 > class legacyrepo(repo.__class__):
304 > class legacyrepo(repo.__class__):
305 > def _filecommit(self, fctx, manifest1, manifest2,
305 > def _filecommit(self, fctx, manifest1, manifest2,
@@ -312,12 +312,12 b' and its ancestor by overriding "repo._fi'
312 > meta = {}
312 > meta = {}
313 > copy = fctx.renamed()
313 > copy = fctx.renamed()
314 > if copy and copy[0] != fname:
314 > if copy and copy[0] != fname:
315 > raise util.Abort('copying is not supported')
315 > raise error.Abort('copying is not supported')
316 > if fparent2 != node.nullid:
316 > if fparent2 != node.nullid:
317 > changelist.append(fname)
317 > changelist.append(fname)
318 > return flog.add(text, meta, tr, linkrev,
318 > return flog.add(text, meta, tr, linkrev,
319 > fparent1, fparent2)
319 > fparent1, fparent2)
320 > raise util.Abort('only merging is supported')
320 > raise error.Abort('only merging is supported')
321 > repo.__class__ = legacyrepo
321 > repo.__class__ = legacyrepo
322 > EOF
322 > EOF
323
323
@@ -453,7 +453,7 b' Setting up'
453 > used to test error handling in bundle2
453 > used to test error handling in bundle2
454 > """
454 > """
455 >
455 >
456 > from mercurial import util
456 > from mercurial import error
457 > from mercurial import bundle2
457 > from mercurial import bundle2
458 > from mercurial import exchange
458 > from mercurial import exchange
459 > from mercurial import extensions
459 > from mercurial import extensions
@@ -471,7 +471,7 b' Setting up'
471 >
471 >
472 > @bundle2.parthandler("test:abort")
472 > @bundle2.parthandler("test:abort")
473 > def handleabort(op, part):
473 > def handleabort(op, part):
474 > raise util.Abort('Abandon ship!', hint="don't panic")
474 > raise error.Abort('Abandon ship!', hint="don't panic")
475 >
475 >
476 > def uisetup(ui):
476 > def uisetup(ui):
477 > exchange.b2partsgenmapping['failpart'] = _pushbundle2failpart
477 > exchange.b2partsgenmapping['failpart'] = _pushbundle2failpart
@@ -90,7 +90,7 b' Create an extension to test bundle2 API'
90 > try:
90 > try:
91 > bundler.addparam(*p)
91 > bundler.addparam(*p)
92 > except ValueError, exc:
92 > except ValueError, exc:
93 > raise util.Abort('%s' % exc)
93 > raise error.Abort('%s' % exc)
94 >
94 >
95 > if opts['compress']:
95 > if opts['compress']:
96 > bundler.setcompression(opts['compress'])
96 > bundler.setcompression(opts['compress'])
@@ -164,7 +164,7 b' Create an extension to test bundle2 API'
164 > for chunk in bundler.getchunks():
164 > for chunk in bundler.getchunks():
165 > file.write(chunk)
165 > file.write(chunk)
166 > except RuntimeError, exc:
166 > except RuntimeError, exc:
167 > raise util.Abort(exc)
167 > raise error.Abort(exc)
168 >
168 >
169 > @command('unbundle2', [], '')
169 > @command('unbundle2', [], '')
170 > def cmdunbundle2(ui, repo, replypath=None):
170 > def cmdunbundle2(ui, repo, replypath=None):
@@ -178,9 +178,9 b' Create an extension to test bundle2 API'
178 > op = bundle2.processbundle(repo, unbundler, lambda: tr)
178 > op = bundle2.processbundle(repo, unbundler, lambda: tr)
179 > tr.close()
179 > tr.close()
180 > except error.BundleValueError, exc:
180 > except error.BundleValueError, exc:
181 > raise util.Abort('missing support for %s' % exc)
181 > raise error.Abort('missing support for %s' % exc)
182 > except error.PushRaced, exc:
182 > except error.PushRaced, exc:
183 > raise util.Abort('push race: %s' % exc)
183 > raise error.Abort('push race: %s' % exc)
184 > finally:
184 > finally:
185 > if tr is not None:
185 > if tr is not None:
186 > tr.release()
186 > tr.release()
@@ -204,7 +204,7 b' Create an extension to test bundle2 API'
204 > try:
204 > try:
205 > params = unbundler.params
205 > params = unbundler.params
206 > except error.BundleValueError, exc:
206 > except error.BundleValueError, exc:
207 > raise util.Abort('unknown parameters: %s' % exc)
207 > raise error.Abort('unknown parameters: %s' % exc)
208 > ui.write('options count: %i\n' % len(params))
208 > ui.write('options count: %i\n' % len(params))
209 > for key in sorted(params):
209 > for key in sorted(params):
210 > ui.write('- %s\n' % key)
210 > ui.write('- %s\n' % key)
@@ -10,11 +10,11 b''
10 > EOF
10 > EOF
11
11
12 $ cat > prefix.py <<EOF
12 $ cat > prefix.py <<EOF
13 > from mercurial import util
13 > from mercurial import error
14 > def stripprefix(s, cmd, filename, **kwargs):
14 > def stripprefix(s, cmd, filename, **kwargs):
15 > header = '%s\n' % cmd
15 > header = '%s\n' % cmd
16 > if s[:len(header)] != header:
16 > if s[:len(header)] != header:
17 > raise util.Abort('missing header "%s" in %s' % (cmd, filename))
17 > raise error.Abort('missing header "%s" in %s' % (cmd, filename))
18 > return s[len(header):]
18 > return s[len(header):]
19 > def insertprefix(s, cmd):
19 > def insertprefix(s, cmd):
20 > return '%s\n%s' % (cmd, s)
20 > return '%s\n%s' % (cmd, s)
@@ -66,10 +66,10 b' Verify that exceptions during a dirstate'
66 coherent (issue4353)
66 coherent (issue4353)
67
67
68 $ cat > ../dirstateexception.py <<EOF
68 $ cat > ../dirstateexception.py <<EOF
69 > from mercurial import merge, extensions, util
69 > from mercurial import merge, extensions, error
70 >
70 >
71 > def wraprecordupdates(orig, repo, actions, branchmerge):
71 > def wraprecordupdates(orig, repo, actions, branchmerge):
72 > raise util.Abort("simulated error while recording dirstateupdates")
72 > raise error.Abort("simulated error while recording dirstateupdates")
73 >
73 >
74 > def reposetup(ui, repo):
74 > def reposetup(ui, repo):
75 > extensions.wrapfunction(merge, 'recordupdates', wraprecordupdates)
75 > extensions.wrapfunction(merge, 'recordupdates', wraprecordupdates)
@@ -202,12 +202,12 b' Aborting lock does not prevent fncache w'
202
202
203 $ cat > exceptionext.py <<EOF
203 $ cat > exceptionext.py <<EOF
204 > import os
204 > import os
205 > from mercurial import commands, util
205 > from mercurial import commands, error
206 > from mercurial.extensions import wrapfunction
206 > from mercurial.extensions import wrapfunction
207 >
207 >
208 > def lockexception(orig, vfs, lockname, wait, releasefn, *args, **kwargs):
208 > def lockexception(orig, vfs, lockname, wait, releasefn, *args, **kwargs):
209 > def releasewrap():
209 > def releasewrap():
210 > raise util.Abort("forced lock failure")
210 > raise error.Abort("forced lock failure")
211 > return orig(vfs, lockname, wait, releasewrap, *args, **kwargs)
211 > return orig(vfs, lockname, wait, releasewrap, *args, **kwargs)
212 >
212 >
213 > def reposetup(ui, repo):
213 > def reposetup(ui, repo):
@@ -231,13 +231,13 b' Aborting transaction prevents fncache ch'
231
231
232 $ cat > ../exceptionext.py <<EOF
232 $ cat > ../exceptionext.py <<EOF
233 > import os
233 > import os
234 > from mercurial import commands, util, localrepo
234 > from mercurial import commands, error, localrepo
235 > from mercurial.extensions import wrapfunction
235 > from mercurial.extensions import wrapfunction
236 >
236 >
237 > def wrapper(orig, self, *args, **kwargs):
237 > def wrapper(orig, self, *args, **kwargs):
238 > tr = orig(self, *args, **kwargs)
238 > tr = orig(self, *args, **kwargs)
239 > def fail(tr):
239 > def fail(tr):
240 > raise util.Abort("forced transaction failure")
240 > raise error.Abort("forced transaction failure")
241 > # zzz prefix to ensure it sorted after store.write
241 > # zzz prefix to ensure it sorted after store.write
242 > tr.addfinalize('zzz-forcefails', fail)
242 > tr.addfinalize('zzz-forcefails', fail)
243 > return tr
243 > return tr
@@ -262,19 +262,19 b' Aborted transactions can be recovered la'
262
262
263 $ cat > ../exceptionext.py <<EOF
263 $ cat > ../exceptionext.py <<EOF
264 > import os
264 > import os
265 > from mercurial import commands, util, transaction, localrepo
265 > from mercurial import commands, error, transaction, localrepo
266 > from mercurial.extensions import wrapfunction
266 > from mercurial.extensions import wrapfunction
267 >
267 >
268 > def trwrapper(orig, self, *args, **kwargs):
268 > def trwrapper(orig, self, *args, **kwargs):
269 > tr = orig(self, *args, **kwargs)
269 > tr = orig(self, *args, **kwargs)
270 > def fail(tr):
270 > def fail(tr):
271 > raise util.Abort("forced transaction failure")
271 > raise error.Abort("forced transaction failure")
272 > # zzz prefix to ensure it sorted after store.write
272 > # zzz prefix to ensure it sorted after store.write
273 > tr.addfinalize('zzz-forcefails', fail)
273 > tr.addfinalize('zzz-forcefails', fail)
274 > return tr
274 > return tr
275 >
275 >
276 > def abortwrapper(orig, self, *args, **kwargs):
276 > def abortwrapper(orig, self, *args, **kwargs):
277 > raise util.Abort("forced transaction failure")
277 > raise error.Abort("forced transaction failure")
278 >
278 >
279 > def uisetup(ui):
279 > def uisetup(ui):
280 > wrapfunction(localrepo.localrepository, 'transaction', trwrapper)
280 > wrapfunction(localrepo.localrepository, 'transaction', trwrapper)
@@ -298,11 +298,11 b' modify the message'
298 check saving last-message.txt, at first
298 check saving last-message.txt, at first
299
299
300 $ cat > $TESTTMP/commitfailure.py <<EOF
300 $ cat > $TESTTMP/commitfailure.py <<EOF
301 > from mercurial import util
301 > from mercurial import error
302 > def reposetup(ui, repo):
302 > def reposetup(ui, repo):
303 > class commitfailure(repo.__class__):
303 > class commitfailure(repo.__class__):
304 > def commit(self, *args, **kwargs):
304 > def commit(self, *args, **kwargs):
305 > raise util.Abort('emulating unexpected abort')
305 > raise error.Abort('emulating unexpected abort')
306 > repo.__class__ = commitfailure
306 > repo.__class__ = commitfailure
307 > EOF
307 > EOF
308 $ cat >> .hg/hgrc <<EOF
308 $ cat >> .hg/hgrc <<EOF
@@ -394,7 +394,7 b' preoutgoing hook can prevent outgoing ch'
394 $ cd "$TESTTMP/b"
394 $ cd "$TESTTMP/b"
395
395
396 $ cat > hooktests.py <<EOF
396 $ cat > hooktests.py <<EOF
397 > from mercurial import util
397 > from mercurial import error
398 >
398 >
399 > uncallable = 0
399 > uncallable = 0
400 >
400 >
@@ -421,7 +421,7 b' preoutgoing hook can prevent outgoing ch'
421 > raise LocalException('exception from hook')
421 > raise LocalException('exception from hook')
422 >
422 >
423 > def aborthook(**args):
423 > def aborthook(**args):
424 > raise util.Abort('raise abort from hook')
424 > raise error.Abort('raise abort from hook')
425 >
425 >
426 > def brokenhook(**args):
426 > def brokenhook(**args):
427 > return 1 + {}
427 > return 1 + {}
@@ -14,7 +14,7 b' Prepare'
14 Test that raising an exception in the release function doesn't cause the lock to choke
14 Test that raising an exception in the release function doesn't cause the lock to choke
15
15
16 $ cat > testlock.py << EOF
16 $ cat > testlock.py << EOF
17 > from mercurial import cmdutil, error, util
17 > from mercurial import cmdutil, error, error
18 >
18 >
19 > cmdtable = {}
19 > cmdtable = {}
20 > command = cmdutil.command(cmdtable)
20 > command = cmdutil.command(cmdtable)
@@ -22,7 +22,7 b' Test that raising an exception in the re'
22 > def acquiretestlock(repo, releaseexc):
22 > def acquiretestlock(repo, releaseexc):
23 > def unlock():
23 > def unlock():
24 > if releaseexc:
24 > if releaseexc:
25 > raise util.Abort('expected release exception')
25 > raise error.Abort('expected release exception')
26 > l = repo._lock(repo.vfs, 'testlock', False, unlock, None, 'test lock')
26 > l = repo._lock(repo.vfs, 'testlock', False, unlock, None, 'test lock')
27 > return l
27 > return l
28 >
28 >
@@ -35,7 +35,7 b' Test that raising an exception in the re'
35 > try:
35 > try:
36 > testlock = acquiretestlock(repo, False)
36 > testlock = acquiretestlock(repo, False)
37 > except error.LockHeld:
37 > except error.LockHeld:
38 > raise util.Abort('lockfile on disk even after releasing!')
38 > raise error.Abort('lockfile on disk even after releasing!')
39 > testlock.release()
39 > testlock.release()
40 > EOF
40 > EOF
41 $ cat >> $HGRCPATH << EOF
41 $ cat >> $HGRCPATH << EOF
@@ -214,10 +214,10 b" isn't changed on the filesystem (see als"
214 $ cat > $TESTTMP/abort.py <<EOF
214 $ cat > $TESTTMP/abort.py <<EOF
215 > # emulate aborting before "recordupdates()". in this case, files
215 > # emulate aborting before "recordupdates()". in this case, files
216 > # are changed without updating dirstate
216 > # are changed without updating dirstate
217 > from mercurial import extensions, merge, util
217 > from mercurial import extensions, merge, error
218 > def applyupdates(orig, *args, **kwargs):
218 > def applyupdates(orig, *args, **kwargs):
219 > orig(*args, **kwargs)
219 > orig(*args, **kwargs)
220 > raise util.Abort('intentional aborting')
220 > raise error.Abort('intentional aborting')
221 > def extsetup(ui):
221 > def extsetup(ui):
222 > extensions.wrapfunction(merge, "applyupdates", applyupdates)
222 > extensions.wrapfunction(merge, "applyupdates", applyupdates)
223 > EOF
223 > EOF
@@ -149,11 +149,11 b' Test saving last-message.txt:'
149 $ hg qrefresh -m "original message"
149 $ hg qrefresh -m "original message"
150
150
151 $ cat > $TESTTMP/commitfailure.py <<EOF
151 $ cat > $TESTTMP/commitfailure.py <<EOF
152 > from mercurial import util
152 > from mercurial import error
153 > def reposetup(ui, repo):
153 > def reposetup(ui, repo):
154 > class commitfailure(repo.__class__):
154 > class commitfailure(repo.__class__):
155 > def commit(self, *args, **kwargs):
155 > def commit(self, *args, **kwargs):
156 > raise util.Abort('emulating unexpected abort')
156 > raise error.Abort('emulating unexpected abort')
157 > repo.__class__ = commitfailure
157 > repo.__class__ = commitfailure
158 > EOF
158 > EOF
159
159
@@ -248,11 +248,11 b' Test saving last-message.txt'
248 $ cd repo
248 $ cd repo
249
249
250 $ cat > $TESTTMP/commitfailure.py <<EOF
250 $ cat > $TESTTMP/commitfailure.py <<EOF
251 > from mercurial import util
251 > from mercurial import error
252 > def reposetup(ui, repo):
252 > def reposetup(ui, repo):
253 > class commitfailure(repo.__class__):
253 > class commitfailure(repo.__class__):
254 > def commit(self, *args, **kwargs):
254 > def commit(self, *args, **kwargs):
255 > raise util.Abort('emulating unexpected abort')
255 > raise error.Abort('emulating unexpected abort')
256 > repo.__class__ = commitfailure
256 > repo.__class__ = commitfailure
257 > EOF
257 > EOF
258 $ cat >> .hg/hgrc <<EOF
258 $ cat >> .hg/hgrc <<EOF
@@ -108,11 +108,11 b' Test saving last-message.txt:'
108 > EOF
108 > EOF
109
109
110 $ cat > $TESTTMP/commitfailure.py <<EOF
110 $ cat > $TESTTMP/commitfailure.py <<EOF
111 > from mercurial import util
111 > from mercurial import error
112 > def reposetup(ui, repo):
112 > def reposetup(ui, repo):
113 > class commitfailure(repo.__class__):
113 > class commitfailure(repo.__class__):
114 > def commit(self, *args, **kwargs):
114 > def commit(self, *args, **kwargs):
115 > raise util.Abort('emulating unexpected abort')
115 > raise error.Abort('emulating unexpected abort')
116 > repo.__class__ = commitfailure
116 > repo.__class__ = commitfailure
117 > EOF
117 > EOF
118
118
@@ -15,7 +15,7 b''
15
15
16 import unittest
16 import unittest
17 from unittest import TestCase
17 from unittest import TestCase
18 from mercurial import util, simplemerge
18 from mercurial import util, simplemerge, error
19
19
20 # bzr compatible interface, for the tests
20 # bzr compatible interface, for the tests
21 class Merge3(simplemerge.Merge3Text):
21 class Merge3(simplemerge.Merge3Text):
@@ -29,7 +29,7 b' class Merge3(simplemerge.Merge3Text):'
29 atext = '\n'.join([i.strip('\n') for i in a] + [''])
29 atext = '\n'.join([i.strip('\n') for i in a] + [''])
30 btext = '\n'.join([i.strip('\n') for i in b] + [''])
30 btext = '\n'.join([i.strip('\n') for i in b] + [''])
31 if util.binary(basetext) or util.binary(atext) or util.binary(btext):
31 if util.binary(basetext) or util.binary(atext) or util.binary(btext):
32 raise util.Abort("don't know how to merge binary files")
32 raise error.Abort("don't know how to merge binary files")
33 simplemerge.Merge3Text.__init__(self, basetext, atext, btext,
33 simplemerge.Merge3Text.__init__(self, basetext, atext, btext,
34 base, a, b)
34 base, a, b)
35
35
@@ -321,7 +321,7 b' bbb'
321 self.assertEquals(ml, MERGED_RESULT)
321 self.assertEquals(ml, MERGED_RESULT)
322
322
323 def test_binary(self):
323 def test_binary(self):
324 self.assertRaises(util.Abort, Merge3, ['\x00'], ['a'], ['b'])
324 self.assertRaises(error.Abort, Merge3, ['\x00'], ['a'], ['b'])
325
325
326 def test_dos_text(self):
326 def test_dos_text(self):
327 base_text = 'a\r\n'
327 base_text = 'a\r\n'
@@ -1028,8 +1028,8 b' Create repo without default path, pull t'
1028
1028
1029 Ensure a full traceback, not just the SubrepoAbort part
1029 Ensure a full traceback, not just the SubrepoAbort part
1030
1030
1031 $ hg -R issue1852b update --traceback 2>&1 | grep 'raise util\.Abort'
1031 $ hg -R issue1852b update --traceback 2>&1 | grep 'raise error\.Abort'
1032 raise util.Abort(_("default path for subrepository not found"))
1032 raise error.Abort(_("default path for subrepository not found"))
1033
1033
1034 Pull -u now doesn't help
1034 Pull -u now doesn't help
1035
1035
@@ -166,7 +166,7 b" print u2.config('foobar', 'baz', untrust"
166 print
166 print
167 print "# error handling"
167 print "# error handling"
168
168
169 def assertraises(f, exc=util.Abort):
169 def assertraises(f, exc=error.Abort):
170 try:
170 try:
171 f()
171 f()
172 except exc as inst:
172 except exc as inst:
General Comments 0
You need to be logged in to leave comments. Login now