diff hgext/extdiff.py @ 46843:728d89f6f9b1

refactor: prefer checks against nullrev over nullid A common pattern is using a changeset context and obtaining the node to compare against nullid. Change this to obtain the nullrev instead. In the future, the nullid becomes a property of the repository and is no longer a global constant, so using nullrev is much easier to reason about. Python function call overhead makes the difference moot, but future changes will result in more dictionary lookups otherwise, so prefer the simpler pattern. Differential Revision: https://phab.mercurial-scm.org/D10290
author Joerg Sonnenberger <joerg@bec.de>
date Tue, 30 Mar 2021 02:32:30 +0200
parents 0a4d47f4337b
children b74e128676d4
line wrap: on
line diff
--- a/hgext/extdiff.py	Tue Mar 30 02:33:12 2021 +0200
+++ b/hgext/extdiff.py	Tue Mar 30 02:32:30 2021 +0200
@@ -91,7 +91,7 @@
 
 from mercurial.i18n import _
 from mercurial.node import (
-    nullid,
+    nullrev,
     short,
 )
 from mercurial import (
@@ -565,18 +565,18 @@
             repo, [from_rev] + [to_rev], b'nowarn'
         )
         ctx1a = scmutil.revsingle(repo, from_rev, None)
-        ctx1b = repo[nullid]
+        ctx1b = repo[nullrev]
         ctx2 = scmutil.revsingle(repo, to_rev, None)
     else:
         ctx1a, ctx2 = scmutil.revpair(repo, revs)
         if not revs:
             ctx1b = repo[None].p2()
         else:
-            ctx1b = repo[nullid]
+            ctx1b = repo[nullrev]
 
     # Disable 3-way merge if there is only one parent
     if do3way:
-        if ctx1b.node() == nullid:
+        if ctx1b.rev() == nullrev:
             do3way = False
 
     matcher = scmutil.match(ctx2, pats, opts)