comparison mercurial/commands.py @ 14323:a79fea6b3e77

debugindex etc.: add --changelog and --manifest options These open the changelog and manifest, respectively, directly so you don't need to specify the path. The options have been added to debugindex, debugdata and debugrevlog. The patch also fixes some minor usage-related bugs.
author Sune Foldager <cryo@cyanite.org>
date Sat, 14 May 2011 00:30:32 +0200
parents a90131b85fd8
children 6078a99af433
comparison
equal deleted inserted replaced
14322:a90131b85fd8 14323:a79fea6b3e77
1500 usedots=dots, 1500 usedots=dots,
1501 maxlinewidth=70): 1501 maxlinewidth=70):
1502 ui.write(line) 1502 ui.write(line)
1503 ui.write("\n") 1503 ui.write("\n")
1504 1504
1505 @command('debugdata', [], _('FILE REV')) 1505 @command('debugdata',
1506 def debugdata(ui, repo, file_, rev): 1506 [('c', 'changelog', False, _('open changelog')),
1507 ('m', 'manifest', False, _('open manifest'))],
1508 _('-c|-m|FILE REV'))
1509 def debugdata(ui, repo, file_, rev = None, **opts):
1507 """dump the contents of a data file revision""" 1510 """dump the contents of a data file revision"""
1508 r = None 1511 if opts.get('changelog') or opts.get('manifest'):
1509 if repo: 1512 file_, rev = None, file_
1510 filelog = repo.file(file_) 1513 elif rev is None:
1511 if len(filelog): 1514 raise error.CommandError('debugdata', _('invalid arguments'))
1512 r = filelog 1515 r = cmdutil.openrevlog(repo, 'debugdata', file_, opts)
1513 if not r:
1514 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False),
1515 file_[:-2] + ".i")
1516 try: 1516 try:
1517 ui.write(r.revision(r.lookup(rev))) 1517 ui.write(r.revision(r.lookup(rev)))
1518 except KeyError: 1518 except KeyError:
1519 raise util.Abort(_('invalid revision identifier %s') % rev) 1519 raise util.Abort(_('invalid revision identifier %s') % rev)
1520 1520
1643 ui.write("%s\n" % ignore.includepat) 1643 ui.write("%s\n" % ignore.includepat)
1644 else: 1644 else:
1645 raise util.Abort(_("no ignore patterns found")) 1645 raise util.Abort(_("no ignore patterns found"))
1646 1646
1647 @command('debugindex', 1647 @command('debugindex',
1648 [('f', 'format', 0, _('revlog format'), _('FORMAT'))], 1648 [('c', 'changelog', False, _('open changelog')),
1649 _('FILE')) 1649 ('m', 'manifest', False, _('open manifest')),
1650 def debugindex(ui, repo, file_, **opts): 1650 ('f', 'format', 0, _('revlog format'), _('FORMAT'))],
1651 _('[-f FORMAT] -c|-m|FILE'))
1652 def debugindex(ui, repo, file_ = None, **opts):
1651 """dump the contents of an index file""" 1653 """dump the contents of an index file"""
1652 r = None 1654 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
1653 if repo:
1654 filelog = repo.file(file_)
1655 if len(filelog):
1656 r = filelog
1657
1658 format = opts.get('format', 0) 1655 format = opts.get('format', 0)
1659 if format not in (0, 1): 1656 if format not in (0, 1):
1660 raise util.Abort(_("unknown format %d") % format) 1657 raise util.Abort(_("unknown format %d") % format)
1661
1662 if not r:
1663 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
1664 1658
1665 generaldelta = r.version & revlog.REVLOGGENERALDELTA 1659 generaldelta = r.version & revlog.REVLOGGENERALDELTA
1666 if generaldelta: 1660 if generaldelta:
1667 basehdr = ' delta' 1661 basehdr = ' delta'
1668 else: 1662 else:
1853 if o: 1847 if o:
1854 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1]))) 1848 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
1855 else: 1849 else:
1856 ui.write(_("%s not renamed\n") % rel) 1850 ui.write(_("%s not renamed\n") % rel)
1857 1851
1858 @command('debugrevlog', [], _('FILE')) 1852 @command('debugrevlog',
1859 def debugrevlog(ui, repo, file_): 1853 [('c', 'changelog', False, _('open changelog')),
1854 ('m', 'manifest', False, _('open manifest'))],
1855 _('-c|-m|FILE'))
1856 def debugrevlog(ui, repo, file_ = None, **opts):
1860 """show data and statistics about a revlog""" 1857 """show data and statistics about a revlog"""
1861 r = None 1858 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
1862 if repo:
1863 filelog = repo.file(file_)
1864 if len(filelog):
1865 r = filelog
1866 if not r:
1867 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
1868
1869 v = r.version 1859 v = r.version
1870 format = v & 0xFFFF 1860 format = v & 0xFFFF
1871 flags = [] 1861 flags = []
1872 gdelta = False 1862 gdelta = False
1873 if v & revlog.REVLOGNGINLINEDATA: 1863 if v & revlog.REVLOGNGINLINEDATA:
5017 5007
5018 norepo = ("clone init version help debugcommands debugcomplete" 5008 norepo = ("clone init version help debugcommands debugcomplete"
5019 " debugdate debuginstall debugfsinfo debugpushkey debugwireargs" 5009 " debugdate debuginstall debugfsinfo debugpushkey debugwireargs"
5020 " debugknown debuggetbundle debugbundle") 5010 " debugknown debuggetbundle debugbundle")
5021 optionalrepo = ("identify paths serve showconfig debugancestor debugdag" 5011 optionalrepo = ("identify paths serve showconfig debugancestor debugdag"
5022 " debugdata debugindex debugindexdot") 5012 " debugdata debugindex debugindexdot debugrevlog")