engine: 'if not, else' -> 'if, else'
authorPulkit Goyal <7895pulkit@gmail.com>
Sun, 31 Jan 2021 23:13:08 +0530
changeset 46467 45c3a263d5d1
parent 46466 3e3b81b6e7da
child 46468 83f037acf71a
engine: 'if not, else' -> 'if, else' I personally feel that ``` if x: pass else: pass ``` is easier to read and edit than ``` if not x: pass else: pass ``` Next patches will add one more if-else clause. Differential Revision: https://phab.mercurial-scm.org/D9931
mercurial/upgrade_utils/engine.py
--- a/mercurial/upgrade_utils/engine.py	Mon Jan 25 14:23:47 2021 +0530
+++ b/mercurial/upgrade_utils/engine.py	Sun Jan 31 23:13:08 2021 +0530
@@ -449,7 +449,10 @@
         )
     )
 
-    if not upgrade_op.requirements_only:
+    if upgrade_op.requirements_only:
+        ui.status(_(b'upgrading repository requirements\n'))
+        scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements)
+    else:
         with dstrepo.transaction(b'upgrade') as tr:
             _clonerevlogs(
                 ui,
@@ -532,8 +535,5 @@
             # could update srcrepo.svfs and other variables to point to the new
             # location. This is simpler.
             backupvfs.unlink(b'store/lock')
-    else:
-        ui.status(_(b'upgrading repository requirements\n'))
-        scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements)
 
     return backuppath