##// END OF EJS Templates
refactor: prefer checks against nullrev over nullid...
Joerg Sonnenberger -
r47601:728d89f6 default
parent child Browse files
Show More
@@ -91,7 +91,7 b' import subprocess'
91 91
92 92 from mercurial.i18n import _
93 93 from mercurial.node import (
94 nullid,
94 nullrev,
95 95 short,
96 96 )
97 97 from mercurial import (
@@ -565,18 +565,18 b' def dodiff(ui, repo, cmdline, pats, opts'
565 565 repo, [from_rev] + [to_rev], b'nowarn'
566 566 )
567 567 ctx1a = scmutil.revsingle(repo, from_rev, None)
568 ctx1b = repo[nullid]
568 ctx1b = repo[nullrev]
569 569 ctx2 = scmutil.revsingle(repo, to_rev, None)
570 570 else:
571 571 ctx1a, ctx2 = scmutil.revpair(repo, revs)
572 572 if not revs:
573 573 ctx1b = repo[None].p2()
574 574 else:
575 ctx1b = repo[nullid]
575 ctx1b = repo[nullrev]
576 576
577 577 # Disable 3-way merge if there is only one parent
578 578 if do3way:
579 if ctx1b.node() == nullid:
579 if ctx1b.rev() == nullrev:
580 580 do3way = False
581 581
582 582 matcher = scmutil.match(ctx2, pats, opts)
@@ -12,7 +12,7 b' from __future__ import absolute_import'
12 12 from mercurial.i18n import _
13 13
14 14 from mercurial.node import (
15 nullid,
15 nullrev,
16 16 short,
17 17 )
18 18
@@ -80,12 +80,12 b' def split(ui, repo, *revs, **opts):'
80 80 raise error.InputError(_(b'cannot split multiple revisions'))
81 81
82 82 rev = revs.first()
83 ctx = repo[rev]
84 # Handle nullid specially here (instead of leaving for precheck()
83 # Handle nullrev specially here (instead of leaving for precheck()
85 84 # below) so we get a nicer message and error code.
86 if rev is None or ctx.node() == nullid:
85 if rev is None or rev == nullrev:
87 86 ui.status(_(b'nothing to split\n'))
88 87 return 1
88 ctx = repo[rev]
89 89 if ctx.node() is None:
90 90 raise error.InputError(_(b'cannot split working directory'))
91 91
@@ -2885,7 +2885,7 b' class memctx(committablectx):'
2885 2885 # "1 < len(self._parents)" can't be used for checking
2886 2886 # existence of the 2nd parent, because "memctx._parents" is
2887 2887 # explicitly initialized by the list, of which length is 2.
2888 if p2.node() != nullid:
2888 if p2.rev() != nullrev:
2889 2889 man2 = p2.manifest()
2890 2890 managing = lambda f: f in man1 or f in man2
2891 2891 else:
@@ -2903,7 +2903,7 b' class memctx(committablectx):'
2903 2903 return scmutil.status(modified, added, removed, [], [], [], [])
2904 2904
2905 2905 def parents(self):
2906 if self._parents[1].node() == nullid:
2906 if self._parents[1].rev() == nullrev:
2907 2907 return [self._parents[0]]
2908 2908 return self._parents
2909 2909
@@ -3052,7 +3052,7 b' class metadataonlyctx(committablectx):'
3052 3052 # "1 < len(self._parents)" can't be used for checking
3053 3053 # existence of the 2nd parent, because "metadataonlyctx._parents" is
3054 3054 # explicitly initialized by the list, of which length is 2.
3055 if p2.node() != nullid:
3055 if p2.rev() != nullrev:
3056 3056 man2 = p2.manifest()
3057 3057 managing = lambda f: f in man1 or f in man2
3058 3058 else:
@@ -149,7 +149,7 b' def _committedforwardcopies(a, b, base, '
149 149 # optimization, since the ctx.files() for a merge commit is not correct for
150 150 # this comparison.
151 151 forwardmissingmatch = match
152 if b.p1() == a and b.p2().node() == nullid:
152 if b.p1() == a and b.p2().rev() == nullrev:
153 153 filesmatcher = matchmod.exact(b.files())
154 154 forwardmissingmatch = matchmod.intersectmatchers(match, filesmatcher)
155 155 if repo.ui.configbool(b'devel', b'copy-tracing.trace-all-files'):
@@ -14,6 +14,7 b' import posixpath'
14 14 from .i18n import _
15 15 from .node import (
16 16 nullid,
17 nullrev,
17 18 wdirid,
18 19 wdirrev,
19 20 )
@@ -82,7 +83,7 b' def diff_parent(ctx):'
82 83 If diff.merge is enabled, an overlayworkingctx of the auto-merged parents will be returned.
83 84 """
84 85 repo = ctx.repo()
85 if repo.ui.configbool(b"diff", b"merge") and ctx.p2().node() != nullid:
86 if repo.ui.configbool(b"diff", b"merge") and ctx.p2().rev() != nullrev:
86 87 # avoid cycle context -> subrepo -> cmdutil -> logcmdutil
87 88 from . import context
88 89
@@ -11,6 +11,7 b' from .node import ('
11 11 hex,
12 12 nullhex,
13 13 nullid,
14 nullrev,
14 15 )
15 16 from . import (
16 17 error,
@@ -341,7 +342,7 b' class _mergestate_base(object):'
341 342 flo = fco.flags()
342 343 fla = fca.flags()
343 344 if b'x' in flags + flo + fla and b'l' not in flags + flo + fla:
344 if fca.node() == nullid and flags != flo:
345 if fca.rev() == nullrev and flags != flo:
345 346 if preresolve:
346 347 self._repo.ui.warn(
347 348 _(
@@ -534,7 +534,7 b' def _docreatecmd(ui, repo, pats, opts):'
534 534 parent = parents[0]
535 535 origbranch = wctx.branch()
536 536
537 if parent.node() != nullid:
537 if parent.rev() != nullrev:
538 538 desc = b"changes to: %s" % parent.description().split(b'\n', 1)[0]
539 539 else:
540 540 desc = b'(changes in empty repository)'
@@ -19,7 +19,7 b''
19 19 from __future__ import absolute_import
20 20
21 21 from .i18n import _
22 from .node import nullid
22 from .node import nullrev
23 23 from . import (
24 24 error,
25 25 mdiff,
@@ -427,7 +427,7 b' def _picklabels(defaults, overrides):'
427 427 def is_not_null(ctx):
428 428 if not util.safehasattr(ctx, "node"):
429 429 return False
430 return ctx.node() != nullid
430 return ctx.rev() != nullrev
431 431
432 432
433 433 def _mergediff(m3, name_a, name_b, name_base):
General Comments 0
You need to be logged in to leave comments. Login now