1737 ui.write(('deltas against p2 : ') |
1740 ui.write(('deltas against p2 : ') |
1738 + fmt % pcfmt(nump2, numdeltas)) |
1741 + fmt % pcfmt(nump2, numdeltas)) |
1739 ui.write(('deltas against other : ') + fmt % pcfmt(numother, |
1742 ui.write(('deltas against other : ') + fmt % pcfmt(numother, |
1740 numdeltas)) |
1743 numdeltas)) |
1741 |
1744 |
|
1745 @command('debugrevspec', |
|
1746 [('', 'optimize', None, |
|
1747 _('print parsed tree after optimizing (DEPRECATED)')), |
|
1748 ('p', 'show-stage', [], |
|
1749 _('print parsed tree at the given stage'), _('NAME')), |
|
1750 ('', 'no-optimized', False, _('evaluate tree without optimization')), |
|
1751 ('', 'verify-optimized', False, _('verify optimized result')), |
|
1752 ], |
|
1753 ('REVSPEC')) |
|
1754 def debugrevspec(ui, repo, expr, **opts): |
|
1755 """parse and apply a revision specification |
|
1756 |
|
1757 Use -p/--show-stage option to print the parsed tree at the given stages. |
|
1758 Use -p all to print tree at every stage. |
|
1759 |
|
1760 Use --verify-optimized to compare the optimized result with the unoptimized |
|
1761 one. Returns 1 if the optimized result differs. |
|
1762 """ |
|
1763 stages = [ |
|
1764 ('parsed', lambda tree: tree), |
|
1765 ('expanded', lambda tree: revset.expandaliases(ui, tree)), |
|
1766 ('concatenated', revset.foldconcat), |
|
1767 ('analyzed', revset.analyze), |
|
1768 ('optimized', revset.optimize), |
|
1769 ] |
|
1770 if opts['no_optimized']: |
|
1771 stages = stages[:-1] |
|
1772 if opts['verify_optimized'] and opts['no_optimized']: |
|
1773 raise error.Abort(_('cannot use --verify-optimized with ' |
|
1774 '--no-optimized')) |
|
1775 stagenames = set(n for n, f in stages) |
|
1776 |
|
1777 showalways = set() |
|
1778 showchanged = set() |
|
1779 if ui.verbose and not opts['show_stage']: |
|
1780 # show parsed tree by --verbose (deprecated) |
|
1781 showalways.add('parsed') |
|
1782 showchanged.update(['expanded', 'concatenated']) |
|
1783 if opts['optimize']: |
|
1784 showalways.add('optimized') |
|
1785 if opts['show_stage'] and opts['optimize']: |
|
1786 raise error.Abort(_('cannot use --optimize with --show-stage')) |
|
1787 if opts['show_stage'] == ['all']: |
|
1788 showalways.update(stagenames) |
|
1789 else: |
|
1790 for n in opts['show_stage']: |
|
1791 if n not in stagenames: |
|
1792 raise error.Abort(_('invalid stage name: %s') % n) |
|
1793 showalways.update(opts['show_stage']) |
|
1794 |
|
1795 treebystage = {} |
|
1796 printedtree = None |
|
1797 tree = revset.parse(expr, lookup=repo.__contains__) |
|
1798 for n, f in stages: |
|
1799 treebystage[n] = tree = f(tree) |
|
1800 if n in showalways or (n in showchanged and tree != printedtree): |
|
1801 if opts['show_stage'] or n != 'parsed': |
|
1802 ui.write(("* %s:\n") % n) |
|
1803 ui.write(revset.prettyformat(tree), "\n") |
|
1804 printedtree = tree |
|
1805 |
|
1806 if opts['verify_optimized']: |
|
1807 arevs = revset.makematcher(treebystage['analyzed'])(repo) |
|
1808 brevs = revset.makematcher(treebystage['optimized'])(repo) |
|
1809 if ui.verbose: |
|
1810 ui.note(("* analyzed set:\n"), smartset.prettyformat(arevs), "\n") |
|
1811 ui.note(("* optimized set:\n"), smartset.prettyformat(brevs), "\n") |
|
1812 arevs = list(arevs) |
|
1813 brevs = list(brevs) |
|
1814 if arevs == brevs: |
|
1815 return 0 |
|
1816 ui.write(('--- analyzed\n'), label='diff.file_a') |
|
1817 ui.write(('+++ optimized\n'), label='diff.file_b') |
|
1818 sm = difflib.SequenceMatcher(None, arevs, brevs) |
|
1819 for tag, alo, ahi, blo, bhi in sm.get_opcodes(): |
|
1820 if tag in ('delete', 'replace'): |
|
1821 for c in arevs[alo:ahi]: |
|
1822 ui.write('-%s\n' % c, label='diff.deleted') |
|
1823 if tag in ('insert', 'replace'): |
|
1824 for c in brevs[blo:bhi]: |
|
1825 ui.write('+%s\n' % c, label='diff.inserted') |
|
1826 if tag == 'equal': |
|
1827 for c in arevs[alo:ahi]: |
|
1828 ui.write(' %s\n' % c) |
|
1829 return 1 |
|
1830 |
|
1831 func = revset.makematcher(tree) |
|
1832 revs = func(repo) |
|
1833 if ui.verbose: |
|
1834 ui.note(("* set:\n"), smartset.prettyformat(revs), "\n") |
|
1835 for c in revs: |
|
1836 ui.write("%s\n" % c) |
|
1837 |
1742 @command('debugupgraderepo', [ |
1838 @command('debugupgraderepo', [ |
1743 ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')), |
1839 ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')), |
1744 ('', 'run', False, _('performs an upgrade')), |
1840 ('', 'run', False, _('performs an upgrade')), |
1745 ]) |
1841 ]) |
1746 def debugupgraderepo(ui, repo, run=False, optimize=None): |
1842 def debugupgraderepo(ui, repo, run=False, optimize=None): |