Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 34084:8b8b70cb4288
py3: replace bytes[n] with bytes[n:n + 1] in patch.py where needed
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 03 Sep 2017 16:19:20 +0900 |
parents | 871a58b5f428 |
children | 0fa781320203 |
comparison
equal
deleted
inserted
replaced
34083:871a58b5f428 | 34084:8b8b70cb4288 |
---|---|
1691 if i == -1: | 1691 if i == -1: |
1692 raise PatchError(_("unable to strip away %d of %d dirs from %s") % | 1692 raise PatchError(_("unable to strip away %d of %d dirs from %s") % |
1693 (count, strip, path)) | 1693 (count, strip, path)) |
1694 i += 1 | 1694 i += 1 |
1695 # consume '//' in the path | 1695 # consume '//' in the path |
1696 while i < pathlen - 1 and path[i] == '/': | 1696 while i < pathlen - 1 and path[i:i + 1] == '/': |
1697 i += 1 | 1697 i += 1 |
1698 count -= 1 | 1698 count -= 1 |
1699 return path[:i].lstrip(), prefix + path[i:].rstrip() | 1699 return path[:i].lstrip(), prefix + path[i:].rstrip() |
1700 | 1700 |
1701 def makepatchmeta(backend, afile_orig, bfile_orig, hunk, strip, prefix): | 1701 def makepatchmeta(backend, afile_orig, bfile_orig, hunk, strip, prefix): |
1786 tofile = lr.readline() | 1786 tofile = lr.readline() |
1787 header += [fromfile, tofile] | 1787 header += [fromfile, tofile] |
1788 else: | 1788 else: |
1789 lr.push(fromfile) | 1789 lr.push(fromfile) |
1790 yield 'file', header | 1790 yield 'file', header |
1791 elif line[0] == ' ': | 1791 elif line[0:1] == ' ': |
1792 yield 'context', scanwhile(line, lambda l: l[0] in ' \\') | 1792 yield 'context', scanwhile(line, lambda l: l[0] in ' \\') |
1793 elif line[0] in '-+': | 1793 elif line[0] in '-+': |
1794 yield 'hunk', scanwhile(line, lambda l: l[0] in '-+\\') | 1794 yield 'hunk', scanwhile(line, lambda l: l[0] in '-+\\') |
1795 else: | 1795 else: |
1796 m = lines_re.match(line) | 1796 m = lines_re.match(line) |