# HG changeset patch # User Augie Fackler # Date 1657822144 14400 # Node ID 6cc5a05502813b44a3cf7ca707c7965cc3b86250 # Parent 9af1fc9b713ca73ccff5ab45b4967ef4e7ec2dc0 tools: port hg utility scripts to python 3 diff --git a/unixSoft/bin/apply-patchbomb b/unixSoft/bin/apply-patchbomb --- a/unixSoft/bin/apply-patchbomb +++ b/unixSoft/bin/apply-patchbomb @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # shebang for system python explicitly so we're sure to have pyobjc and # the scripting bridge. """apply-patchbomb: apply selected messages in Mail.app to an hg repo in pwd. @@ -18,12 +18,12 @@ def main(): messages = list(sorted(mail.selection(), cmp=lambda x,y: cmp(x.subject(), y.subject()))) for m in messages: - print 'Applying', m.subject() + print('Applying', m.subject()) p = subprocess.Popen(['hg', 'import', '--obsolete', '-'], stdin=subprocess.PIPE) p.stdin.write(m.source()) p.stdin.close() if p.wait() != 0: - print 'hg import failed, bailing' + print('hg import failed, bailing') return 2 return 0 diff --git a/unixSoft/bin/hgimp b/unixSoft/bin/hgimp --- a/unixSoft/bin/hgimp +++ b/unixSoft/bin/hgimp @@ -29,11 +29,11 @@ def main(argv): if n.startswith(name): c.append(n) if not c: - print 'abort: no repo named %s' % name + print('abort: no repo named %s' % name) sys.exit(1) elif len(c) != 1: - print 'abort: ambiguous repo name %s matches %s' % ( - name, ', '.join(c)) + print('abort: ambiguous repo name %s matches %s' % ( + name, ', '.join(c))) sys.exit(1) repo = _MAP[c[0]] importargs = ['hg', '-R', repo, 'import', '--obsolete'] @@ -41,7 +41,7 @@ def main(argv): importargs.append('--partial') importargs.append('-') hg = subprocess.Popen(importargs, stdin=subprocess.PIPE) - hg.stdin.write(sys.stdin.read()) + hg.stdin.write(sys.stdin.buffer.read()) hg.stdin.close() hg.wait() sys.exit(hg.returncode)