Mercurial > public > mercurial-scm > hg
comparison mercurial/scmutil.py @ 47012:d55b71393907
node: replace nullid and friends with nodeconstants class
The introduction of 256bit hashes require changes to nullid and other
constant magic values. Start pushing them down from repository and
revlog where sensible.
Differential Revision: https://phab.mercurial-scm.org/D9465
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Mon, 29 Mar 2021 01:52:06 +0200 |
parents | f9482db16cef |
children | a407fe56d6e8 |
comparison
equal
deleted
inserted
replaced
46992:5fa019ceb499 | 47012:d55b71393907 |
---|---|
17 | 17 |
18 from .i18n import _ | 18 from .i18n import _ |
19 from .node import ( | 19 from .node import ( |
20 bin, | 20 bin, |
21 hex, | 21 hex, |
22 nullid, | |
23 nullrev, | 22 nullrev, |
24 short, | 23 short, |
25 wdirid, | |
26 wdirrev, | 24 wdirrev, |
27 ) | 25 ) |
28 from .pycompat import getattr | 26 from .pycompat import getattr |
29 from .thirdparty import attr | 27 from .thirdparty import attr |
30 from . import ( | 28 from . import ( |
448 | 446 |
449 def binnode(ctx): | 447 def binnode(ctx): |
450 """Return binary node id for a given basectx""" | 448 """Return binary node id for a given basectx""" |
451 node = ctx.node() | 449 node = ctx.node() |
452 if node is None: | 450 if node is None: |
453 return wdirid | 451 return ctx.repo().nodeconstants.wdirid |
454 return node | 452 return node |
455 | 453 |
456 | 454 |
457 def intrev(ctx): | 455 def intrev(ctx): |
458 """Return integer for a given basectx that can be used in comparison or | 456 """Return integer for a given basectx that can be used in comparison or |
1106 unfi.set(b'max((::%n) - %ln)', oldnode, allreplaced) | 1104 unfi.set(b'max((::%n) - %ln)', oldnode, allreplaced) |
1107 ) | 1105 ) |
1108 if roots: | 1106 if roots: |
1109 newnode = roots[0].node() | 1107 newnode = roots[0].node() |
1110 else: | 1108 else: |
1111 newnode = nullid | 1109 newnode = repo.nullid |
1112 else: | 1110 else: |
1113 newnode = newnodes[0] | 1111 newnode = newnodes[0] |
1114 moves[oldnode] = newnode | 1112 moves[oldnode] = newnode |
1115 | 1113 |
1116 allnewnodes = [n for ns in replacements.values() for n in ns] | 1114 allnewnodes = [n for ns in replacements.values() for n in ns] |
1504 working copy and newctx. | 1502 working copy and newctx. |
1505 """ | 1503 """ |
1506 oldctx = repo[b'.'] | 1504 oldctx = repo[b'.'] |
1507 ds = repo.dirstate | 1505 ds = repo.dirstate |
1508 copies = dict(ds.copies()) | 1506 copies = dict(ds.copies()) |
1509 ds.setparents(newctx.node(), nullid) | 1507 ds.setparents(newctx.node(), repo.nullid) |
1510 s = newctx.status(oldctx, match=match) | 1508 s = newctx.status(oldctx, match=match) |
1511 for f in s.modified: | 1509 for f in s.modified: |
1512 if ds[f] == b'r': | 1510 if ds[f] == b'r': |
1513 # modified + removed -> removed | 1511 # modified + removed -> removed |
1514 continue | 1512 continue |