Commits

Pierre-Yves David  committed 4dd1cda

evolve: add a debugobsstorestat command

This commands print multiple some data about the content of the obsstore. This
will be usefull to provide some metric and insight for obsolescence marker
exchange.

  • Participants
  • Parent commits 895fadf
  • Branches default

Comments (0)

Files changed (2)

File hgext/evolve.py

      _('record the specified user in metadata'), _('USER')),
 ]
 
+@command('debugobsstorestat', [], '')
+def cmddebugobsstorestat(ui, repo):
+    """print statistic about obsolescence markers in the repo"""
+    store = repo.obsstore
+    unfi = repo.unfiltered()
+    nm = unfi.changelog.nodemap
+    ui.write('markers total:              %9i\n' % len(store._all))
+    sucscount = [0, 0 , 0, 0]
+    known = 0
+    metatotallenght = 0
+    metakeys = {}
+    for mark in store:
+        if mark[0] in nm:
+            known += 1
+        nbsucs = len(mark[1])
+        sucscount[min(nbsucs, 3)] += 1
+        metatotallenght += len(mark[3])
+        meta = obsolete.decodemeta(mark[3])
+        for key in meta:
+            metakeys.setdefault(key, 0)
+            metakeys[key] += 1
+
+    ui.write('    for known precursors:   %9i\n' % known)
+    # successors data
+    ui.write('markers with no successors: %9i\n' % sucscount[0])
+    ui.write('              1 successors: %9i\n' % sucscount[1])
+    ui.write('              2 successors: %9i\n' % sucscount[2])
+    ui.write('    more than 2 successors: %9i\n' % sucscount[3])
+    # meta data info
+    ui.write('average meta length:        %9i\n'
+             % (metatotallenght/len(store._all)))
+    ui.write('    available  keys:\n')
+    for key in sorted(metakeys):
+        ui.write('    %15s:        %9i\n' % (key, metakeys[key]))
+
 
 @command('^evolve|stabilize|solve',
     [('n', 'dry-run', False, 'do not perform actions, print what to be done'),

File tests/test-evolve.t

   4	: add 4 - test
   5	: add 3 - test
   11	: add 1 - test
+
+Test obsstore stat
+
+  $ hg debugobsstorestat
+  markers total:                     10
+      for known precursors:          10
+  markers with no successors:         0
+                1 successors:        10
+                2 successors:         0
+      more than 2 successors:         0
+  average meta length:               27
+      available  keys:
+                 date:               10
+                 user:               10