[PATCH 18 of 21 WIP-PY3K] patch: use StringIO from py3kcompat
Matthew Turk
matthewturk at gmail.com
Mon Oct 12 16:25:02 CDT 2015
# HG changeset patch
# User Matthew Turk <matthewturk at gmail.com>
# Date 1444684349 18000
# Mon Oct 12 16:12:29 2015 -0500
# Node ID fd30b2b728e639f76d38d57c656f2edd859daced
# Parent 97c6284c8ba29a8c595e3bdcbb858e91e34332d1
patch: use StringIO from py3kcompat
diff -r 97c6284c8ba2 -r fd30b2b728e6 mercurial/patch.py
--- a/mercurial/patch.py Mon Oct 12 16:12:01 2015 -0500
+++ b/mercurial/patch.py Mon Oct 12 16:12:29 2015 -0500
@@ -9,7 +9,7 @@
from __future__ import absolute_import
import collections
-import cStringIO, email, os, errno, re, posixpath, copy
+import email, os, errno, re, posixpath, copy
import tempfile, zlib, shutil
from .i18n import _
@@ -25,6 +25,7 @@
error,
pathutil
)
+from .py3kcompat import StringIO
gitre = re.compile('diff --git a/(.*) b/(.*)')
tabsplitter = re.compile(r'(\t+|[^\t]+)')
@@ -48,7 +49,7 @@
return len(l) == 2 and ' ' not in l[0]
def chunk(lines):
- return cStringIO.StringIO(''.join(lines))
+ return StringIO(''.join(lines))
def hgsplit(stream, cur):
inheader = True
@@ -81,7 +82,7 @@
def mimesplit(stream, cur):
def msgfp(m):
- fp = cStringIO.StringIO()
+ fp = StringIO()
g = email.Generator.Generator(fp, mangle_from_=False)
g.flatten(m)
fp.seek(0)
@@ -234,7 +235,7 @@
ui.debug('found patch at byte %d\n' % m.start(0))
diffs_seen += 1
- cfp = cStringIO.StringIO()
+ cfp = StringIO()
for line in payload[:m.start(0)].splitlines():
if line.startswith('# HG changeset patch') and not hgpatch:
ui.debug('patch generated by hg export\n')
@@ -1045,7 +1046,7 @@
continue
# Remove comment lines
patchfp = open(patchfn)
- ncpatchfp = cStringIO.StringIO()
+ ncpatchfp = StringIO()
for line in patchfp:
if not line.startswith('#'):
ncpatchfp.write(line)
@@ -1428,7 +1429,7 @@
... hunkscomingfromfilterpatch.extend(h.hunks)
>>> reversedhunks = reversehunks(hunkscomingfromfilterpatch)
- >>> fp = cStringIO.StringIO()
+ >>> fp = StringIO()
>>> for c in reversedhunks:
... c.write(fp)
>>> fp.seek(0)
@@ -1542,7 +1543,7 @@
}
p = parser()
- fp = cStringIO.StringIO()
+ fp = StringIO()
fp.write(''.join(originalchunks))
fp.seek(0)
@@ -1721,7 +1722,7 @@
pos = lr.fp.tell()
fp = lr.fp
except IOError:
- fp = cStringIO.StringIO(lr.fp.read())
+ fp = StringIO(lr.fp.read())
gitlr = linereader(fp)
gitlr.push(firstline)
gitpatches = readgitpatch(gitlr)
More information about the Mercurial-devel
mailing list