diff mercurial/changegroup.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 7469067de2ba
children be0489770925
line wrap: on
line diff
--- a/mercurial/changegroup.py	Mon Oct 05 22:49:24 2015 -0700
+++ b/mercurial/changegroup.py	Thu Oct 08 12:55:45 2015 -0700
@@ -37,7 +37,7 @@
     '''read n bytes from stream.read and abort if less was available'''
     s = stream.read(n)
     if len(s) < n:
-        raise util.Abort(_("stream ended unexpectedly"
+        raise error.Abort(_("stream ended unexpectedly"
                            " (got %d bytes, expected %d)")
                           % (len(s), n))
     return s
@@ -48,7 +48,7 @@
     l = struct.unpack(">l", d)[0]
     if l <= 4:
         if l:
-            raise util.Abort(_("invalid chunk length %d") % l)
+            raise error.Abort(_("invalid chunk length %d") % l)
         return ""
     return readexactly(stream, l - 4)
 
@@ -144,12 +144,12 @@
         # compression argument is only for the bundle2 case
         assert compression is None
         if cg.version != '01':
-            raise util.Abort(_('old bundle types only supports v1 '
-                               'changegroups'))
+            raise error.Abort(_('old bundle types only supports v1 '
+                                'changegroups'))
         header, comp = bundletypes[bundletype]
         if comp not in util.compressors:
-            raise util.Abort(_('unknown stream compression type: %s')
-                             % comp)
+            raise error.Abort(_('unknown stream compression type: %s')
+                              % comp)
         z = util.compressors[comp]()
         subchunkiter = cg.getchunks()
         def chunkiter():
@@ -175,7 +175,7 @@
         if alg == 'UN':
             alg = None # get more modern without breaking too much
         if not alg in util.decompressors:
-            raise util.Abort(_('unknown stream compression type: %s')
+            raise error.Abort(_('unknown stream compression type: %s')
                              % alg)
         if alg == 'BZ':
             alg = '_truncatedBZ'
@@ -198,7 +198,7 @@
         l = struct.unpack(">l", d)[0]
         if l <= 4:
             if l:
-                raise util.Abort(_("invalid chunk length %d") % l)
+                raise error.Abort(_("invalid chunk length %d") % l)
             return 0
         if self.callback:
             self.callback()
@@ -477,7 +477,7 @@
         for i, fname in enumerate(sorted(changedfiles)):
             filerevlog = repo.file(fname)
             if not filerevlog:
-                raise util.Abort(_("empty or missing revlog for %s") % fname)
+                raise error.Abort(_("empty or missing revlog for %s") % fname)
 
             linkrevnodes = linknodes(filerevlog, fname)
             # Lookup for filenodes, we collected the linkrev nodes above in the
@@ -688,9 +688,9 @@
         o = len(fl)
         try:
             if not fl.addgroup(source, revmap, trp):
-                raise util.Abort(_("received file revlog group is empty"))
+                raise error.Abort(_("received file revlog group is empty"))
         except error.CensoredBaseError as e:
-            raise util.Abort(_("received delta base is censored: %s") % e)
+            raise error.Abort(_("received delta base is censored: %s") % e)
         revisions += len(fl) - o
         files += 1
         if f in needfiles:
@@ -700,7 +700,7 @@
                 if n in needs:
                     needs.remove(n)
                 else:
-                    raise util.Abort(
+                    raise error.Abort(
                         _("received spurious file revlog entry"))
             if not needs:
                 del needfiles[f]
@@ -712,7 +712,7 @@
             try:
                 fl.rev(n)
             except error.LookupError:
-                raise util.Abort(
+                raise error.Abort(
                     _('missing file data for %s:%s - run hg verify') %
                     (f, hex(n)))
 
@@ -784,7 +784,7 @@
         efiles = len(efiles)
 
         if not (srccontent or emptyok):
-            raise util.Abort(_("received changelog group is empty"))
+            raise error.Abort(_("received changelog group is empty"))
         clend = len(cl)
         changesets = clend - clstart
         repo.ui.progress(_('changesets'), None)