changeset 1555:cff81f35b31e

cleanup: reference Abort from mercurial.error instead of mercurial.util It's been there since hg 1.7 or so, which lets us avoid any need for compat shims.
author Augie Fackler <raf@durin42.com>
date Sat, 24 Mar 2018 16:39:30 -0400
parents 258fb67fb956
children 53d170a6c3c8
files hgsubversion/__init__.py hgsubversion/editor.py hgsubversion/layouts/__init__.py hgsubversion/layouts/custom.py hgsubversion/maps.py hgsubversion/pushmod.py hgsubversion/replay.py hgsubversion/stupid.py hgsubversion/svncommands.py hgsubversion/svnexternals.py hgsubversion/svnmeta.py hgsubversion/svnrepo.py hgsubversion/util.py hgsubversion/verify.py hgsubversion/wrappers.py tests/test_pull.py tests/test_push_command.py tests/test_svn_pre_commit_hooks.py tests/test_utility_commands.py
diffstat 19 files changed, 85 insertions(+), 70 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/__init__.py
+++ b/hgsubversion/__init__.py
@@ -28,6 +28,7 @@ try:
 except ImportError:
     # We only *use* the exchange module in hg 3.2+, so this is safe
     pass
+from mercurial import error as hgerror
 from mercurial import extensions
 from mercurial import help
 from mercurial import hg
@@ -349,7 +350,7 @@ def _templatehelper(ctx, kw):
     elif kw == 'svnrev':
         return convertinfo[40:].rsplit('@', 1)[-1]
     else:
-        raise hgutil.Abort('unrecognized hgsubversion keyword %s' % kw)
+        raise hgerror.Abort('unrecognized hgsubversion keyword %s' % kw)
 
 @templatekeyword('svnrev')
 def svnrevkw(**args):
--- a/hgsubversion/editor.py
+++ b/hgsubversion/editor.py
@@ -4,6 +4,7 @@ import tempfile
 import shutil
 import os
 
+from mercurial import error as hgerror
 from mercurial import util as hgutil
 from mercurial import revlog
 from mercurial import node
@@ -575,7 +576,7 @@ class HgEditor(svnwrap.Editor):
 
         handler = svnwrap.apply_txdelta(base, target)
         if not callable(handler): # pragma: no cover
