diff hgext/convert/subversion.py @ 26587:56b2bcea2529

error: get Abort from 'error' instead of 'util' The home of 'Abort' is 'error' not 'util' however, a lot of code seems to be confused about that and gives all the credit to 'util' instead of the hardworking 'error'. In a spirit of equity, we break the cycle of injustice and give back to 'error' the respect it deserves. And screw that 'util' poser. For great justice.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 08 Oct 2015 12:55:45 -0700
parents baea47cafe75
children a434f15dc0f4
line wrap: on
line diff
--- a/hgext/convert/subversion.py	Mon Oct 05 22:49:24 2015 -0700
+++ b/hgext/convert/subversion.py	Thu Oct 08 12:55:45 2015 -0700
@@ -6,7 +6,7 @@
 import xml.dom.minidom
 import cPickle as pickle
 
-from mercurial import strutil, scmutil, util, encoding
+from mercurial import strutil, scmutil, util, encoding, error
 from mercurial.i18n import _
 
 propertycache = util.propertycache
@@ -141,7 +141,7 @@
     avoid memory collection issues.
     """
     if svn is None:
-        raise util.Abort(_('debugsvnlog could not load Subversion python '
+        raise error.Abort(_('debugsvnlog could not load Subversion python '
                            'bindings'))
 
     util.setbinary(sys.stdin)
@@ -159,14 +159,14 @@
             try:
                 entry = pickle.load(self._stdout)
             except EOFError:
-                raise util.Abort(_('Mercurial failed to run itself, check'
+                raise error.Abort(_('Mercurial failed to run itself, check'
                                    ' hg executable is in PATH'))
             try:
                 orig_paths, revnum, author, date, message = entry
             except (TypeError, ValueError):
                 if entry is None:
                     break
-                raise util.Abort(_("log stream exception '%s'") % entry)
+                raise error.Abort(_("log stream exception '%s'") % entry)
             yield entry
 
     def close(self):
@@ -327,12 +327,12 @@
 
         if revs:
             if len(revs) > 1:
-                raise util.Abort(_('subversion source does not support '
+                raise error.Abort(_('subversion source does not support '
                                    'specifying multiple revisions'))
             try:
                 latest = int(revs[0])
             except ValueError:
-                raise util.Abort(_('svn: revision %s is not an integer') %
+                raise error.Abort(_('svn: revision %s is not an integer') %
                                  revs[0])
 
         self.trunkname = self.ui.config('convert', 'svn.trunk',
@@ -343,7 +343,7 @@
             if self.startrev < 0:
                 self.startrev = 0
         except ValueError:
-            raise util.Abort(_('svn: start revision %s is not an integer')
+            raise error.Abort(_('svn: start revision %s is not an integer')
                              % self.startrev)
 
         try:
@@ -351,7 +351,7 @@
         except SvnPathNotFound:
             self.head = None
         if not self.head:
-            raise util.Abort(_('no revision found in module %s')
+            raise error.Abort(_('no revision found in module %s')
                              % self.module)
         self.last_changed = self.revnum(self.head)
 
@@ -396,8 +396,8 @@
                     # we are converting from inside this directory
                     return None
                 if cfgpath:
-                    raise util.Abort(_('expected %s to be at %r, but not found')
-                                 % (name, path))
+                    raise error.Abort(_('expected %s to be at %r, but not found'
+                                       ) % (name, path))
                 return None
             self.ui.note(_('found %s at %r\n') % (name, path))
             return path
@@ -415,7 +415,7 @@
             self.module += '/' + trunk
             self.head = self.latest(self.module, self.last_changed)
             if not self.head:
-                raise util.Abort(_('no revision found in module %s')
+                raise error.Abort(_('no revision found in module %s')
                                  % self.module)
 
         # First head in the list is the module's head
@@ -442,11 +442,11 @@
 
         if self.startrev and self.heads:
             if len(self.heads) > 1:
-                raise util.Abort(_('svn: start revision is not supported '
+                raise error.Abort(_('svn: start revision is not supported '
                                    'with more than one branch'))
             revnum = self.revnum(self.heads[0])
             if revnum < self.startrev:
-                raise util.Abort(
+                raise error.Abort(
                     _('svn: no revision found after start revision %d')
                                  % self.startrev)
 
@@ -502,7 +502,7 @@
                 stop = revnum + 1
             self._fetch_revisions(revnum, stop)
             if rev not in self.commits:
-                raise util.Abort(_('svn: revision %s not found') % revnum)
+                raise error.Abort(_('svn: revision %s not found') % revnum)
         revcommit = self.commits[rev]
         # caller caches the result, so free it here to release memory
         del self.commits[rev]
@@ -513,7 +513,7 @@
         if not re.match(r'svn:[0-9a-f]{8,8}-[0-9a-f]{4,4}-'
                               '[0-9a-f]{4,4}-[0-9a-f]{4,4}-[0-9a-f]'
                               '{12,12}(.*)\@[0-9]+$',revstr):
-            raise util.Abort(_('%s entry %s is not a valid revision'
+            raise error.Abort(_('%s entry %s is not a valid revision'
                                ' identifier') % (mapname, revstr))
 
     def numcommits(self):
@@ -951,7 +951,7 @@
         except SubversionException as xxx_todo_changeme:
             (inst, num) = xxx_todo_changeme.args
             if num == svn.core.SVN_ERR_FS_NO_SUCH_REVISION:
-                raise util.Abort(_('svn: branch has no revision %s')
+                raise error.Abort(_('svn: branch has no revision %s')
                                  % to_revnum)
             raise
 
@@ -1052,7 +1052,7 @@
         try:
             stdin.close()
         except IOError:
-            raise util.Abort(_('Mercurial failed to run itself, check'
+            raise error.Abort(_('Mercurial failed to run itself, check'
                                ' hg executable is in PATH'))
         return logstream(stdout)
 
@@ -1302,7 +1302,7 @@
                     return parents[0]
                 self.ui.warn(_('unexpected svn output:\n'))
                 self.ui.warn(output)
-                raise util.Abort(_('unable to cope with svn output'))
+                raise error.Abort(_('unable to cope with svn output'))
             if commit.rev:
                 self.run('propset', 'hg:convert-rev', commit.rev,
                          revprop=True, revision=rev)
@@ -1329,6 +1329,6 @@
         # repository and childmap would not list all revisions. Too bad.
         if rev in self.childmap:
             return True
-        raise util.Abort(_('splice map revision %s not found in subversion '
+        raise error.Abort(_('splice map revision %s not found in subversion '
                            'child map (revision lookups are not implemented)')
                          % rev)