mercurial/wireproto.py
changeset 36066 2ad145fbde54
parent 35982 5a56bf4180ad
child 36067 caca3ac2ac04
--- a/mercurial/wireproto.py	Wed Feb 07 20:17:05 2018 -0800
+++ b/mercurial/wireproto.py	Wed Feb 07 20:17:47 2018 -0800
@@ -978,20 +978,12 @@
     else:
         new = encoding.tolocal(new) # normal path
 
-    if util.safehasattr(proto, 'restore'):
-
-        proto.redirect()
-
+    with proto.mayberedirectstdio() as output:
         r = repo.pushkey(encoding.tolocal(namespace), encoding.tolocal(key),
                          encoding.tolocal(old), new) or False
 
-        output = proto.restore()
-
-        return '%s\n%s' % (int(r), output)
-
-    r = repo.pushkey(encoding.tolocal(namespace), encoding.tolocal(key),
-                     encoding.tolocal(old), new)
-    return '%s\n' % int(r)
+    output = output.getvalue() if output else ''
+    return '%s\n%s' % (int(r), output)
 
 @wireprotocommand('stream_out')
 def stream(repo, proto):