changeset 25119:49c583ca48c4

treemanifest: add --dir option to debug{revlog,data,index} It should be possible to debug the submanifest revlogs without having to know where they are stored (in .hg/store/meta/), so let's add a --dir option for this purpose.
author Martin von Zweigbergk <martinvonz@google.com>
date Sun, 12 Apr 2015 23:51:06 -0700
parents e632a2429982
children a7701001c829
files mercurial/cmdutil.py mercurial/commands.py mercurial/localrepo.py mercurial/manifest.py tests/test-completion.t tests/test-treemanifest.t
diffstat 6 files changed, 33 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Sun May 10 06:48:08 2015 -0700
+++ b/mercurial/cmdutil.py	Sun Apr 12 23:51:06 2015 -0700
@@ -450,14 +450,17 @@
     """opens the changelog, manifest, a filelog or a given revlog"""
     cl = opts['changelog']
     mf = opts['manifest']
+    dir = opts['dir']
     msg = None
     if cl and mf:
         msg = _('cannot specify --changelog and --manifest at the same time')
+    elif cl and dir:
+        msg = _('cannot specify --changelog and --dir at the same time')
     elif cl or mf:
         if file_:
             msg = _('cannot specify filename with --changelog or --manifest')
         elif not repo:
-            msg = _('cannot specify --changelog or --manifest '
+            msg = _('cannot specify --changelog or --manifest or --dir '
                     'without a repository')
     if msg:
         raise util.Abort(msg)
@@ -466,6 +469,13 @@
     if repo:
         if cl:
             r = repo.unfiltered().changelog
+        elif dir:
+            if 'treemanifest' not in repo.requirements:
+                raise util.Abort(_("--dir can only be used on repos with "
+                                   "treemanifest enabled"))
+            dirlog = repo.dirlog(file_)
+            if len(dirlog):
+                r = dirlog
         elif mf:
             r = repo.manifest
         elif file_:
--- a/mercurial/commands.py	Sun May 10 06:48:08 2015 -0700
+++ b/mercurial/commands.py	Sun Apr 12 23:51:06 2015 -0700
@@ -2056,7 +2056,8 @@
 
 @command('debugdata',
     [('c', 'changelog', False, _('open changelog')),
-     ('m', 'manifest', False, _('open manifest'))],
+     ('m', 'manifest', False, _('open manifest')),
+     ('', 'dir', False, _('open directory manifest'))],
     _('-c|-m|FILE REV'))
 def debugdata(ui, repo, file_, rev=None, **opts):
     """dump the contents of a data file revision"""
@@ -2227,6 +2228,7 @@
 @command('debugindex',
     [('c', 'changelog', False, _('open changelog')),
      ('m', 'manifest', False, _('open manifest')),
+     ('', 'dir', False, _('open directory manifest')),
      ('f', 'format', 0, _('revlog format'), _('FORMAT'))],
     _('[-f FORMAT] -c|-m|FILE'),
     optionalrepo=True)
@@ -2729,6 +2731,7 @@
 @command('debugrevlog',
     [('c', 'changelog', False, _('open changelog')),
      ('m', 'manifest', False, _('open manifest')),
+     ('', 'dir', False, _('open directory manifest')),
      ('d', 'dump', False, _('dump index data'))],
     _('-c|-m|FILE'),
     optionalrepo=True)
--- a/mercurial/localrepo.py	Sun May 10 06:48:08 2015 -0700
+++ b/mercurial/localrepo.py	Sun Apr 12 23:51:06 2015 -0700
@@ -460,6 +460,9 @@
     def manifest(self):
         return manifest.manifest(self.svfs)
 
+    def dirlog(self, dir):
+        return manifest.manifest(self.svfs, dir)
+
     @repofilecache('dirstate')
     def dirstate(self):
         warned = [0]
--- a/mercurial/manifest.py	Sun May 10 06:48:08 2015 -0700
+++ b/mercurial/manifest.py	Sun Apr 12 23:51:06 2015 -0700
@@ -815,6 +815,8 @@
         indexfile = "00manifest.i"
         if dir:
             assert self._treeondisk
+            if not dir.endswith('/'):
+                dir = dir + '/'
             indexfile = "meta/" + dir + "00manifest.i"
         revlog.revlog.__init__(self, opener, indexfile)
         self._dir = dir
