hgk: stop using util.bytesinput() to read a single line from stdin
authorYuya Nishihara <yuya@tcha.org>
Tue, 06 Mar 2018 02:05:25 -0600
changeset 36790 cb0afaf112e8
parent 36789 09b58af83d44
child 36791 30742c216abb
hgk: stop using util.bytesinput() to read a single line from stdin Appears that the stdio here is an IPC channel between hg and hgk (tk) processes, which shouldn't need a fancy readline support.
hgext/hgk.py
--- a/hgext/hgk.py	Mon Aug 29 10:42:58 2016 -0400
+++ b/hgext/hgk.py	Tue Mar 06 02:05:25 2018 -0600
@@ -51,7 +51,6 @@
     pycompat,
     registrar,
     scmutil,
-    util,
 )
 
 cmdtable = {}
@@ -105,15 +104,15 @@
 
     while True:
         if opts[r'stdin']:
-            try:
-                line = util.bytesinput(ui.fin, ui.fout).split(' ')
-                node1 = line[0]
-                if len(line) > 1:
-                    node2 = line[1]
-                else:
-                    node2 = None
-            except EOFError:
+            line = ui.fin.readline()
+            if not line:
                 break
+            line = line.rstrip(pycompat.oslinesep).split(b' ')
+            node1 = line[0]
+            if len(line) > 1:
+                node2 = line[1]
+            else:
+                node2 = None
         node1 = repo.lookup(node1)
         if node2:
             node2 = repo.lookup(node2)
@@ -186,12 +185,11 @@
     #
     prefix = ""
     if opts[r'stdin']:
-        try:
-            (type, r) = util.bytesinput(ui.fin, ui.fout).split(' ')
-            prefix = "    "
-        except EOFError:
+        line = ui.fin.readline()
+        if not line:
             return
-
+        (type, r) = line.rstrip(pycompat.oslinesep).split(b' ')
+        prefix = "    "
     else:
         if not type or not r:
             ui.warn(_("cat-file: type or revision not supplied\n"))
@@ -204,10 +202,10 @@
         n = repo.lookup(r)
         catcommit(ui, repo, n, prefix)
         if opts[r'stdin']:
-            try:
-                (type, r) = util.bytesinput(ui.fin, ui.fout).split(' ')
-            except EOFError:
+            line = ui.fin.readline()
+            if not line:
                 break
+            (type, r) = line.rstrip(pycompat.oslinesep).split(b' ')
         else:
             break