commandserver: unindent superfluous "if True" blocks
authorYuya Nishihara <yuya@tcha.org>
Sat, 21 May 2016 18:14:13 +0900
changeset 29585 6ed452d0f1f1
parent 29584 06587edd1233
child 29586 42cdba9cfee4
commandserver: unindent superfluous "if True" blocks
hgext/chgserver.py
mercurial/commandserver.py
--- a/hgext/chgserver.py	Sun Jul 17 19:48:04 2016 +0530
+++ b/hgext/chgserver.py	Sat May 21 18:14:13 2016 +0900
@@ -581,13 +581,12 @@
         pass
 
     def shouldexit(self):
-        if True:  # TODO: unindent
-            if not self.issocketowner():
-                _log('%s is not owned, exiting.\n' % self.address)
-                return True
-            if time.time() - self.lastactive > self.idletimeout:
-                _log('being idle too long. exiting.\n')
-                return True
+        if not self.issocketowner():
+            _log('%s is not owned, exiting.\n' % self.address)
+            return True
+        if time.time() - self.lastactive > self.idletimeout:
+            _log('being idle too long. exiting.\n')
+            return True
         return False
 
     def newconnection(self):
--- a/mercurial/commandserver.py	Sun Jul 17 19:48:04 2016 +0530
+++ b/mercurial/commandserver.py	Sat May 21 18:14:13 2016 +0900
@@ -343,51 +343,50 @@
             _restoreio(ui, fin, fout)
 
 def _serverequest(ui, repo, conn, createcmdserver):
-    if True:  # TODO: unindent
-        # use a different process group from the master process, making this
-        # process pass kernel "is_current_pgrp_orphaned" check so signals like
-        # SIGTSTP, SIGTTIN, SIGTTOU are not ignored.
-        os.setpgid(0, 0)
-        # change random state otherwise forked request handlers would have a
-        # same state inherited from parent.
-        random.seed()
+    # use a different process group from the master process, making this
+    # process pass kernel "is_current_pgrp_orphaned" check so signals like
+    # SIGTSTP, SIGTTIN, SIGTTOU are not ignored.
+    os.setpgid(0, 0)
+    # change random state otherwise forked request handlers would have a
+    # same state inherited from parent.
+    random.seed()
 
-        fin = conn.makefile('rb')
-        fout = conn.makefile('wb')
-        sv = None
+    fin = conn.makefile('rb')
+    fout = conn.makefile('wb')
+    sv = None
+    try:
+        sv = createcmdserver(repo, conn, fin, fout)
         try:
-            sv = createcmdserver(repo, conn, fin, fout)
-            try:
-                sv.serve()
-            # handle exceptions that may be raised by command server. most of
-            # known exceptions are caught by dispatch.
-            except error.Abort as inst:
-                ui.warn(_('abort: %s\n') % inst)
-            except IOError as inst:
-                if inst.errno != errno.EPIPE:
-                    raise
-            except KeyboardInterrupt:
-                pass
-            finally:
-                sv.cleanup()
-        except: # re-raises
-            # also write traceback to error channel. otherwise client cannot
-            # see it because it is written to server's stderr by default.
-            if sv:
-                cerr = sv.cerr
-            else:
-                cerr = channeledoutput(fout, 'e')
-            traceback.print_exc(file=cerr)
-            raise
+            sv.serve()
+        # handle exceptions that may be raised by command server. most of
+        # known exceptions are caught by dispatch.
+        except error.Abort as inst:
+            ui.warn(_('abort: %s\n') % inst)
+        except IOError as inst:
+            if inst.errno != errno.EPIPE:
+                raise
+        except KeyboardInterrupt:
+            pass
         finally:
-            fin.close()
-            try:
-                fout.close()  # implicit flush() may cause another EPIPE
-            except IOError as inst:
-                if inst.errno != errno.EPIPE:
-                    raise
-            # trigger __del__ since ForkingMixIn uses os._exit
-            gc.collect()
+            sv.cleanup()
+    except: # re-raises
+        # also write traceback to error channel. otherwise client cannot
+        # see it because it is written to server's stderr by default.
+        if sv:
+            cerr = sv.cerr
+        else:
+            cerr = channeledoutput(fout, 'e')
+        traceback.print_exc(file=cerr)
+        raise
+    finally:
+        fin.close()
+        try:
+            fout.close()  # implicit flush() may cause another EPIPE
+        except IOError as inst:
+            if inst.errno != errno.EPIPE:
+                raise
+        # trigger __del__ since ForkingMixIn uses os._exit
+        gc.collect()
 
 class unixservicehandler(object):
     """Set of pluggable operations for unix-mode services