Mercurial > public > mercurial-scm > hg
comparison mercurial/simplemerge.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 | 98e3a693061a |
children | 9e1f174d305b |
comparison
equal
deleted
inserted
replaced
46842:ad878e3f282b | 46843:728d89f6f9b1 |
---|---|
17 # s: "i hate that." | 17 # s: "i hate that." |
18 | 18 |
19 from __future__ import absolute_import | 19 from __future__ import absolute_import |
20 | 20 |
21 from .i18n import _ | 21 from .i18n import _ |
22 from .node import nullid | 22 from .node import nullrev |
23 from . import ( | 23 from . import ( |
24 error, | 24 error, |
25 mdiff, | 25 mdiff, |
26 pycompat, | 26 pycompat, |
27 util, | 27 util, |
425 | 425 |
426 | 426 |
427 def is_not_null(ctx): | 427 def is_not_null(ctx): |
428 if not util.safehasattr(ctx, "node"): | 428 if not util.safehasattr(ctx, "node"): |
429 return False | 429 return False |
430 return ctx.node() != nullid | 430 return ctx.rev() != nullrev |
431 | 431 |
432 | 432 |
433 def _mergediff(m3, name_a, name_b, name_base): | 433 def _mergediff(m3, name_a, name_b, name_base): |
434 lines = [] | 434 lines = [] |
435 conflicts = False | 435 conflicts = False |