[PATCH 6 of 6]hgclient: use absolute_import and print_function

Pulkit Goyal 7895pulkit at gmail.com
Sat Mar 5 21:46:24 UTC 2016


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1457214345 -19800
#      Sun Mar 06 03:15:45 2016 +0530
# Node ID 5740a7496e31a542e5664a4e00495e7587d0738b
# Parent  f0cc0073a7c91d6529beaac7c912c84791875dab
hgclient: use absolute_import and print_function

diff -r f0cc0073a7c9 -r 5740a7496e31 contrib/hgclient.py
--- a/contrib/hgclient.py    Sun Mar 06 03:10:17 2016 +0530
+++ b/contrib/hgclient.py    Sun Mar 06 03:15:45 2016 +0530
@@ -1,6 +1,14 @@
 # A minimal client for Mercurial's command server

-import os, sys, signal, struct, socket, subprocess, time, cStringIO
+from __future__ import absolute_import, print_function
+import cStringIO
+import os
+import signal
+import socket
+import struct
+import subprocess
+import sys
+import time

 def connectpipe(path=None):
     cmdline = ['hg', 'serve', '--cmdserver', 'pipe']
@@ -69,7 +77,7 @@

 def runcommand(server, args, output=sys.stdout, error=sys.stderr, input=None,
                outfilter=lambda x: x):
-    print '*** runcommand', ' '.join(args)
+    print('*** runcommand', ' '.join(args))
     sys.stdout.flush()
     server.stdin.write('runcommand\n')
     writeblock(server, '\0'.join(args))
@@ -92,10 +100,10 @@
         elif ch == 'r':
             ret, = struct.unpack('>i', data)
             if ret != 0:
-                print ' [%d]' % ret
+                print(' [%d]' % ret)
             return ret
         else:
-            print "unexpected channel %c: %r" % (ch, data)
+            print("unexpected channel %c: %r" % (ch, data))
             if ch.isupper():
                 return

diff -r f0cc0073a7c9 -r 5740a7496e31 tests/test-check-py3-compat.t
--- a/tests/test-check-py3-compat.t    Sun Mar 06 03:10:17 2016 +0530
+++ b/tests/test-check-py3-compat.t    Sun Mar 06 03:15:45 2016 +0530
@@ -4,8 +4,6 @@

   $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs python
contrib/check-py3-compat.py
   contrib/debugshell.py not using absolute_import
-  contrib/hgclient.py not using absolute_import
-  contrib/hgclient.py requires print_function
   contrib/hgfixes/fix_bytes.py not using absolute_import
   contrib/hgfixes/fix_bytesmod.py not using absolute_import
   contrib/hgfixes/fix_leftover_imports.py not using absolute_import


More information about the Mercurial-devel mailing list