comparison mercurial/debugcommands.py @ 49228:b909dd35d9ab

deltas: add a debug-delta-find command to analyse delta search See command documentation for details. For some reason, pytype is confused by our usage of None/deltainfo variable, so I had to quiet it.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 20 May 2022 14:27:46 +0200
parents 13e523228623
children 63fd0282ad40
comparison
equal deleted inserted replaced
49227:2bcf5e14bb7e 49228:b909dd35d9ab
71 registrar, 71 registrar,
72 repair, 72 repair,
73 repoview, 73 repoview,
74 requirements, 74 requirements,
75 revlog, 75 revlog,
76 revlogutils,
76 revset, 77 revset,
77 revsetlang, 78 revsetlang,
78 scmutil, 79 scmutil,
79 setdiscovery, 80 setdiscovery,
80 simplemerge, 81 simplemerge,
984 ) 985 )
985 986
986 fm.plain(b'\n') 987 fm.plain(b'\n')
987 988
988 fm.end() 989 fm.end()
990
991
992 @command(
993 b'debug-delta-find',
994 cmdutil.debugrevlogopts + cmdutil.formatteropts,
995 _(b'-c|-m|FILE REV'),
996 optionalrepo=True,
997 )
998 def debugdeltafind(ui, repo, arg_1, arg_2=None, **opts):
999 """display the computation to get to a valid delta for storing REV
1000
1001 This command will replay the process used to find the "best" delta to store
1002 a revision and display information about all the steps used to get to that
1003 result.
1004
1005 The revision use the revision number of the target storage (not changelog
1006 revision number).
1007
1008 note: the process is initiated from a full text of the revision to store.
1009 """
1010 opts = pycompat.byteskwargs(opts)
1011 if arg_2 is None:
1012 file_ = None
1013 rev = arg_1
1014 else:
1015 file_ = arg_1
1016 rev = arg_2
1017
1018 rev = int(rev)
1019
1020 revlog = cmdutil.openrevlog(repo, b'debugdeltachain', file_, opts)
1021
1022 deltacomputer = deltautil.deltacomputer(
1023 revlog,
1024 write_debug=ui.write,
1025 debug_search=True,
1026 )
1027
1028 node = revlog.node(rev)
1029 p1r, p2r = revlog.parentrevs(rev)
1030 p1 = revlog.node(p1r)
1031 p2 = revlog.node(p2r)
1032 btext = [revlog.revision(rev)]
1033 textlen = len(btext[0])
1034 cachedelta = None
1035 flags = revlog.flags(rev)
1036
1037 revinfo = revlogutils.revisioninfo(
1038 node,
1039 p1,
1040 p2,
1041 btext,
1042 textlen,
1043 cachedelta,
1044 flags,
1045 )
1046
1047 fh = revlog._datafp()
1048 deltacomputer.finddeltainfo(revinfo, fh, target_rev=rev)
989 1049
990 1050
991 @command( 1051 @command(
992 b'debugdirstate|debugstate', 1052 b'debugdirstate|debugstate',
993 [ 1053 [