py3: stop using util.iterfile()
authorGregory Szorc <gregory.szorc@gmail.com>
Mon, 21 Feb 2022 12:42:48 -0700
changeset 48941 fd5b8e696b75
parent 48940 2974cdda819b
child 48942 bce8f66d3045
py3: stop using util.iterfile() The Python 3 implementation is a no-op. So this is equivalent. We still keep util.iterfile() around for backwards API compatibility to help the Python 3 migration. It can be deleted in a future release. Differential Revision: https://phab.mercurial-scm.org/D12347
hgext/convert/common.py
hgext/convert/convcmd.py
mercurial/match.py
mercurial/patch.py
mercurial/store.py
--- a/hgext/convert/common.py	Thu Mar 03 07:56:47 2022 -0800
+++ b/hgext/convert/common.py	Mon Feb 21 12:42:48 2022 -0700
@@ -552,7 +552,7 @@
             if err.errno != errno.ENOENT:
                 raise
             return
-        for i, line in enumerate(util.iterfile(fp)):
+        for i, line in enumerate(fp):
             line = line.splitlines()[0].rstrip()
             if not line:
                 # Ignore blank lines
--- a/hgext/convert/convcmd.py	Thu Mar 03 07:56:47 2022 -0800
+++ b/hgext/convert/convcmd.py	Mon Feb 21 12:42:48 2022 -0700
@@ -242,7 +242,7 @@
         m = {}
         try:
             fp = open(path, b'rb')
-            for i, line in enumerate(util.iterfile(fp)):
+            for i, line in enumerate(fp):
                 line = line.splitlines()[0].rstrip()
                 if not line:
                     # Ignore blank lines
--- a/mercurial/match.py	Thu Mar 03 07:56:47 2022 -0800
+++ b/mercurial/match.py	Mon Feb 21 12:42:48 2022 -0700
@@ -1611,7 +1611,7 @@
     patterns = []
 
     fp = open(filepath, b'rb')
-    for lineno, line in enumerate(util.iterfile(fp), start=1):
+    for lineno, line in enumerate(fp, start=1):
         if b"#" in line:
             global _commentre
             if not _commentre:
--- a/mercurial/patch.py	Thu Mar 03 07:56:47 2022 -0800
+++ b/mercurial/patch.py	Mon Feb 21 12:42:48 2022 -0700
@@ -1259,7 +1259,7 @@
                     # Remove comment lines
                     patchfp = open(patchfn, 'rb')
                     ncpatchfp = stringio()
-                    for line in util.iterfile(patchfp):
+                    for line in patchfp:
                         line = util.fromnativeeol(line)
                         if not line.startswith(b'#'):
                             ncpatchfp.write(line)
@@ -2343,7 +2343,7 @@
     ui.debug(b'Using external patch tool: %s\n' % cmd)
     fp = procutil.popen(cmd, b'rb')
     try:
-        for line in util.iterfile(fp):
+        for line in fp:
             line = line.rstrip()
             ui.note(line + b'\n')
             if line.startswith(b'patching file '):
--- a/mercurial/store.py	Thu Mar 03 07:56:47 2022 -0800
+++ b/mercurial/store.py	Mon Feb 21 12:42:48 2022 -0700
@@ -661,7 +661,7 @@
         """make sure there is no empty string in entries"""
         if b'' in self.entries:
             fp.seek(0)
-            for n, line in enumerate(util.iterfile(fp)):
+            for n, line in enumerate(fp):
                 if not line.rstrip(b'\n'):
                     t = _(b'invalid entry in fncache, line %d') % (n + 1)
                     if warn: