Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/debugcommands.py @ 45665:308ca5528ee6
changing-files: add a debug command display changed files
The binary output from sidedata is useful to verify the underlying data do not
get corrupted. However having a human readable version is much simpler for
debuging the changed files data itself.
So we add a debug command to dump this information and we use it in the tests.
Differential Revision: https://phab.mercurial-scm.org/D9125
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 30 Sep 2020 09:21:33 +0200 |
parents | 00e4e97c6bc8 |
children | d2e1dcd4490d |
comparison
equal
deleted
inserted
replaced
45664:8cebc4c13978 | 45665:308ca5528ee6 |
---|---|
57 httppeer, | 57 httppeer, |
58 localrepo, | 58 localrepo, |
59 lock as lockmod, | 59 lock as lockmod, |
60 logcmdutil, | 60 logcmdutil, |
61 mergestate as mergestatemod, | 61 mergestate as mergestatemod, |
62 metadata, | |
62 obsolete, | 63 obsolete, |
63 obsutil, | 64 obsutil, |
64 pathutil, | 65 pathutil, |
65 phases, | 66 phases, |
66 policy, | 67 policy, |
97 ) | 98 ) |
98 | 99 |
99 from .revlogutils import ( | 100 from .revlogutils import ( |
100 deltas as deltautil, | 101 deltas as deltautil, |
101 nodemap, | 102 nodemap, |
103 sidedata, | |
102 ) | 104 ) |
103 | 105 |
104 release = lockmod.release | 106 release = lockmod.release |
105 | 107 |
106 command = registrar.command() | 108 command = registrar.command() |
474 ui.writenoi18n(b'Bundle2 capabilities:\n') | 476 ui.writenoi18n(b'Bundle2 capabilities:\n') |
475 for key, values in sorted(pycompat.iteritems(b2caps)): | 477 for key, values in sorted(pycompat.iteritems(b2caps)): |
476 ui.write(b' %s\n' % key) | 478 ui.write(b' %s\n' % key) |
477 for v in values: | 479 for v in values: |
478 ui.write(b' %s\n' % v) | 480 ui.write(b' %s\n' % v) |
481 | |
482 | |
483 @command(b'debugchangedfiles', [], b'REV') | |
484 def debugchangedfiles(ui, repo, rev): | |
485 """list the stored files changes for a revision""" | |
486 ctx = scmutil.revsingle(repo, rev, None) | |
487 sd = repo.changelog.sidedata(ctx.rev()) | |
488 files_block = sd.get(sidedata.SD_FILES) | |
489 if files_block is not None: | |
490 files = metadata.decode_files_sidedata(sd) | |
491 for f in sorted(files.touched): | |
492 if f in files.added: | |
493 action = b"added" | |
494 elif f in files.removed: | |
495 action = b"removed" | |
496 elif f in files.merged: | |
497 action = b"merged" | |
498 elif f in files.salvaged: | |
499 action = b"salvaged" | |
500 else: | |
501 action = b"touched" | |
502 | |
503 copy_parent = b"" | |
504 copy_source = b"" | |
505 if f in files.copied_from_p1: | |
506 copy_parent = b"p1" | |
507 copy_source = files.copied_from_p1[f] | |
508 elif f in files.copied_from_p2: | |
509 copy_parent = b"p2" | |
510 copy_source = files.copied_from_p2[f] | |
511 | |
512 data = (action, copy_parent, f, copy_source) | |
513 template = b"%-8s %2s: %s, %s;\n" | |
514 ui.write(template % data) | |
479 | 515 |
480 | 516 |
481 @command(b'debugcheckstate', [], b'') | 517 @command(b'debugcheckstate', [], b'') |
482 def debugcheckstate(ui, repo): | 518 def debugcheckstate(ui, repo): |
483 """validate the correctness of the current dirstate""" | 519 """validate the correctness of the current dirstate""" |