[Request] [+ ] D9931: engine: 'if not, else' -> 'if, else'

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Sun Jan 31 19:35:14 UTC 2021


pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9931

AFFECTED FILES
  mercurial/upgrade_utils/engine.py

CHANGE DETAILS

diff --git a/mercurial/upgrade_utils/engine.py b/mercurial/upgrade_utils/engine.py
--- a/mercurial/upgrade_utils/engine.py
+++ b/mercurial/upgrade_utils/engine.py
@@ -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



To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20210131/2febce2d/attachment.html>


More information about the Mercurial-patches mailing list