Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 36846:c268ba15deb3
py3: open patch file in binary mode and convert eol manually
Here we don't introduce a reader wrapper since it wouldn't be easy to make
read(n) handle partial data and length correctly.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 10 Mar 2018 19:49:09 +0900 |
parents | 472c68cda3f8 |
children | f0b6fbea00cf |
comparison
equal
deleted
inserted
replaced
36845:472c68cda3f8 | 36846:c268ba15deb3 |
---|---|
1118 blockedtag='filterpatch') | 1118 blockedtag='filterpatch') |
1119 if ret != 0: | 1119 if ret != 0: |
1120 ui.warn(_("editor exited with exit code %d\n") % ret) | 1120 ui.warn(_("editor exited with exit code %d\n") % ret) |
1121 continue | 1121 continue |
1122 # Remove comment lines | 1122 # Remove comment lines |
1123 patchfp = open(patchfn) | 1123 patchfp = open(patchfn, r'rb') |
1124 ncpatchfp = stringio() | 1124 ncpatchfp = stringio() |
1125 for line in util.iterfile(patchfp): | 1125 for line in util.iterfile(patchfp): |
1126 line = util.fromnativeeol(line) | |
1126 if not line.startswith('#'): | 1127 if not line.startswith('#'): |
1127 ncpatchfp.write(line) | 1128 ncpatchfp.write(line) |
1128 patchfp.close() | 1129 patchfp.close() |
1129 ncpatchfp.seek(0) | 1130 ncpatchfp.seek(0) |
1130 newpatches = parsepatch(ncpatchfp) | 1131 newpatches = parsepatch(ncpatchfp) |