diff rust/chg/src/attachio.rs @ 44856:27fe8cc1338f

rust-chg: clean up excessive indents Differential Revision: https://phab.mercurial-scm.org/D8450
author Yuya Nishihara <yuya@tcha.org>
date Sat, 11 Apr 2020 17:43:29 +0900
parents cb5822e6e545
children
line wrap: on
line diff
--- a/rust/chg/src/attachio.rs	Sat Apr 11 02:51:03 2020 +0900
+++ b/rust/chg/src/attachio.rs	Sat Apr 11 17:43:29 2020 +0900
@@ -28,44 +28,41 @@
     stdout: &impl AsRawFd,
     stderr: &impl AsRawFd,
 ) -> io::Result<()> {
-    // TODO: unindent
-    {
-        proto.send_command("attachio").await?;
-        loop {
-            match proto.fetch_response().await? {
-                ChannelMessage::Data(b'r', data) => {
-                    let fd_cnt = message::parse_result_code(data)?;
-                    if fd_cnt == 3 {
-                        return Ok(());
-                    } else {
-                        return Err(io::Error::new(
-                            io::ErrorKind::InvalidData,
-                            "unexpected attachio result",
-                        ));
-                    }
-                }
-                ChannelMessage::Data(..) => {
-                    // just ignore data sent to uninteresting (optional) channel
-                }
-                ChannelMessage::InputRequest(1) => {
-                    // this may fail with EWOULDBLOCK in theory, but the
-                    // payload is quite small, and the send buffer should
-                    // be empty so the operation will complete immediately
-                    let sock_fd = proto.as_raw_fd();
-                    let ifd = stdin.as_raw_fd();
-                    let ofd = stdout.as_raw_fd();
-                    let efd = stderr.as_raw_fd();
-                    procutil::send_raw_fds(sock_fd, &[ifd, ofd, efd])?;
-                }
-                ChannelMessage::InputRequest(..)
-                | ChannelMessage::LineRequest(..)
-                | ChannelMessage::SystemRequest(..) => {
+    proto.send_command("attachio").await?;
+    loop {
+        match proto.fetch_response().await? {
+            ChannelMessage::Data(b'r', data) => {
+                let fd_cnt = message::parse_result_code(data)?;
+                if fd_cnt == 3 {
+                    return Ok(());
+                } else {
                     return Err(io::Error::new(
                         io::ErrorKind::InvalidData,
-                        "unsupported request while attaching io",
+                        "unexpected attachio result",
                     ));
                 }
             }
+            ChannelMessage::Data(..) => {
+                // just ignore data sent to uninteresting (optional) channel
+            }
+            ChannelMessage::InputRequest(1) => {
+                // this may fail with EWOULDBLOCK in theory, but the
+                // payload is quite small, and the send buffer should
+                // be empty so the operation will complete immediately
+                let sock_fd = proto.as_raw_fd();
+                let ifd = stdin.as_raw_fd();
+                let ofd = stdout.as_raw_fd();
+                let efd = stderr.as_raw_fd();
+                procutil::send_raw_fds(sock_fd, &[ifd, ofd, efd])?;
+            }
+            ChannelMessage::InputRequest(..)
+            | ChannelMessage::LineRequest(..)
+            | ChannelMessage::SystemRequest(..) => {
+                return Err(io::Error::new(
+                    io::ErrorKind::InvalidData,
+                    "unsupported request while attaching io",
+                ));
+            }
         }
     }
 }