Mercurial > hg
comparison mercurial/debugcommands.py @ 49676:4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Lets us that module more. It will help us to keep revlog implementation details
close to each other.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 28 Nov 2022 18:58:35 +0100 |
parents | bd3b6f363fb9 |
children | 4303fa8f4232 |
comparison
equal
deleted
inserted
replaced
49675:0fca63953810 | 49676:4302db0f54c8 |
---|---|
56 hg, | 56 hg, |
57 httppeer, | 57 httppeer, |
58 localrepo, | 58 localrepo, |
59 lock as lockmod, | 59 lock as lockmod, |
60 logcmdutil, | 60 logcmdutil, |
61 mdiff, | |
62 mergestate as mergestatemod, | 61 mergestate as mergestatemod, |
63 metadata, | 62 metadata, |
64 obsolete, | 63 obsolete, |
65 obsutil, | 64 obsutil, |
66 pathutil, | 65 pathutil, |
71 registrar, | 70 registrar, |
72 repair, | 71 repair, |
73 repoview, | 72 repoview, |
74 requirements, | 73 requirements, |
75 revlog, | 74 revlog, |
76 revlogutils, | |
77 revset, | 75 revset, |
78 revsetlang, | 76 revsetlang, |
79 scmutil, | 77 scmutil, |
80 setdiscovery, | 78 setdiscovery, |
81 simplemerge, | 79 simplemerge, |
1027 rev = arg_2 | 1025 rev = arg_2 |
1028 | 1026 |
1029 rev = int(rev) | 1027 rev = int(rev) |
1030 | 1028 |
1031 revlog = cmdutil.openrevlog(repo, b'debugdeltachain', file_, opts) | 1029 revlog = cmdutil.openrevlog(repo, b'debugdeltachain', file_, opts) |
1032 | |
1033 deltacomputer = deltautil.deltacomputer( | |
1034 revlog, | |
1035 write_debug=ui.write, | |
1036 debug_search=not ui.quiet, | |
1037 ) | |
1038 | |
1039 node = revlog.node(rev) | |
1040 p1r, p2r = revlog.parentrevs(rev) | 1030 p1r, p2r = revlog.parentrevs(rev) |
1041 p1 = revlog.node(p1r) | 1031 |
1042 p2 = revlog.node(p2r) | 1032 if source == b'full': |
1043 full_text = revlog.revision(rev) | 1033 base_rev = nullrev |
1044 btext = [full_text] | 1034 elif source == b'storage': |
1045 textlen = len(btext[0]) | 1035 base_rev = revlog.deltaparent(rev) |
1046 cachedelta = None | 1036 elif source == b'p1': |
1047 flags = revlog.flags(rev) | 1037 base_rev = p1r |
1048 | 1038 elif source == b'p2': |
1049 if source != b'full': | 1039 base_rev = p2r |
1050 if source == b'storage': | 1040 elif source == b'prev': |
1051 base_rev = revlog.deltaparent(rev) | 1041 base_rev = rev - 1 |
1052 elif source == b'p1': | 1042 else: |
1053 base_rev = p1r | 1043 raise error.InputError(b"invalid --source value: %s" % source) |
1054 elif source == b'p2': | 1044 |
1055 base_rev = p2r | 1045 revlog_debug.debug_delta_find(ui, revlog, rev, base_rev=base_rev) |
1056 elif source == b'prev': | |
1057 base_rev = rev - 1 | |
1058 else: | |
1059 raise error.InputError(b"invalid --source value: %s" % source) | |
1060 | |
1061 if base_rev != nullrev: | |
1062 base_text = revlog.revision(base_rev) | |
1063 delta = mdiff.textdiff(base_text, full_text) | |
1064 | |
1065 cachedelta = (base_rev, delta) | |
1066 btext = [None] | |
1067 | |
1068 revinfo = revlogutils.revisioninfo( | |
1069 node, | |
1070 p1, | |
1071 p2, | |
1072 btext, | |
1073 textlen, | |
1074 cachedelta, | |
1075 flags, | |
1076 ) | |
1077 | |
1078 fh = revlog._datafp() | |
1079 deltacomputer.finddeltainfo(revinfo, fh, target_rev=rev) | |
1080 | 1046 |
1081 | 1047 |
1082 @command( | 1048 @command( |
1083 b'debugdirstate|debugstate', | 1049 b'debugdirstate|debugstate', |
1084 [ | 1050 [ |