comparison mercurial/patch.py @ 30397:564b33acc21f

patch: migrate to util.iterfile
author Jun Wu <quark@fb.com>
date Mon, 14 Nov 2016 23:14:06 +0000
parents 173bdb502503
children e1677cc29da6
comparison
equal deleted inserted replaced
30396:78a58dcf8853 30397:564b33acc21f
1067 ui.warn(_("editor exited with exit code %d\n") % ret) 1067 ui.warn(_("editor exited with exit code %d\n") % ret)
1068 continue 1068 continue
1069 # Remove comment lines 1069 # Remove comment lines
1070 patchfp = open(patchfn) 1070 patchfp = open(patchfn)
1071 ncpatchfp = stringio() 1071 ncpatchfp = stringio()
1072 for line in patchfp: 1072 for line in util.iterfile(patchfp):
1073 if not line.startswith('#'): 1073 if not line.startswith('#'):
1074 ncpatchfp.write(line) 1074 ncpatchfp.write(line)
1075 patchfp.close() 1075 patchfp.close()
1076 ncpatchfp.seek(0) 1076 ncpatchfp.seek(0)
1077 newpatches = parsepatch(ncpatchfp) 1077 newpatches = parsepatch(ncpatchfp)
2010 if cwd: 2010 if cwd:
2011 args.append('-d %s' % util.shellquote(cwd)) 2011 args.append('-d %s' % util.shellquote(cwd))
2012 fp = util.popen('%s %s -p%d < %s' % (patcher, ' '.join(args), strip, 2012 fp = util.popen('%s %s -p%d < %s' % (patcher, ' '.join(args), strip,
2013 util.shellquote(patchname))) 2013 util.shellquote(patchname)))
2014 try: 2014 try:
2015 for line in fp: 2015 for line in util.iterfile(fp):
2016 line = line.rstrip() 2016 line = line.rstrip()
2017 ui.note(line + '\n') 2017 ui.note(line + '\n')
2018 if line.startswith('patching file '): 2018 if line.startswith('patching file '):
2019 pf = util.parsepatchoutput(line) 2019 pf = util.parsepatchoutput(line)
2020 printed_file = False 2020 printed_file = False