comparison mercurial/patch.py @ 38084:86e0a4bede5d

py3: slice over bytes to prevent getting the ascii values Differential Revision: https://phab.mercurial-scm.org/D3608
author Pulkit Goyal <7895pulkit@gmail.com>
date Sat, 19 May 2018 18:49:07 +0530
parents 468797392cc6
children e887381e2976
comparison
equal deleted inserted replaced
38083:5f2dc1b71cf1 38084:86e0a4bede5d
1956 binchunk = binchunk[s:] 1956 binchunk = binchunk[s:]
1957 s = deltahead(binchunk) 1957 s = deltahead(binchunk)
1958 binchunk = binchunk[s:] 1958 binchunk = binchunk[s:]
1959 i = 0 1959 i = 0
1960 while i < len(binchunk): 1960 while i < len(binchunk):
1961 cmd = ord(binchunk[i]) 1961 cmd = ord(binchunk[i:i + 1])
1962 i += 1 1962 i += 1
1963 if (cmd & 0x80): 1963 if (cmd & 0x80):
1964 offset = 0 1964 offset = 0
1965 size = 0 1965 size = 0
1966 if (cmd & 0x01): 1966 if (cmd & 0x01):
1967 offset = ord(binchunk[i]) 1967 offset = ord(binchunk[i:i + 1])
1968 i += 1 1968 i += 1
1969 if (cmd & 0x02): 1969 if (cmd & 0x02):
1970 offset |= ord(binchunk[i]) << 8 1970 offset |= ord(binchunk[i:i + 1]) << 8
1971 i += 1 1971 i += 1
1972 if (cmd & 0x04): 1972 if (cmd & 0x04):
1973 offset |= ord(binchunk[i]) << 16 1973 offset |= ord(binchunk[i:i + 1]) << 16
1974 i += 1 1974 i += 1
1975 if (cmd & 0x08): 1975 if (cmd & 0x08):
1976 offset |= ord(binchunk[i]) << 24 1976 offset |= ord(binchunk[i:i + 1]) << 24
1977 i += 1 1977 i += 1
1978 if (cmd & 0x10): 1978 if (cmd & 0x10):
1979 size = ord(binchunk[i]) 1979 size = ord(binchunk[i:i + 1])
1980 i += 1 1980 i += 1
1981 if (cmd & 0x20): 1981 if (cmd & 0x20):
1982 size |= ord(binchunk[i]) << 8 1982 size |= ord(binchunk[i:i + 1]) << 8
1983 i += 1 1983 i += 1
1984 if (cmd & 0x40): 1984 if (cmd & 0x40):
1985 size |= ord(binchunk[i]) << 16 1985 size |= ord(binchunk[i:i + 1]) << 16
1986 i += 1 1986 i += 1
1987 if size == 0: 1987 if size == 0:
1988 size = 0x10000 1988 size = 0x10000
1989 offset_end = offset + size 1989 offset_end = offset + size
1990 out += data[offset:offset_end] 1990 out += data[offset:offset_end]