comparison mercurial/debugcommands.py @ 49589:266bb5c86f4b

debug-delta-find: add a --source option This will help us to understand the delta-find operation in different situations.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 04 Nov 2022 19:38:47 -0400
parents f59e49f6bee4
children 7c0a383849a8
comparison
equal deleted inserted replaced
49588:7236f11db0c3 49589:266bb5c86f4b
57 hg, 57 hg,
58 httppeer, 58 httppeer,
59 localrepo, 59 localrepo,
60 lock as lockmod, 60 lock as lockmod,
61 logcmdutil, 61 logcmdutil,
62 mdiff,
62 mergestate as mergestatemod, 63 mergestate as mergestatemod,
63 metadata, 64 metadata,
64 obsolete, 65 obsolete,
65 obsutil, 66 obsutil,
66 pathutil, 67 pathutil,
988 fm.end() 989 fm.end()
989 990
990 991
991 @command( 992 @command(
992 b'debug-delta-find', 993 b'debug-delta-find',
993 cmdutil.debugrevlogopts + cmdutil.formatteropts, 994 cmdutil.debugrevlogopts
995 + cmdutil.formatteropts
996 + [
997 (
998 b'',
999 b'source',
1000 b'full',
1001 _(b'input data feed to the process (full, storage, p1, p2, prev)'),
1002 ),
1003 ],
994 _(b'-c|-m|FILE REV'), 1004 _(b'-c|-m|FILE REV'),
995 optionalrepo=True, 1005 optionalrepo=True,
996 ) 1006 )
997 def debugdeltafind(ui, repo, arg_1, arg_2=None, **opts): 1007 def debugdeltafind(ui, repo, arg_1, arg_2=None, source=b'full', **opts):
998 """display the computation to get to a valid delta for storing REV 1008 """display the computation to get to a valid delta for storing REV
999 1009
1000 This command will replay the process used to find the "best" delta to store 1010 This command will replay the process used to find the "best" delta to store
1001 a revision and display information about all the steps used to get to that 1011 a revision and display information about all the steps used to get to that
1002 result. 1012 result.
1013
1014 By default, the process is fed with a the full-text for the revision. This
1015 can be controlled with the --source flag.
1003 1016
1004 The revision use the revision number of the target storage (not changelog 1017 The revision use the revision number of the target storage (not changelog
1005 revision number). 1018 revision number).
1006 1019
1007 note: the process is initiated from a full text of the revision to store. 1020 note: the process is initiated from a full text of the revision to store.
1026 1039
1027 node = revlog.node(rev) 1040 node = revlog.node(rev)
1028 p1r, p2r = revlog.parentrevs(rev) 1041 p1r, p2r = revlog.parentrevs(rev)
1029 p1 = revlog.node(p1r) 1042 p1 = revlog.node(p1r)
1030 p2 = revlog.node(p2r) 1043 p2 = revlog.node(p2r)
1031 btext = [revlog.revision(rev)] 1044 full_text = revlog.revision(rev)
1045 btext = [full_text]
1032 textlen = len(btext[0]) 1046 textlen = len(btext[0])
1033 cachedelta = None 1047 cachedelta = None
1034 flags = revlog.flags(rev) 1048 flags = revlog.flags(rev)
1049
1050 if source != b'full':
1051 if source == b'storage':
1052 base_rev = revlog.deltaparent(rev)
1053 elif source == b'p1':
1054 base_rev = p1r
1055 elif source == b'p2':
1056 base_rev = p2r
1057 elif source == b'prev':
1058 base_rev = rev - 1
1059 else:
1060 raise error.InputError(b"invalid --source value: %s" % source)
1061
1062 if base_rev != nullrev:
1063 base_text = revlog.revision(base_rev)
1064 delta = mdiff.textdiff(base_text, full_text)
1065
1066 cachedelta = (base_rev, delta)
1067 btext = [None]
1035 1068
1036 revinfo = revlogutils.revisioninfo( 1069 revinfo = revlogutils.revisioninfo(
1037 node, 1070 node,
1038 p1, 1071 p1,
1039 p2, 1072 p2,