Mercurial > hg > check_whitespace
changeset 17:8d5ba09be6c5 default tip
Fix some mercurial-on-python3 incompatibilities.
author | Sjoerd Mullender <sjoerd@acm.org> |
---|---|
date | Thu, 03 Sep 2020 18:17:08 +0200 (2020-09-03) |
parents | 86405cf4b913 |
children | |
files | check_whitespace.py |
diffstat | 1 files changed, 20 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/check_whitespace.py Tue Apr 14 19:24:46 2020 +0200 +++ b/check_whitespace.py Thu Sep 03 18:17:08 2020 +0200 @@ -19,21 +19,21 @@ import re import os -binary_suffixes = ( - '.bam', - '.bmp', - '.bz2', - '.chm', - '.cpl', - '.dia', - '.dll', - '.gz', - '.ico', - '.pdf', - '.png', - '.rtf', - '.zip', -) +binary_suffixes = { + b'.bam', + b'.bmp', + b'.bz2', + b'.chm', + b'.cpl', + b'.dia', + b'.dll', + b'.gz', + b'.ico', + b'.pdf', + b'.png', + b'.rtf', + b'.zip', +} def trailing_whitespace(difflines): linenum = 0 @@ -71,9 +71,9 @@ continue if header or not filename: continue - if line[:1] == b'+': + if line.startswith(b'+'): adding = True - elif line[:1] in (b' ', b'-'): + elif line.startswith(b' ') or line.startswith(b'-'): adding = False elif adding \ and not islink \ @@ -118,15 +118,15 @@ # no descendants for this revision, check diff with saved parents for p in branches[branch]: for filename, linenum, msg in trailing_whitespace(repo[rev].diff(p)): - ui.write('%s, line %d, branch %s: %s added\n' % (filename, linenum, branch, msg)) + ui.write(b'%s, line %d, branch %s: %s added\n' % (filename, linenum, branch, msg)) added = True if added: # save the commit message so we don't need to retype it if source != 'serve': - cmtsv = os.path.join('.hg','commit.save') + cmtsv = os.path.join(b'.hg',b'commit.save') subprocess.call(['hg', 'tip', '--template', '{desc}'], stdout=open(cmtsv, 'w')) - ui.write('commit message saved to %s\n' % cmtsv) + ui.write(b'commit message saved to %s\n' % cmtsv) return 1 if __name__ == '__main__':