--- a/tests/test-completion.t	Sun May 10 06:48:08 2015 -0700
+++ b/tests/test-completion.t	Sun Apr 12 23:51:06 2015 -0700
@@ -234,7 +234,7 @@
   debugcommands: 
   debugcomplete: options
   debugdag: tags, branches, dots, spaces
-  debugdata: changelog, manifest
+  debugdata: changelog, manifest, dir
   debugdate: extended
   debugdirstate: nodates, datesort
   debugdiscovery: old, nonheads, ssh, remotecmd, insecure
@@ -242,7 +242,7 @@
   debugfsinfo: 
   debuggetbundle: head, common, type
   debugignore: 
-  debugindex: changelog, manifest, format
+  debugindex: changelog, manifest, dir, format
   debugindexdot: 
   debuginstall: 
   debugknown: 
@@ -255,7 +255,7 @@
   debugpvec: 
   debugrebuilddirstate: rev
   debugrename: rev
-  debugrevlog: changelog, manifest, dump
+  debugrevlog: changelog, manifest, dir, dump
   debugrevspec: optimize
   debugsetparents: 
   debugsub: rev
--- a/tests/test-treemanifest.t	Sun May 10 06:48:08 2015 -0700
+++ b/tests/test-treemanifest.t	Sun Apr 12 23:51:06 2015 -0700
@@ -30,7 +30,7 @@
   b\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe (esc)
   dir1\x008b3ffd73f901e83304c83d33132c8e774ceac44ed (esc)
   e\x00b8e02f6433738021a065f94175c7cd23db5f05be (esc)
-  $ hg debugdata .hg/store/meta/dir1/00manifest.i 0
+  $ hg debugdata --dir dir1 0
   a\x00b8e02f6433738021a065f94175c7cd23db5f05be (esc)
   b\x00b8e02f6433738021a065f94175c7cd23db5f05be (esc)
 
@@ -60,9 +60,9 @@
   $ echo 3 > dir2/a
   $ hg add dir2
   adding dir2/a
-  $ hg debugindex .hg/store/meta/dir1/00manifest.i > before
+  $ hg debugindex --dir dir1 > before
   $ hg ci -qm 'add dir2'
-  $ hg debugindex .hg/store/meta/dir1/00manifest.i > after
+  $ hg debugindex --dir dir1 > after
   $ diff before after
   $ rm before after
 
@@ -71,9 +71,9 @@
   $ hg rm dir1/dir1
   removing dir1/dir1/a
   removing dir1/dir1/b
-  $ hg debugindex .hg/store/meta/dir1/dir1/00manifest.i > before
+  $ hg debugindex --dir dir1/dir1 > before
   $ hg ci -qm 'remove dir1/dir1'
-  $ hg debugindex .hg/store/meta/dir1/dir1/00manifest.i > after
+  $ hg debugindex --dir dir1/dir1 > after
   $ diff before after
   $ rm before after
 
@@ -113,7 +113,7 @@
   5
   $ cat dir1/b
   6
-  $ hg debugindex .hg/store/meta/dir1/00manifest.i
+  $ hg debugindex --dir dir1
      rev    offset  length   base linkrev nodeid       p1           p2
        0         0      54      0       1 8b3ffd73f901 000000000000 000000000000
        1        54      68      0       2 b66d046c644f 8b3ffd73f901 000000000000
@@ -131,14 +131,14 @@
   $ hg ci -m 'modify dir2/a'
   created new head
 
-  $ hg debugindex .hg/store/meta/dir2/00manifest.i > before
+  $ hg debugindex --dir dir2 > before
   $ hg merge 'desc("modify dir1/a")'
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
   $ hg revert -r 'desc("modify dir2/a")' .
   reverting dir1/a (glob)
   $ hg ci -m 'merge, keeping parent 1'
-  $ hg debugindex .hg/store/meta/dir2/00manifest.i > after
+  $ hg debugindex --dir dir2 > after
   $ diff before after
   $ rm before after
 
@@ -147,7 +147,7 @@
 
   $ hg co 'desc("modify dir2/a")'
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg debugindex .hg/store/meta/dir1/00manifest.i > before
+  $ hg debugindex --dir dir1 > before
   $ hg merge 'desc("modify dir1/a")'
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
@@ -155,7 +155,7 @@
   reverting dir2/a (glob)
   $ hg ci -m 'merge, keeping parent 2'
   created new head
-  $ hg debugindex .hg/store/meta/dir1/00manifest.i > after
+  $ hg debugindex --dir dir1 > after
   $ diff before after
   $ rm before after