-            raise hgutil.Abort('Error in Subversion bindings: '
+            raise hgerror.Abort('Error in Subversion bindings: '
                                'cannot call handler!')
         def txdelt_window(window):
             try:
@@ -611,7 +612,7 @@ class HgEditor(svnwrap.Editor):
                 if e.args[1] == svnwrap.ERR_INCOMPLETE_DATA:
                     self.addmissing(path)
                 else: # pragma: no cover
-                    raise hgutil.Abort(*e.args)
+                    raise hgerror.Abort(*e.args)
             except: # pragma: no cover
                 self._exception_info = sys.exc_info()
                 raise
--- a/hgsubversion/layouts/__init__.py
+++ b/hgsubversion/layouts/__init__.py
@@ -9,6 +9,7 @@ NB: this has a long way to go before it 
 
 """
 
+from mercurial import error as hgerror
 from mercurial import util as hgutil
 
 import custom
@@ -39,5 +40,5 @@ def layout_from_name(name, meta):
     """
 
     if name not in NAME_TO_CLASS:
-        raise hgutil.Abort('Unknown hgsubversion layout: %s' % name)
+        raise hgerror.Abort('Unknown hgsubversion layout: %s' % name)
     return NAME_TO_CLASS[name](meta)
--- a/hgsubversion/layouts/custom.py
+++ b/hgsubversion/layouts/custom.py
@@ -6,6 +6,7 @@ want a couple of branches.
 
 
 """
+from mercurial import error as hgerror
 
 import base
 
@@ -30,12 +31,12 @@ class CustomLayout(base.BaseLayout):
             for other_svn in self.svn_to_hg:
                 if other_svn == svn_path:
                     msg = 'specified two hg branches for svn path %s: %s and %s'
-                    raise hgutil.Abort(msg % (svn_path, other_hg, hg_branch))
+                    raise hgerror.Abort(msg % (svn_path, other_hg, hg_branch))
 
                 if (other_svn.startswith(svn_path + '/') or
                     svn_path.startswith(other_svn + '/')):
                     msg = 'specified mappings for nested svn paths: %s and %s'
-                    raise hgutl.Abort(msg % (svn_path, other_svn))
+                    raise hgerror.Abort(msg % (svn_path, other_svn))
 
             self.svn_to_hg[svn_path] = hg_branch
             self.hg_to_svn[hg_branch] = svn_path
--- a/hgsubversion/maps.py
+++ b/hgsubversion/maps.py
@@ -255,7 +255,7 @@ class AuthorMap(BaseMap):
             retcode = process.poll()
             if retcode:
                 msg = 'map author command "%s" exited with error'
-                raise hgutil.Abort(msg % cmd)
+                raise error.Abort(msg % cmd)
             self[author] = result = output.strip()
         if not result:
             if self._defaultauthors:
@@ -264,7 +264,7 @@ class AuthorMap(BaseMap):
                 self._ui.debug(msg % (author, result))
             else:
                 msg = 'author %s has no entry in the author map!'
-                raise hgutil.Abort(msg % author)
+                raise error.Abort(msg % author)
         self._ui.debug('mapping author "%s" to "%s"\n' % (author, result))
         return result
 
@@ -302,7 +302,7 @@ class Tags(dict):
             raise error.Abort(
                 'tag map outdated, please run `hg svn rebuildmeta`')
         elif ver != self.VERSION:
-            raise hgutil.Abort('tagmap too new -- please upgrade')
+            raise error.Abort('tagmap too new -- please upgrade')
         for l in f:
             ha, revision, tag = l.split(' ', 2)
             revision = int(revision)
@@ -335,7 +335,7 @@ class Tags(dict):
 
     def __setitem__(self, tag, info):
         if not tag:
-            raise hgutil.Abort('tag cannot be empty')
+            raise error.Abort('tag cannot be empty')
         ha, revision = info
         f = open(self._filepath, 'a')
         f.write('%s %s %s\n' % (hex(ha), revision, tag))
@@ -429,7 +429,7 @@ class RevMap(dict):
             hgutil.unlinkpath(revmap._rowcountpath, ignoremissing=True)
             return self._readmapfile()
         if ver != self.VERSION:
-            raise hgutil.Abort('revmap too new -- please upgrade')
+            raise error.Abort('revmap too new -- please upgrade')
         return f
 
     @util.gcdisable
@@ -887,7 +887,7 @@ class FileMap(object):
         with open(self._filename) as f:
             ver = int(f.readline())
             if ver != self.VERSION:
-                raise hgutil.Abort('filemap too new -- please upgrade')
+                raise error.Abort('filemap too new -- please upgrade')
             self.load_fd(f, self._filename)
 
     def _write(self):
--- a/hgsubversion/pushmod.py
+++ b/hgsubversion/pushmod.py
@@ -1,3 +1,4 @@
+from mercurial import error as hgerror
 from mercurial import util as hgutil
 
 import svnwrap
@@ -208,11 +209,11 @@ def commit(ui, repo, rev_ctx, meta, base
         if len(e.args) > 0 and e.args[1] in (svnwrap.ERR_FS_TXN_OUT_OF_DATE,
                                              svnwrap.ERR_FS_CONFLICT,
                                              svnwrap.ERR_FS_ALREADY_EXISTS):
-            raise hgutil.Abort('Outgoing changesets parent is not at '
+            raise hgerror.Abort('Outgoing changesets parent is not at '
                                'subversion HEAD\n'
                                '(pull again and rebase on a newer revision)')
         elif len(e.args) > 0 and e.args[1] == svnwrap.ERR_REPOS_HOOK_FAILURE:
             # Special handling for svn hooks blocking error
-            raise hgutil.Abort(e.args[0])
+            raise hgerror.Abort(e.args[0])
         else:
             raise
--- a/hgsubversion/replay.py
+++ b/hgsubversion/replay.py
@@ -1,6 +1,7 @@
 import errno
 import traceback
 
+from mercurial import error as hgerror
 from mercurial import revlog
 from mercurial import node
 from mercurial import context
@@ -93,7 +94,7 @@ def _convert_rev(ui, meta, svn, r, tbdel
     for f in files_to_commit:
         if not meta.is_path_valid(f):
             if failoninvalid:
-                raise hgutil.Abort('file %s should not be in commit list' % f)
+                raise hgerror.Abort('file %s should not be in commit list' % f)
             continue
         p, b = meta.split_branch_path(f)[:2]
         if b not in branch_batches:
--- a/hgsubversion/stupid.py
+++ b/hgsubversion/stupid.py
@@ -3,6 +3,7 @@ import errno
 import re
 
 from mercurial import context
+from mercurial import error as hgerror
 from mercurial import node
 from mercurial import patch
 from mercurial import revlog
@@ -633,14 +634,14 @@ def branches_in_paths(meta, tbdelta, pat
 
 def convert_rev(ui, meta, svn, r, tbdelta, firstrun):
     if svnwrap.subversion_version >= (1, 9, 0):
-        raise hgutil.Abort(
+        raise hgerror.Abort(
             "hgsubversion doesn't support stupid mode with Subversion 1.9."
             ' Please email hgsubversion@googlegroups.com and let us know you'
             ' saw this, otherwise we may remove stupid mode entirely.')
     # this server fails at replay
 
     if meta.filemap:
-        raise hgutil.Abort('filemaps currently unsupported with stupid replay.')
+        raise hgerror.Abort('filemaps currently unsupported with stupid replay.')
 
     branches = branches_in_paths(meta, tbdelta, r.paths, r.revnum,
                                  svn.checkpath, svn.list_files, firstrun)
--- a/hgsubversion/svncommands.py
+++ b/hgsubversion/svncommands.py
@@ -51,7 +51,7 @@ def _buildmeta(ui, repo, args, partial=F
         dest = args[0]
         validateuuid = True
     elif len(args) > 1:
-        raise hgutil.Abort('rebuildmeta takes 1 or no arguments')
+        raise error.Abort('rebuildmeta takes 1 or no arguments')
     url = repo.ui.expandpath(dest or repo.ui.config('paths', 'default-push') or
                              repo.ui.config('paths', 'default') or '')
 
@@ -196,7 +196,7 @@ def _buildmeta(ui, repo, args, partial=F
                 if svn is None:
                     svn = svnrepo.svnremoterepo(ui, url).svn
                 if uuid != svn.uuid:
-                    raise hgutil.Abort('remote svn repository identifier '
+                    raise error.Abort('remote svn repository identifier '
                                        'does not match')
             meta.uuid = uuid
 
@@ -343,7 +343,7 @@ def genignore(ui, repo, force=False, **o
 
     ignpath = repo.wvfs.join('.hgignore')
     if not force and os.path.exists(ignpath):
-        raise hgutil.Abort('not overwriting existing .hgignore, try --force?')
+        raise error.Abort('not overwriting existing .hgignore, try --force?')
     svn = svnrepo.svnremoterepo(repo.ui).svn
     meta = repo.svnmeta()
     hashes = meta.revmap.hashes()
@@ -470,7 +470,7 @@ def svn(ui, repo, subcommand, *args, **o
         commandfunc = table[subcommand]
         return commandfunc(ui, args=args, repo=repo, **opts)
     except svnwrap.SubversionConnectionException, e:
-        raise hgutil.Abort(*e.args)
+        raise error.Abort(*e.args)
     except TypeError:
         tb = traceback.extract_tb(sys.exc_info()[2])
         if len(tb) == 1:
--- a/hgsubversion/svnexternals.py
+++ b/hgsubversion/svnexternals.py
@@ -1,6 +1,7 @@
 import cStringIO
 
 import os, re, shutil, stat, subprocess
+from mercurial import error as hgerror
 from mercurial import util as hgutil
 from mercurial.i18n import _
 from mercurial import subrepo
@@ -58,7 +59,7 @@ class externalsfile(dict):
             if line.startswith('['):
                 line = line.strip()
                 if line[-1] != ']':
-                    raise hgutil.Abort('invalid externals section name: %s' % line)
+                    raise hgerror.Abort('invalid externals section name: %s' % line)
                 target = line[1:-1]
                 if target == '.':
                     target = ''
@@ -228,7 +229,7 @@ def parsedefinitions(ui, repo, svnroot, 
     for i, d in enumerate(defs):
         for d2 in defs[i+1:]:
             if d2[0].startswith(d[0] + '/'):
-                raise hgutil.Abort(_('external directories cannot nest:\n%s\n%s')
+                raise hgerror.Abort(_('external directories cannot nest:\n%s\n%s')
                                    % (d[0], d2[0]))
     return defs
 
@@ -264,22 +265,22 @@ def getsvninfo(svnurl):
                          stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
     stdout = p.communicate()[0]
     if p.returncode:
-        raise hgutil.Abort(_('cannot get information about %s')
+        raise hgerror.Abort(_('cannot get information about %s')
                          % svnurl)
     m = re.search(r'<root>(.*)</root>', stdout, re.S)
     if not m:
-        raise hgutil.Abort(_('cannot find SVN repository root from %s')
+        raise hgerror.Abort(_('cannot find SVN repository root from %s')
                            % svnurl)
     root = m.group(1).rstrip('/')
 
     m = re.search(r'<url>(.*)</url>', stdout, re.S)
     if not m:
-        raise hgutil.Abort(_('cannot find SVN repository URL from %s') % svnurl)
+        raise hgerror.Abort(_('cannot find SVN repository URL from %s') % svnurl)
     url = m.group(1)
 
     m = re.search(r'<entry[^>]+revision="([^"]+)"', stdout, re.S)
     if not m:
-        raise hgutil.Abort(_('cannot find SVN revision from %s') % svnurl)
+        raise hgerror.Abort(_('cannot find SVN revision from %s') % svnurl)
     rev = m.group(1)
     return url, root, rev
 
@@ -348,13 +349,13 @@ class externalsupdater:
             self.ui.debug(line)
         p.wait()
         if p.returncode != 0:
-            raise hgutil.Abort("subprocess '%s' failed" % ' '.join(args))
+            raise hgerror.Abort("subprocess '%s' failed" % ' '.join(args))
 
 def updateexternals(ui, args, repo, **opts):
     """update repository externals
     """
     if len(args) > 2:
-        raise hgutil.Abort(_('updateexternals expects at most one changeset'))
+        raise hgerror.Abort(_('updateexternals expects at most one changeset'))
     node = None
     if len(args) == 2:
         svnurl = util.normalize_url(repo.ui.expandpath(args[0]))
@@ -384,7 +385,7 @@ def updateexternals(ui, args, repo, **op
         elif action == 'd':
             updater.delete(ext[0])
         else:
-            raise hgutil.Abort(_('unknown update actions: %r') % action)
+            raise hgerror.Abort(_('unknown update actions: %r') % action)
 
     file(repo.vfs.join('svn/externals'), 'wb').write(newext)
 
@@ -421,7 +422,7 @@ def getchanges(ui, repo, parentctx, exts
     elif mode == 'ignore':
         files = {}
     else:
-        raise hgutil.Abort(_('unknown externals modes: %s') % mode)
+        raise hgerror.Abort(_('unknown externals modes: %s') % mode)
 
     # Should the really be updated?
     updates = {}
@@ -455,7 +456,7 @@ def parse(ui, ctx):
     elif mode == 'ignore':
         pass
     else:
-        raise hgutil.Abort(_('unknown externals modes: %s') % mode)
+        raise hgerror.Abort(_('unknown externals modes: %s') % mode)
     return external
 
 _notset = object()
--- a/hgsubversion/svnmeta.py
+++ b/hgsubversion/svnmeta.py
@@ -3,6 +3,7 @@ import os
 import tempfile
 
 from mercurial import context
+from mercurial import error as hgerror
 from mercurial import util as hgutil
 from mercurial import revlog
 from mercurial import node
@@ -164,7 +165,7 @@ class SVNMeta(object):
             rootlist = svn.list_dir('', revision=revision)
         except svnwrap.SubversionException, e:
             err = "%s (subversion error: %d)" % (e.args[0], e.args[1])
-            raise hgutil.Abort(err)
+            raise hgerror.Abort(err)
         if sum(map(lambda x: x in rootlist, ('branches', 'tags', 'trunk'))):
             layout = 'standard'
         else:
@@ -240,7 +241,7 @@ class SVNMeta(object):
             if subdir is None:
                 self.__subdir = stored_subdir
             elif subdir and subdir != stored_subdir:
-                raise hgutil.Abort('unable to work on a different path in the '
+                raise hgerror.Abort('unable to work on a different path in the '
                                    'repository')
             else:
                 self.__subdir = subdir
@@ -248,7 +249,7 @@ class SVNMeta(object):
             util.dump(subdir, subdirfile)
             self.__subdir = subdir
         elif not self._skiperror:
-            raise hgutil.Abort("hgsubversion metadata unavailable; "
+            raise hgerror.Abort("hgsubversion metadata unavailable; "
                                "please run 'hg svn rebuildmeta'")
 
     subdir = property(_get_subdir, _set_subdir, None,
@@ -265,13 +266,13 @@ class SVNMeta(object):
             stored_uuid = util.load(uuidfile)
             assert stored_uuid
             if uuid and uuid != stored_uuid:
-                raise hgutil.Abort('unable to operate on unrelated repository')
+                raise hgerror.Abort('unable to operate on unrelated repository')
             self.__uuid = uuid or stored_uuid
         elif uuid:
             util.dump(uuid, uuidfile)
             self.__uuid = uuid
         elif not self._skiperror:
-            raise hgutil.Abort("hgsubversion metadata unavailable; "
+            raise hgerror.Abort("hgsubversion metadata unavailable; "
                                "please run 'hg svn rebuildmeta'")
 
     uuid = property(_get_uuid, _set_uuid, None,
@@ -372,7 +373,7 @@ class SVNMeta(object):
         elif impl is None:
             return self._defaultrevmapclass
         else:
-            raise hgutil.Abort('unknown revmapimpl: %s' % impl)
+            raise hgerror.Abort('unknown revmapimpl: %s' % impl)
 
     def fixdate(self, date):
         if date is not None:
--- a/hgsubversion/svnrepo.py
+++ b/hgsubversion/svnrepo.py
@@ -133,7 +133,7 @@ class svnremoterepo(peerrepository):
         if path is None:
             path = self.ui.config('paths', 'default')
         if not path:
-            raise hgutil.Abort('no Subversion URL specified. Expect '
+            raise error.Abort('no Subversion URL specified. Expect '
                                '[path] default= or [path] default-push= '
                                'SVN URL entries in hgrc.')
         self.path = path
@@ -179,7 +179,7 @@ class svnremoterepo(peerrepository):
             return svnwrap.SubversionRepo(auth[0], auth[1], auth[2], password_stores=self.password_stores)
         except svnwrap.SubversionConnectionException, e:
             self.ui.traceback()
-            raise hgutil.Abort(e)
+            raise error.Abort(e)
 
     @property
     def ui(self):
@@ -199,7 +199,7 @@ class svnremoterepo(peerrepository):
         Whenever this function is hit, we abort. The traceback is useful for
         figuring out where to intercept the functionality.
         """
-        raise hgutil.Abort('command unavailable for Subversion repositories')
+        raise error.Abort('command unavailable for Subversion repositories')
 
     def pushkey(self, namespace, key, old, new):
         return False
@@ -251,7 +251,7 @@ def instance(ui, url, create):
             ui.note('(falling back to Subversion support)\n')
 
     if create:
-        raise hgutil.Abort('cannot create new remote Subversion repository')
+        raise error.Abort('cannot create new remote Subversion repository')
 
     svnwrap.prompt_callback(SubversionPrompt(ui))
     return svnremoterepo(ui, url)
--- a/hgsubversion/util.py
+++ b/hgsubversion/util.py
@@ -270,7 +270,8 @@ def outgoing_revisions(repo, reverse_map
         outgoing_rev_hashes.append(sourcerev.node())
         sourcerev = sourcerev.parents()
         if len(sourcerev) != 1:
-            raise hgutil.Abort("Sorry, can't find svn parent of a merge revision.")
+            raise error.Abort(
+                "Sorry, can't find svn parent of a merge revision.")
         sourcerev = sourcerev[0]
     if sourcerev.node() != node.nullid:
         return outgoing_rev_hashes
@@ -287,7 +288,8 @@ def outgoing_common_and_heads(repo, reve
            and sourcecx.node() != node.nullid):
         ps = sourcecx.parents()
         if len(ps) != 1:
-            raise hgutil.Abort("Sorry, can't find svn parent of a merge revision.")
+            raise error.Abort(
+                "Sorry, can't find svn parent of a merge revision.")
         sourcecx = ps[0]
     if sourcecx.node() != node.nullid:
         return ([sourcecx.node()], [sourcerev])
@@ -350,8 +352,8 @@ def revset_fromsvn(repo, subset, x):
 
     meta = repo.svnmeta(skiperrorcheck=True)
     if not meta.revmapexists:
-        raise hgutil.Abort("svn metadata is missing - "
-                           "run 'hg svn rebuildmeta' to reconstruct it")
+        raise error.Abort("svn metadata is missing - "
+                          "run 'hg svn rebuildmeta' to reconstruct it")
     tonode = repo.changelog.node
     hashes = meta.revmap.hashes()
     return subset.filter(lambda r: tonode(r) in hashes)
@@ -371,8 +373,8 @@ def revset_svnrev(repo, subset, x):
 
     meta = repo.svnmeta(skiperrorcheck=True)
     if not meta.revmapexists:
-        raise hgutil.Abort("svn metadata is missing - "
-                           "run 'hg svn rebuildmeta' to reconstruct it")
+        raise error.Abort("svn metadata is missing - "
+                          "run 'hg svn rebuildmeta' to reconstruct it")
     torev = repo.changelog.rev
     revs = revset.baseset(torev(r) for r in meta.revmap.revhashes(revnum))
     return subset & revs
--- a/hgsubversion/verify.py
+++ b/hgsubversion/verify.py
@@ -24,7 +24,7 @@ def verify(ui, repo, args=None, **opts):
         return 0
     convert_revision = ctx.extra().get('convert_revision')
     if convert_revision is None or not convert_revision.startswith('svn:'):
-        raise hgutil.Abort('revision %s not from SVN' % ctx)
+        raise error.Abort('revision %s not from SVN' % ctx)
 
     if args:
         url = repo.ui.expandpath(args[0])
@@ -163,8 +163,8 @@ def verify(ui, repo, args=None, **opts):
                 stream = svnwrap.SimpleStringIO(closing=False)
                 handler = svnwrap.apply_txdelta('', stream)
                 if not callable(handler):
-                    raise hgutil.Abort('Error in Subversion bindings: '
-                                       'cannot call handler!')
+                    raise error.Abort('Error in Subversion bindings: '
+                                      'cannot call handler!')
                 def txdelt_window(window):
                     handler(window)
                     # window being None means we're done
--- a/hgsubversion/wrappers.py
+++ b/hgsubversion/wrappers.py
@@ -11,6 +11,7 @@ try:
 except ImportError:
     # We only *use* the exchange module in hg 3.2+, so this is safe
     pass
+from mercurial import error as hgerror
 from mercurial import patch
 from mercurial import hg
 from mercurial import util as hgutil
@@ -68,7 +69,7 @@ def parents(orig, ui, repo, *args, **opt
     hashes = meta.revmap.hashes()
     ha = util.parentrev(ui, repo, meta, hashes)
     if ha.node() == node.nullid:
-        raise hgutil.Abort('No parent svn revision!')
+        raise hgerror.Abort('No parent svn revision!')
     displayer = cmdutil.show_changeset(ui, repo, opts, buffered=False)
     displayer.show(ha)
     return 0
@@ -432,7 +433,7 @@ def pull(repo, source, heads=[], force=F
             if meta.layout != 'single':
                 msg = ('branch cannot be specified for Subversion clones using '
                        'standard directory layout')
-                raise hgutil.Abort(msg)
+                raise hgerror.Abort(msg)
 
             meta.branchmap['default'] = meta.branch
 
@@ -446,7 +447,7 @@ def pull(repo, source, heads=[], force=F
 
             if start > 0:
                 if meta.layout == 'standard':
-                    raise hgutil.Abort('non-zero start revisions are only '
+                    raise hgerror.Abort('non-zero start revisions are only '
                                        'supported for single-directory clones.')
                 ui.note('starting at revision %d; any prior will be ignored\n'
                         % start)
@@ -518,7 +519,7 @@ def pull(repo, source, heads=[], force=F
                             ui.status('Got a 502, retrying (%s)\n' % tries)
                         else:
                             ui.traceback()
-                            raise hgutil.Abort(*e.args)
+                            raise hgerror.Abort(*e.args)
 
                 lastpulled = r.revnum
 
--- a/tests/test_pull.py
+++ b/tests/test_pull.py
@@ -2,6 +2,7 @@ import test_util
 
 import os.path
 import subprocess
+from mercurial import error as hgerror
 from mercurial import node
 from mercurial import ui
 from mercurial import util as hgutil
@@ -47,7 +48,7 @@ class TestPull(test_util.TestBase):
         self.add_svn_rev(repo_path, {'trunk/alpha': 'Changed one way'})
         try:
             commands.pull(self.repo.ui, repo, update=True)
-        except hgutil.Abort:
+        except hgerror.Abort:
             # hg < 1.9 raised when crossing branches
             pass
         self.assertEqual(state, repo[None].parents())
--- a/tests/test_push_command.py
+++ b/tests/test_push_command.py
@@ -12,6 +12,7 @@ import unittest
 
 from mercurial import context
 from mercurial import commands
+from mercurial import error as hgerror
 from mercurial import hg
 from mercurial import node
 from mercurial import revlog
@@ -102,7 +103,7 @@ class PushTests(test_util.TestBase):
         old_tip = repo['tip'].node()
         try:
           self.pushrevisions()
-        except hgutil.Abort, e:
+        except hgerror.Abort, e:
           assert "pull again and rebase" in str(e)
         tip = self.repo['tip']
         self.assertEqual(tip.node(), old_tip)
@@ -131,7 +132,7 @@ class PushTests(test_util.TestBase):
         repo.wwrite('beta', 'something else', '')
         try:
             self.pushrevisions()
-        except hgutil.Abort:
+        except hgerror.Abort:
             pass
         tip = self.repo['tip']
         self.assertEqual(new_hash, tip.node())
@@ -657,7 +658,7 @@ class PushTests(test_util.TestBase):
         try:
             self.pushrevisions()
             assert False, 'This should have aborted!'
-        except hgutil.Abort, e:
+        except hgerror.Abort, e:
             self.assertEqual(e.args[0],
                              'Outgoing changesets parent is not at subversion '
                              'HEAD\n'
--- a/tests/test_svn_pre_commit_hooks.py
+++ b/tests/test_svn_pre_commit_hooks.py
@@ -3,9 +3,9 @@ import sys
 import test_util
 import unittest
 
-from mercurial import hg
 from mercurial import commands
-from mercurial import util
+from mercurial import error
+from mercurial import hg
 
 
 class TestSvnPreCommitHooks(test_util.TestBase):
@@ -28,4 +28,4 @@ class TestSvnPreCommitHooks(test_util.Te
         changes = [('narf/a', 'narf/a', 'ohai',),
                    ]
         self.commitchanges(changes)
-        self.assertRaises(util.Abort, self.pushrevisions)
+        self.assertRaises(error.Abort, self.pushrevisions)
--- a/tests/test_utility_commands.py
+++ b/tests/test_utility_commands.py
@@ -5,6 +5,7 @@ import unittest
 import re
 
 from hgext import rebase
+from mercurial import error as hgerror
 from mercurial import hg
 from mercurial import revlog
 from mercurial import context
@@ -132,26 +133,26 @@ class UtilityTests(test_util.TestBase):
         svncommands.updatemeta(self.ui(), self.repo, [])
 
         test_util.rmtree(self.repo.vfs.join('svn'))
-        self.assertRaises(hgutil.Abort,
+        self.assertRaises(hgerror.Abort,
                           self.repo.svnmeta)
-        self.assertRaises(hgutil.Abort,
+        self.assertRaises(hgerror.Abort,
                           svncommands.info,
                           self.ui(), repo=self.repo, args=[])
-        self.assertRaises(hgutil.Abort,
+        self.assertRaises(hgerror.Abort,
                           svncommands.genignore,
                           self.ui(), repo=self.repo, args=[])
 
         os.remove(self.repo.vfs.join('hgrc'))
-        self.assertRaises(hgutil.Abort,
+        self.assertRaises(hgerror.Abort,
                           self.repo.svnmeta)
-        self.assertRaises(hgutil.Abort,
+        self.assertRaises(hgerror.Abort,
                           svncommands.info,
                           self.ui(), repo=self.repo, args=[])
-        self.assertRaises(hgutil.Abort,
+        self.assertRaises(hgerror.Abort,
                           svncommands.genignore,
                           self.ui(), repo=self.repo, args=[])
 
-        self.assertRaises(hgutil.Abort,
+        self.assertRaises(hgerror.Abort,
                           svncommands.rebuildmeta,
                           self.ui(), repo=self.repo, args=[])
 
@@ -369,7 +370,7 @@ missing file: binary3
         # rebuildmeta with original repo
         svncommands.rebuildmeta(self.ui(), repo=self.repo, args=[])
         # rebuildmeta with unrelated repo
-        self.assertRaises(hgutil.Abort,
+        self.assertRaises(hgerror.Abort,
                           svncommands.rebuildmeta,
                           self.ui(), repo=self.repo, args=[otherurl])
         # rebuildmeta --unsafe-skip-uuid-check with unrelated repo