Mercurial > public > mercurial-scm > hg
comparison mercurial/debugcommands.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 | d7b36a4e03de |
children | bea4717415c0 |
comparison
equal
deleted
inserted
replaced
46992:5fa019ceb499 | 47012:d55b71393907 |
---|---|
28 | 28 |
29 from .i18n import _ | 29 from .i18n import _ |
30 from .node import ( | 30 from .node import ( |
31 bin, | 31 bin, |
32 hex, | 32 hex, |
33 nullid, | |
34 nullrev, | 33 nullrev, |
35 short, | 34 short, |
36 ) | 35 ) |
37 from .pycompat import ( | 36 from .pycompat import ( |
38 getattr, | 37 getattr, |
1665 ui.writenoi18n(b"digraph G {\n") | 1664 ui.writenoi18n(b"digraph G {\n") |
1666 for i in r: | 1665 for i in r: |
1667 node = r.node(i) | 1666 node = r.node(i) |
1668 pp = r.parents(node) | 1667 pp = r.parents(node) |
1669 ui.write(b"\t%d -> %d\n" % (r.rev(pp[0]), i)) | 1668 ui.write(b"\t%d -> %d\n" % (r.rev(pp[0]), i)) |
1670 if pp[1] != nullid: | 1669 if pp[1] != repo.nullid: |
1671 ui.write(b"\t%d -> %d\n" % (r.rev(pp[1]), i)) | 1670 ui.write(b"\t%d -> %d\n" % (r.rev(pp[1]), i)) |
1672 ui.write(b"}\n") | 1671 ui.write(b"}\n") |
1673 | 1672 |
1674 | 1673 |
1675 @command(b'debugindexstats', []) | 1674 @command(b'debugindexstats', []) |
1676 def debugindexstats(ui, repo): | 1675 def debugindexstats(ui, repo): |
1677 """show stats related to the changelog index""" | 1676 """show stats related to the changelog index""" |
1678 repo.changelog.shortest(nullid, 1) | 1677 repo.changelog.shortest(repo.nullid, 1) |
1679 index = repo.changelog.index | 1678 index = repo.changelog.index |
1680 if not util.safehasattr(index, b'stats'): | 1679 if not util.safehasattr(index, b'stats'): |
1681 raise error.Abort(_(b'debugindexstats only works with native code')) | 1680 raise error.Abort(_(b'debugindexstats only works with native code')) |
1682 for k, v in sorted(index.stats().items()): | 1681 for k, v in sorted(index.stats().items()): |
1683 ui.write(b'%s: %d\n' % (k, v)) | 1682 ui.write(b'%s: %d\n' % (k, v)) |
2423 try: | 2422 try: |
2424 # We do not use revsingle/revrange functions here to accept | 2423 # We do not use revsingle/revrange functions here to accept |
2425 # arbitrary node identifiers, possibly not present in the | 2424 # arbitrary node identifiers, possibly not present in the |
2426 # local repository. | 2425 # local repository. |
2427 n = bin(s) | 2426 n = bin(s) |
2428 if len(n) != len(nullid): | 2427 if len(n) != repo.nodeconstants.nodelen: |
2429 raise TypeError() | 2428 raise TypeError() |
2430 return n | 2429 return n |
2431 except TypeError: | 2430 except TypeError: |
2432 raise error.InputError( | 2431 raise error.InputError( |
2433 b'changeset references must be full hexadecimal ' | 2432 b'changeset references must be full hexadecimal ' |
3326 node = r.node(i) | 3325 node = r.node(i) |
3327 if format == 0: | 3326 if format == 0: |
3328 try: | 3327 try: |
3329 pp = r.parents(node) | 3328 pp = r.parents(node) |
3330 except Exception: | 3329 except Exception: |
3331 pp = [nullid, nullid] | 3330 pp = [repo.nullid, repo.nullid] |
3332 if ui.verbose: | 3331 if ui.verbose: |
3333 ui.write( | 3332 ui.write( |
3334 b"% 6d % 9d % 7d % 7d %s %s %s\n" | 3333 b"% 6d % 9d % 7d % 7d %s %s %s\n" |
3335 % ( | 3334 % ( |
3336 i, | 3335 i, |
3740 chlist.reverse() | 3739 chlist.reverse() |
3741 count = 0 | 3740 count = 0 |
3742 for n in chlist: | 3741 for n in chlist: |
3743 if limit is not None and count >= limit: | 3742 if limit is not None and count >= limit: |
3744 break | 3743 break |
3745 parents = [True for p in other.changelog.parents(n) if p != nullid] | 3744 parents = [ |
3745 True for p in other.changelog.parents(n) if p != repo.nullid | |
3746 ] | |
3746 if opts.get(b"no_merges") and len(parents) == 2: | 3747 if opts.get(b"no_merges") and len(parents) == 2: |
3747 continue | 3748 continue |
3748 count += 1 | 3749 count += 1 |
3749 displayer.show(other[n]) | 3750 displayer.show(other[n]) |
3750 | 3751 |