Mercurial > hg
diff 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 |
line wrap: on
line diff
--- a/mercurial/commands.py Fri May 13 14:58:24 2011 -0500 +++ b/mercurial/commands.py Sat May 14 00:30:32 2011 +0200 @@ -1502,17 +1502,17 @@ ui.write(line) ui.write("\n") -@command('debugdata', [], _('FILE REV')) -def debugdata(ui, repo, file_, rev): +@command('debugdata', + [('c', 'changelog', False, _('open changelog')), + ('m', 'manifest', False, _('open manifest'))], + _('-c|-m|FILE REV')) +def debugdata(ui, repo, file_, rev = None, **opts): """dump the contents of a data file revision""" - r = None - if repo: - filelog = repo.file(file_) - if len(filelog): - r = filelog - if not r: - r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), - file_[:-2] + ".i") + if opts.get('changelog') or opts.get('manifest'): + file_, rev = None, file_ + elif rev is None: + raise error.CommandError('debugdata', _('invalid arguments')) + r = cmdutil.openrevlog(repo, 'debugdata', file_, opts) try: ui.write(r.revision(r.lookup(rev))) except KeyError: @@ -1645,23 +1645,17 @@ raise util.Abort(_("no ignore patterns found")) @command('debugindex', - [('f', 'format', 0, _('revlog format'), _('FORMAT'))], - _('FILE')) -def debugindex(ui, repo, file_, **opts): + [('c', 'changelog', False, _('open changelog')), + ('m', 'manifest', False, _('open manifest')), + ('f', 'format', 0, _('revlog format'), _('FORMAT'))], + _('[-f FORMAT] -c|-m|FILE')) +def debugindex(ui, repo, file_ = None, **opts): """dump the contents of an index file""" - r = None - if repo: - filelog = repo.file(file_) - if len(filelog): - r = filelog - + r = cmdutil.openrevlog(repo, 'debugindex', file_, opts) format = opts.get('format', 0) if format not in (0, 1): raise util.Abort(_("unknown format %d") % format) - if not r: - r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_) - generaldelta = r.version & revlog.REVLOGGENERALDELTA if generaldelta: basehdr = ' delta' @@ -1855,17 +1849,13 @@ else: ui.write(_("%s not renamed\n") % rel) -@command('debugrevlog', [], _('FILE')) -def debugrevlog(ui, repo, file_): +@command('debugrevlog', + [('c', 'changelog', False, _('open changelog')), + ('m', 'manifest', False, _('open manifest'))], + _('-c|-m|FILE')) +def debugrevlog(ui, repo, file_ = None, **opts): """show data and statistics about a revlog""" - r = None - if repo: - filelog = repo.file(file_) - if len(filelog): - r = filelog - if not r: - r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_) - + r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts) v = r.version format = v & 0xFFFF flags = [] @@ -5019,4 +5009,4 @@ " debugdate debuginstall debugfsinfo debugpushkey debugwireargs" " debugknown debuggetbundle debugbundle") optionalrepo = ("identify paths serve showconfig debugancestor debugdag" - " debugdata debugindex debugindexdot") + " debugdata debugindex debugindexdot debugrevlog")