Patchwork [7,of,8] patch: use absolute_import

login
register
mail settings
Submitter Gregory Szorc
Date Dec. 22, 2015, 6 a.m.
Message ID <3af50f2d9359b2491939.1450764042@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/12229/
State Accepted
Headers show

Comments

Gregory Szorc - Dec. 22, 2015, 6 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1450762432 28800
#      Mon Dec 21 21:33:52 2015 -0800
# Node ID 3af50f2d9359b2491939daa0c89b9e73950c6023
# Parent  d48fd95558ba134a260efaa190cae48f09dc5825
patch: use absolute_import

Patch

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -1,24 +1,46 @@ 
 # patch.py - patch file parsing routines
 #
 # Copyright 2006 Brendan Cully <brendan@kublai.com>
 # Copyright 2007 Chris Mason <chris.mason@oracle.com>
 #
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
+from __future__ import absolute_import
+
+import cStringIO
 import collections
-import cStringIO, email, os, errno, re, posixpath, copy
-import tempfile, zlib, shutil
+import copy
+import email
+import errno
+import os
+import posixpath
+import re
+import shutil
+import tempfile
+import zlib
 
-from i18n import _
-from node import hex, short
-import base85, mdiff, scmutil, util, diffhelpers, copies, encoding, error
-import pathutil
+from .i18n import _
+from .node import (
+    hex,
+    short,
+)
+from . import (
+    base85,
+    copies,
+    diffhelpers,
+    encoding,
+    error,
+    mdiff,
+    pathutil,
+    scmutil,
+    util,
+)
 
 gitre = re.compile('diff --git a/(.*) b/(.*)')
 tabsplitter = re.compile(r'(\t+|[^\t]+)')
 
 class PatchError(Exception):
     pass
 
 
@@ -1441,17 +1463,17 @@  def reversehunks(hunks):
      d
     @@ -5,3 +6,2 @@
      5
      d
     -lastline
 
     '''
 
-    import crecord as crecordmod
+    from . import crecord as crecordmod
     newhunks = []
     for c in hunks:
         if isinstance(c, crecordmod.uihunk):
             # curses hunks encapsulate the record hunk in _hunk
             c = c._hunk
         if isinstance(c, recordhunk):
             for j, line in enumerate(c.hunk):
                 if line.startswith("-"):
diff --git a/tests/test-check-py3-compat.t b/tests/test-check-py3-compat.t
--- a/tests/test-check-py3-compat.t
+++ b/tests/test-check-py3-compat.t
@@ -112,17 +112,16 @@ 
   mercurial/keepalive.py not using absolute_import
   mercurial/keepalive.py requires print_function
   mercurial/localrepo.py not using absolute_import
   mercurial/lsprof.py requires print_function
   mercurial/lsprofcalltree.py not using absolute_import
   mercurial/lsprofcalltree.py requires print_function
   mercurial/mail.py requires print_function
   mercurial/manifest.py not using absolute_import
-  mercurial/patch.py not using absolute_import
   mercurial/pvec.py not using absolute_import
   mercurial/py3kcompat.py not using absolute_import
   setup.py not using absolute_import
   tests/filterpyflakes.py requires print_function
   tests/generate-working-copy-states.py requires print_function
   tests/get-with-headers.py requires print_function
   tests/heredoctest.py requires print_function
   tests/hypothesishelpers.py not using absolute_import