# HG changeset patch # User Laurent Charignon # Date 1430431860 25200 # Node ID 445d7f46f25dad1d5893b47b21140572159823fa # Parent d13d973635210b8d43f8f437445ef8ac2f7bce22 evolve: refactor code computing stats of obsolescence markers Duplicated code removal by extracting a function. diff -r d13d97363521 -r 445d7f46f25d hgext/evolve.py --- a/hgext/evolve.py Thu Apr 30 14:55:04 2015 -0700 +++ b/hgext/evolve.py Thu Apr 30 15:11:00 2015 -0700 @@ -1047,6 +1047,23 @@ @command('debugobsstorestat', [], '') def cmddebugobsstorestat(ui, repo): + def _updateclustermap(nodes, mark, clustersmap): + c = (set(nodes), set([mark])) + toproceed = set(nodes) + while toproceed: + n = toproceed.pop() + other = clustersmap.get(n) + if (other is not None + and other is not c): + other[0].update(c[0]) + other[1].update(c[1]) + for on in c[0]: + if on in toproceed: + continue + clustersmap[on] = other + c = other + clustersmap[n] = c + """print statistic about obsolescence markers in the repo""" store = repo.obsstore unfi = repo.unfiltered() @@ -1076,42 +1093,12 @@ if parents: parentsdata += 1 # cluster handling - nodes = set() + nodes = set(mark[1]) nodes.add(mark[0]) - nodes.update(mark[1]) - c = (set(nodes), set([mark])) - - toproceed = set(nodes) - while toproceed: - n = toproceed.pop() - other = clustersmap.get(n) - if (other is not None - and other is not c): - other[0].update(c[0]) - other[1].update(c[1]) - for on in c[0]: - if on in toproceed: - continue - clustersmap[on] = other - c = other - clustersmap[n] = c + _updateclustermap(nodes, mark, clustersmap) # same with parent data nodes.update(parents) - c = (set(nodes), set([mark])) - toproceed = set(nodes) - while toproceed: - n = toproceed.pop() - other = pclustersmap.get(n) - if (other is not None - and other is not c): - other[0].update(c[0]) - other[1].update(c[1]) - for on in c[0]: - if on in toproceed: - continue - pclustersmap[on] = other - c = other - pclustersmap[n] = c + _updateclustermap(nodes, mark, pclustersmap) # freezing the result for c in clustersmap.values():