##// END OF EJS Templates
debugindex etc.: add --changelog and --manifest options...
Sune Foldager -
r14323:a79fea6b default
parent child Browse files
Show More
@@ -8,7 +8,7 b''
8 from node import hex, nullid, nullrev, short
8 from node import hex, nullid, nullrev, short
9 from i18n import _
9 from i18n import _
10 import os, sys, errno, re, tempfile
10 import os, sys, errno, re, tempfile
11 import util, scmutil, templater, patch, error, templatekw
11 import util, scmutil, templater, patch, error, templatekw, revlog
12 import match as matchmod
12 import match as matchmod
13 import subrepo
13 import subrepo
14
14
@@ -170,6 +170,41 b' def makefileobj(repo, pat, node=None, to'
170 pathname),
170 pathname),
171 mode)
171 mode)
172
172
173 def openrevlog(repo, cmd, file_, opts):
174 """opens the changelog, manifest, a filelog or a given revlog"""
175 cl = opts['changelog']
176 mf = opts['manifest']
177 msg = None
178 if cl and mf:
179 msg = _('cannot specify --changelog and --manifest at the same time')
180 elif cl or mf:
181 if file_:
182 msg = _('cannot specify filename with --changelog or --manifest')
183 elif not repo:
184 msg = _('cannot specify --changelog or --manifest '
185 'without a repository')
186 if msg:
187 raise util.Abort(msg)
188
189 r = None
190 if repo:
191 if cl:
192 r = repo.changelog
193 elif mf:
194 r = repo.manifest
195 elif file_:
196 filelog = repo.file(file_)
197 if len(filelog):
198 r = filelog
199 if not r:
200 if not file_:
201 raise error.CommandError(cmd, _('invalid arguments'))
202 if not os.path.isfile(file_):
203 raise util.Abort(_("revlog '%s' not found") % file_)
204 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False),
205 file_[:-2] + ".i")
206 return r
207
173 def copy(ui, repo, pats, opts, rename=False):
208 def copy(ui, repo, pats, opts, rename=False):
174 # called with the repo lock held
209 # called with the repo lock held
175 #
210 #
@@ -1502,17 +1502,17 b' def debugdag(ui, repo, file_=None, *revs'
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:
@@ -1645,23 +1645,17 b' def debugignore(ui, repo, *values, **opt'
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
1658
1662 if not r:
1663 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
1664
1665 generaldelta = r.version & revlog.REVLOGGENERALDELTA
1659 generaldelta = r.version & revlog.REVLOGGENERALDELTA
1666 if generaldelta:
1660 if generaldelta:
1667 basehdr = ' delta'
1661 basehdr = ' delta'
@@ -1855,17 +1849,13 b' def debugrename(ui, repo, file1, *pats, '
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 = []
@@ -5019,4 +5009,4 b' norepo = ("clone init version help debug'
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")
@@ -56,7 +56,7 b''
56 rev offset length base linkrev nodeid p1 p2
56 rev offset length base linkrev nodeid p1 p2
57 0 0 8 0 6 12ab3bcc5ea4 000000000000 000000000000
57 0 0 8 0 6 12ab3bcc5ea4 000000000000 000000000000
58
58
59 $ hg debugindex .hg/store/00manifest.i
59 $ hg debugindex --manifest
60 rev offset length base linkrev nodeid p1 p2
60 rev offset length base linkrev nodeid p1 p2
61 0 0 48 0 0 43eadb1d2d06 000000000000 000000000000
61 0 0 48 0 0 43eadb1d2d06 000000000000 000000000000
62 1 48 48 1 1 8b89697eba2c 43eadb1d2d06 000000000000
62 1 48 48 1 1 8b89697eba2c 43eadb1d2d06 000000000000
@@ -219,20 +219,20 b' Show all commands + options'
219 debugcommands:
219 debugcommands:
220 debugcomplete: options
220 debugcomplete: options
221 debugdag: tags, branches, dots, spaces
221 debugdag: tags, branches, dots, spaces
222 debugdata:
222 debugdata: changelog, manifest
223 debugdate: extended
223 debugdate: extended
224 debugdiscovery: old, nonheads, ssh, remotecmd, insecure
224 debugdiscovery: old, nonheads, ssh, remotecmd, insecure
225 debugfsinfo:
225 debugfsinfo:
226 debuggetbundle: head, common, type
226 debuggetbundle: head, common, type
227 debugignore:
227 debugignore:
228 debugindex: format
228 debugindex: changelog, manifest, format
229 debugindexdot:
229 debugindexdot:
230 debuginstall:
230 debuginstall:
231 debugknown:
231 debugknown:
232 debugpushkey:
232 debugpushkey:
233 debugrebuildstate: rev
233 debugrebuildstate: rev
234 debugrename: rev
234 debugrename: rev
235 debugrevlog:
235 debugrevlog: changelog, manifest
236 debugrevspec:
236 debugrevspec:
237 debugsetparents:
237 debugsetparents:
238 debugstate: nodates, datesort
238 debugstate: nodates, datesort
@@ -63,7 +63,7 b''
63 date: Thu Jan 01 00:00:00 1970 +0000
63 date: Thu Jan 01 00:00:00 1970 +0000
64 summary: test
64 summary: test
65
65
66 $ hg debugindex .hg/store/00changelog.i
66 $ hg debugindex --changelog
67 rev offset length base linkrev nodeid p1 p2
67 rev offset length base linkrev nodeid p1 p2
68 0 0 60 0 0 5e0375449e74 000000000000 000000000000
68 0 0 60 0 0 5e0375449e74 000000000000 000000000000
69 1 60 62 1 1 96155394af80 5e0375449e74 000000000000
69 1 60 62 1 1 96155394af80 5e0375449e74 000000000000
@@ -75,7 +75,7 b" We shouldn't have anything but foo in me"
75
75
76 main: we should have a merge here:
76 main: we should have a merge here:
77
77
78 $ hg debugindex .hg/store/00changelog.i
78 $ hg debugindex --changelog
79 rev offset length base linkrev nodeid p1 p2
79 rev offset length base linkrev nodeid p1 p2
80 0 0 73 0 0 cdca01651b96 000000000000 000000000000
80 0 0 73 0 0 cdca01651b96 000000000000 000000000000
81 1 73 68 1 1 f6718a9cb7f3 cdca01651b96 000000000000
81 1 73 68 1 1 f6718a9cb7f3 cdca01651b96 000000000000
@@ -33,7 +33,7 b' 2 1 0 2 0 1 2'
33 $ cd ..
33 $ cd ..
34 $ hg clone -q -U -r -1 -r -2 -r -3 -r -4 -r -6 orig crossed
34 $ hg clone -q -U -r -1 -r -2 -r -3 -r -4 -r -6 orig crossed
35 $ cd crossed
35 $ cd crossed
36 $ hg debugindex .hg/store/00manifest.i
36 $ hg debugindex --manifest
37 rev offset length base linkrev nodeid p1 p2
37 rev offset length base linkrev nodeid p1 p2
38 0 0 112 0 0 6f105cbb914d 000000000000 000000000000
38 0 0 112 0 0 6f105cbb914d 000000000000 000000000000
39 1 112 56 1 3 1b55917b3699 000000000000 000000000000
39 1 112 56 1 3 1b55917b3699 000000000000 000000000000
General Comments 0
You need to be logged in to leave comments. Login now