Mercurial > public > mercurial-scm > hg
comparison mercurial/debugcommands.py @ 52457:8dede0df9de9
format: add pattern filtering to debugformat
The number of format to consider increase, this will make the command simpler to
use in tests and debug.
See test changes for some direct benefits.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 18 Nov 2024 17:25:30 +0100 |
parents | 9746e618c151 |
children | cac851655570 |
comparison
equal
deleted
inserted
replaced
52456:57a4adbef74d | 52457:8dede0df9de9 |
---|---|
1623 from_report=from_report, | 1623 from_report=from_report, |
1624 paranoid=paranoid, | 1624 paranoid=paranoid, |
1625 ) | 1625 ) |
1626 | 1626 |
1627 | 1627 |
1628 @command(b'debugformat', [] + cmdutil.formatteropts) | 1628 @command( |
1629 def debugformat(ui, repo, **opts): | 1629 b'debugformat', |
1630 [] + cmdutil.formatteropts, | |
1631 b'[PATTERN] ... [PATTERN]', | |
1632 ) | |
1633 def debugformat(ui, repo, *patterns, **opts): | |
1630 """display format information about the current repository | 1634 """display format information about the current repository |
1631 | 1635 |
1632 Use --verbose to get extra information about current config value and | 1636 Use --verbose to get extra information about current config value and |
1633 Mercurial default.""" | 1637 Mercurial default. |
1638 | |
1639 If patterns are specified, only format matching at least one of these | |
1640 pattern will be displayed. | |
1641 """ | |
1634 maxvariantlength = max(len(fv.name) for fv in upgrade.allformatvariant) | 1642 maxvariantlength = max(len(fv.name) for fv in upgrade.allformatvariant) |
1635 maxvariantlength = max(len(b'format-variant'), maxvariantlength) | 1643 maxvariantlength = max(len(b'format-variant'), maxvariantlength) |
1636 | 1644 |
1637 def makeformatname(name): | 1645 def makeformatname(name): |
1638 return b'%s:' + (b' ' * (maxvariantlength - len(name))) | 1646 return b'%s:' + (b' ' * (maxvariantlength - len(name))) |
1656 fm.plain(b' repo') | 1664 fm.plain(b' repo') |
1657 if ui.verbose: | 1665 if ui.verbose: |
1658 fm.plain(b' config default') | 1666 fm.plain(b' config default') |
1659 fm.plain(b'\n') | 1667 fm.plain(b'\n') |
1660 for fv in upgrade.allformatvariant: | 1668 for fv in upgrade.allformatvariant: |
1669 if patterns: | |
1670 for p in patterns: | |
1671 # XXX support "re:" at some point | |
1672 if p in fv.name: | |
1673 break | |
1674 else: | |
1675 # no pattern matches, continue | |
1676 continue | |
1661 fm.startitem() | 1677 fm.startitem() |
1662 repovalue = fv.fromrepo(repo) | 1678 repovalue = fv.fromrepo(repo) |
1663 configvalue = fv.fromconfig(repo) | 1679 configvalue = fv.fromconfig(repo) |
1664 | 1680 |
1665 if repovalue != configvalue: | 1681 if repovalue != configvalue: |