Patchwork D9931: engine: 'if not, else' -> 'if, else'

login
register
mail settings
Submitter phabricator
Date Jan. 31, 2021, 7:35 p.m.
Message ID <differential-rev-PHID-DREV-ocukosfdm5mofmfcrt5u-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48241/
State Superseded
Headers show

Comments

phabricator - Jan. 31, 2021, 7:35 p.m.
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




To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

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