Merge "use sha1 hashes to sort constraints"
This commit is contained in:
commit
d32dc2e1f5
@ -14,10 +14,12 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import copy
|
||||
import hashlib
|
||||
import optparse
|
||||
import os.path
|
||||
import subprocess
|
||||
import sys
|
||||
import textwrap
|
||||
|
||||
import fixtures
|
||||
|
||||
@ -188,6 +190,19 @@ def _parse_blacklist(path):
|
||||
return [l.strip() for l in f]
|
||||
|
||||
|
||||
def _make_sort_key(line):
|
||||
"""Produce a key that is unlikely to place similar values together.
|
||||
|
||||
We want to avoid sorting all of the oslo libraries together (or
|
||||
all of the python-*client libraries) so when we do batch releases
|
||||
we do not have merge conflicts in the individual patches updating
|
||||
the constraints.
|
||||
|
||||
"""
|
||||
dep = line.partition('=')[0].encode('utf-8')
|
||||
return hashlib.sha1(dep).digest()
|
||||
|
||||
|
||||
def main(argv=None, stdout=None):
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option(
|
||||
@ -214,5 +229,12 @@ def main(argv=None, stdout=None):
|
||||
_freeze(options.requirements, python) for python in options.pythons]
|
||||
_clone_versions(freezes, options)
|
||||
blacklist = _parse_blacklist(options.blacklist)
|
||||
stdout.writelines(_combine_freezes(freezes, blacklist))
|
||||
stdout.write(textwrap.dedent('''\
|
||||
# This file is automatically generated using a sort order
|
||||
# intended to reduce collisions when individual lines are
|
||||
# updated in separate patches.
|
||||
#
|
||||
'''))
|
||||
frozen = sorted(_combine_freezes(freezes, blacklist), key=_make_sort_key)
|
||||
stdout.writelines(frozen)
|
||||
stdout.flush()
|
||||
|
Loading…
x
Reference in New Issue
Block a user