Mercurial > evolve
comparison hgext/evolve.py @ 809:5d3ddede6ccf
debugobsstorestat: add information about cluster
We now display information about independant osolescence markers clusters.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Mon, 24 Feb 2014 17:32:09 -0800 |
parents | 81a3d9a24e6b |
children | acfa2b67cff6 |
comparison
equal
deleted
inserted
replaced
808:81a3d9a24e6b | 809:5d3ddede6ccf |
---|---|
858 _('record the specified date in metadata'), _('DATE')), | 858 _('record the specified date in metadata'), _('DATE')), |
859 ('u', 'user', '', | 859 ('u', 'user', '', |
860 _('record the specified user in metadata'), _('USER')), | 860 _('record the specified user in metadata'), _('USER')), |
861 ] | 861 ] |
862 | 862 |
863 | |
863 @command('debugobsstorestat', [], '') | 864 @command('debugobsstorestat', [], '') |
864 def cmddebugobsstorestat(ui, repo): | 865 def cmddebugobsstorestat(ui, repo): |
865 """print statistic about obsolescence markers in the repo""" | 866 """print statistic about obsolescence markers in the repo""" |
866 store = repo.obsstore | 867 store = repo.obsstore |
867 unfi = repo.unfiltered() | 868 unfi = repo.unfiltered() |
868 nm = unfi.changelog.nodemap | 869 nm = unfi.changelog.nodemap |
869 ui.write('markers total: %9i\n' % len(store._all)) | 870 ui.write('markers total: %9i\n' % len(store._all)) |
870 sucscount = [0, 0 , 0, 0] | 871 sucscount = [0, 0 , 0, 0] |
871 known = 0 | 872 known = 0 |
873 parentsdata = 0 | |
872 metatotallenght = 0 | 874 metatotallenght = 0 |
873 metakeys = {} | 875 metakeys = {} |
876 # node -> cluster mapping | |
877 # a cluster is a (set(nodes), set(markers)) tuple | |
878 clustersmap = {} | |
879 # same data using parent information | |
880 pclustersmap= {} | |
874 for mark in store: | 881 for mark in store: |
875 if mark[0] in nm: | 882 if mark[0] in nm: |
876 known += 1 | 883 known += 1 |
877 nbsucs = len(mark[1]) | 884 nbsucs = len(mark[1]) |
878 sucscount[min(nbsucs, 3)] += 1 | 885 sucscount[min(nbsucs, 3)] += 1 |
879 metatotallenght += len(mark[3]) | 886 metatotallenght += len(mark[3]) |
880 meta = obsolete.decodemeta(mark[3]) | 887 meta = obsolete.decodemeta(mark[3]) |
881 for key in meta: | 888 for key in meta: |
882 metakeys.setdefault(key, 0) | 889 metakeys.setdefault(key, 0) |
883 metakeys[key] += 1 | 890 metakeys[key] += 1 |
884 | 891 parents = [meta.get('p1'), meta.get('p2')] |
892 parents = [node.bin(p) for p in parents if p is not None] | |
893 if parents: | |
894 parentsdata += 1 | |
895 # cluster handling | |
896 nodes = set() | |
897 nodes.add(mark[0]) | |
898 nodes.update(mark[1]) | |
899 c = (set(nodes), set([mark])) | |
900 | |
901 toproceed = set(nodes) | |
902 while toproceed: | |
903 n = toproceed.pop() | |
904 other = clustersmap.get(n) | |
905 if (other is not None | |
906 and other is not c): | |
907 other[0].update(c[0]) | |
908 other[1].update(c[1]) | |
909 for on in c[0]: | |
910 if on in toproceed: | |
911 continue | |
912 clustersmap[on] = other | |
913 c = other | |
914 clustersmap[n] = c | |
915 # same with parent data | |
916 nodes.update(parents) | |
917 c = (set(nodes), set([mark])) | |
918 toproceed = set(nodes) | |
919 while toproceed: | |
920 n = toproceed.pop() | |
921 other = pclustersmap.get(n) | |
922 if (other is not None | |
923 and other is not c): | |
924 other[0].update(c[0]) | |
925 other[1].update(c[1]) | |
926 for on in c[0]: | |
927 if on in toproceed: | |
928 continue | |
929 pclustersmap[on] = other | |
930 c = other | |
931 pclustersmap[n] = c | |
932 | |
933 # freezing the result | |
934 for c in clustersmap.values(): | |
935 fc = (frozenset(c[0]), frozenset(c[1])) | |
936 for n in fc[0]: | |
937 clustersmap[n] = fc | |
938 # same with parent data | |
939 for c in pclustersmap.values(): | |
940 fc = (frozenset(c[0]), frozenset(c[1])) | |
941 for n in fc[0]: | |
942 pclustersmap[n] = fc | |
885 ui.write(' for known precursors: %9i\n' % known) | 943 ui.write(' for known precursors: %9i\n' % known) |
944 ui.write(' with parents data: %9i\n' % parentsdata) | |
886 # successors data | 945 # successors data |
887 ui.write('markers with no successors: %9i\n' % sucscount[0]) | 946 ui.write('markers with no successors: %9i\n' % sucscount[0]) |
888 ui.write(' 1 successors: %9i\n' % sucscount[1]) | 947 ui.write(' 1 successors: %9i\n' % sucscount[1]) |
889 ui.write(' 2 successors: %9i\n' % sucscount[2]) | 948 ui.write(' 2 successors: %9i\n' % sucscount[2]) |
890 ui.write(' more than 2 successors: %9i\n' % sucscount[3]) | 949 ui.write(' more than 2 successors: %9i\n' % sucscount[3]) |
893 % (metatotallenght/len(store._all))) | 952 % (metatotallenght/len(store._all))) |
894 ui.write(' available keys:\n') | 953 ui.write(' available keys:\n') |
895 for key in sorted(metakeys): | 954 for key in sorted(metakeys): |
896 ui.write(' %15s: %9i\n' % (key, metakeys[key])) | 955 ui.write(' %15s: %9i\n' % (key, metakeys[key])) |
897 | 956 |
957 allclusters = list(set(clustersmap.values())) | |
958 allclusters.sort(key=lambda x: len(x[1])) | |
959 ui.write('disconnected clusters: %9i\n' % len(allclusters)) | |
960 | |
961 ui.write(' any known node: %9i\n' | |
962 % len([c for c in allclusters | |
963 if [n for n in c[0] if nm.get(n) is not None]])) | |
964 if allclusters: | |
965 nbcluster = len(allclusters) | |
966 ui.write(' smallest length: %9i\n' % len(allclusters[0][1])) | |
967 ui.write(' longer length: %9i\n' % len(allclusters[-1][1])) | |
968 median = len(allclusters[nbcluster//2][1]) | |
969 ui.write(' median length: %9i\n' % median) | |
970 mean = sum(len(x[1]) for x in allclusters) // nbcluster | |
971 ui.write(' mean length: %9i\n' % mean) | |
972 allpclusters = list(set(pclustersmap.values())) | |
973 allpclusters.sort(key=lambda x: len(x[1])) | |
974 ui.write(' using parents data: %9i\n' % len(allpclusters)) | |
975 ui.write(' any known node: %9i\n' | |
976 % len([c for c in allclusters | |
977 if [n for n in c[0] if nm.get(n) is not None]])) | |
978 if allpclusters: | |
979 nbcluster = len(allpclusters) | |
980 ui.write(' smallest length: %9i\n' % len(allpclusters[0][1])) | |
981 ui.write(' longer length: %9i\n' % len(allpclusters[-1][1])) | |
982 median = len(allpclusters[nbcluster//2][1]) | |
983 ui.write(' median length: %9i\n' % median) | |
984 mean = sum(len(x[1]) for x in allpclusters) // nbcluster | |
985 ui.write(' mean length: %9i\n' % mean) | |
898 | 986 |
899 @command('^evolve|stabilize|solve', | 987 @command('^evolve|stabilize|solve', |
900 [('n', 'dry-run', False, 'do not perform actions, print what to be done'), | 988 [('n', 'dry-run', False, 'do not perform actions, print what to be done'), |
901 ('A', 'any', False, 'evolve any troubled changeset'), | 989 ('A', 'any', False, 'evolve any troubled changeset'), |
902 ('a', 'all', False, 'evolve all troubled changesets'), | 990 ('a', 'all', False, 'evolve all troubled changesets'), |