# HG changeset patch # User Pierre-Yves David # Date 1392933589 28800 # Node ID 4dd1cda16fd0981d9d6380240ef4dff4cf34487e # Parent 895fadf6ba3e1a8c55064acea7ec4174f4fbcd1b 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. diff -r 895fadf6ba3e -r 4dd1cda16fd0 hgext/evolve.py --- a/hgext/evolve.py Wed Feb 19 17:27:45 2014 -0800 +++ b/hgext/evolve.py Thu Feb 20 13:59:49 2014 -0800 @@ -860,6 +860,41 @@ _('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'), diff -r 895fadf6ba3e -r 4dd1cda16fd0 tests/test-evolve.t --- a/tests/test-evolve.t Wed Feb 19 17:27:45 2014 -0800 +++ b/tests/test-evolve.t Thu Feb 20 13:59:49 2014 -0800 @@ -645,3 +645,17 @@ 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