Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revlogutils/debug.py @ 49790: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 | 7aea9babac5d |
children | 05db41701ece |
comparison
equal
deleted
inserted
replaced
49789:0fca63953810 | 49790:4302db0f54c8 |
---|---|
8 | 8 |
9 import collections | 9 import collections |
10 import string | 10 import string |
11 | 11 |
12 from .. import ( | 12 from .. import ( |
13 mdiff, | |
13 node as nodemod, | 14 node as nodemod, |
15 revlogutils, | |
14 util, | 16 util, |
15 ) | 17 ) |
16 | 18 |
17 from . import ( | 19 from . import ( |
18 constants, | 20 constants, |
21 deltas as deltautil, | |
19 ) | 22 ) |
20 | 23 |
21 INDEX_ENTRY_DEBUG_COLUMN = [] | 24 INDEX_ENTRY_DEBUG_COLUMN = [] |
22 | 25 |
23 NODE_SIZE = object() | 26 NODE_SIZE = object() |
617 ) | 620 ) |
618 ui.writenoi18n( | 621 ui.writenoi18n( |
619 b'deltas against other : ' | 622 b'deltas against other : ' |
620 + fmt % pcfmt(numother_nad, numdeltas) | 623 + fmt % pcfmt(numother_nad, numdeltas) |
621 ) | 624 ) |
625 | |
626 | |
627 def debug_delta_find(ui, revlog, rev, base_rev=nodemod.nullrev): | |
628 """display the search process for a delta""" | |
629 deltacomputer = deltautil.deltacomputer( | |
630 revlog, | |
631 write_debug=ui.write, | |
632 debug_search=not ui.quiet, | |
633 ) | |
634 | |
635 node = revlog.node(rev) | |
636 p1r, p2r = revlog.parentrevs(rev) | |
637 p1 = revlog.node(p1r) | |
638 p2 = revlog.node(p2r) | |
639 full_text = revlog.revision(rev) | |
640 btext = [full_text] | |
641 textlen = len(btext[0]) | |
642 cachedelta = None | |
643 flags = revlog.flags(rev) | |
644 | |
645 if base_rev != nodemod.nullrev: | |
646 base_text = revlog.revision(base_rev) | |
647 delta = mdiff.textdiff(base_text, full_text) | |
648 | |
649 cachedelta = (base_rev, delta) | |
650 btext = [None] | |
651 | |
652 revinfo = revlogutils.revisioninfo( | |
653 node, | |
654 p1, | |
655 p2, | |
656 btext, | |
657 textlen, | |
658 cachedelta, | |
659 flags, | |
660 ) | |
661 | |
662 fh = revlog._datafp() | |
663 deltacomputer.finddeltainfo(revinfo, fh, target_rev=rev) |