Bug 1459979 - Sort artifact candidate hg revisions by local integer revision. r=froydnj

This works around a situation observed with old hg versions (hg 4.2?)
with mozilla-unified.  I don't know why we haven't witnessed it more
generally, since the sort order was textual and should have caused
issues.

MozReview-Commit-ID: DBtfRJ3NJGR

--HG--
extra : rebase_source : b8605e34341e2c3a40f424688ecef1dbac4dc58e
This commit is contained in:
Nick Alexander 2018-05-07 16:06:14 -07:00
parent 6cc637e95c
commit 6def81e643

View File

@ -1000,7 +1000,31 @@ class Artifacts(object):
'-r', 'last(public() and ::., {num})'.format(
num=NUM_REVISIONS_TO_QUERY)
], cwd=self._topsrcdir).splitlines()
return [i.split(':')[-1] for i in sorted(last_revs, reverse=True)]
self.log(logging.INFO, 'artifact',
{'len': len(last_revs)},
'hg suggested {len} candidate revisions')
def to_pair(line):
rev, node = line.split(':', 1)
return (int(rev), node)
pairs = map(to_pair, last_revs)
# Python's tuple sort orders by first component: here, the (local)
# revision number.
nodes = [pair[1] for pair in sorted(pairs, reverse=True)]
for node in nodes[:20]:
self.log(logging.DEBUG, 'artifact',
{'node': node},
'hg suggested candidate revision: {node}')
self.log(logging.DEBUG, 'artifact',
{'remaining': max(0, len(nodes) - 20)},
'hg suggested candidate revision: and {remaining} more')
return nodes
def _find_pushheads(self):
"""Returns an iterator of recent pushhead revisions, starting with the