comparison mercurial/patch.py @ 34260:5ce32fe7df34

py3: fix doctests in patch.py to be compatible with Python 3 We were lucky that parsepatch() could concatenate a character slice as if it were a list of chunks.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 17 Sep 2017 12:23:16 +0900
parents c43d055ae405
children 86f3c9760cc4
comparison
equal deleted inserted replaced
34259:c43d055ae405 34260:5ce32fe7df34
1488 ... + 3 1488 ... + 3
1489 ... -4 1489 ... -4
1490 ... 5 1490 ... 5
1491 ... d 1491 ... d
1492 ... +lastline""" 1492 ... +lastline"""
1493 >>> hunks = parsepatch(rawpatch) 1493 >>> hunks = parsepatch([rawpatch])
1494 >>> hunkscomingfromfilterpatch = [] 1494 >>> hunkscomingfromfilterpatch = []
1495 >>> for h in hunks: 1495 >>> for h in hunks:
1496 ... hunkscomingfromfilterpatch.append(h) 1496 ... hunkscomingfromfilterpatch.append(h)
1497 ... hunkscomingfromfilterpatch.extend(h.hunks) 1497 ... hunkscomingfromfilterpatch.extend(h.hunks)
1498 1498
1499 >>> reversedhunks = reversehunks(hunkscomingfromfilterpatch) 1499 >>> reversedhunks = reversehunks(hunkscomingfromfilterpatch)
1500 >>> from . import util 1500 >>> from . import util
1501 >>> fp = util.stringio() 1501 >>> fp = util.stringio()
1502 >>> for c in reversedhunks: 1502 >>> for c in reversedhunks:
1503 ... c.write(fp) 1503 ... c.write(fp)
1504 >>> fp.seek(0) 1504 >>> fp.seek(0) or None
1505 >>> reversedpatch = fp.read() 1505 >>> reversedpatch = fp.read()
1506 >>> print(pycompat.sysstr(reversedpatch)) 1506 >>> print(pycompat.sysstr(reversedpatch))
1507 diff --git a/folder1/g b/folder1/g 1507 diff --git a/folder1/g b/folder1/g
1508 --- a/folder1/g 1508 --- a/folder1/g
1509 +++ b/folder1/g 1509 +++ b/folder1/g