Mercurial > evolve
view tests/testlib/check-min-versions.py @ 6935:954d7ea5cd67 stable tip
stack: when stack base is obsolete, pick any successor, even if at random
There are situations when s0 is obsolete and we also cannot pick just one
successor for it to use in stack. In such a case, let's pick the "latest"
successor from the first set.
We're assuming that obsutil.successorssets() returns data in the same order (it
should, since it makes sure to sort data internally). Keeping that in mind,
while the successor picked for s0 by this code is not based on any sort of
sophisticated logic, it should nonetheless be the same every time.
This patch is probably not going to completely break anything that was
previously working fine, because the previous behavior was to just abort with
an exception.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Sat, 16 Nov 2024 17:01:02 +0400 |
parents | 175bb63ba111 |
children |
line wrap: on
line source
#!/usr/bin/env python """ This script takes `minimumhgversion` and `testedwith` values from the first file (e.g. hgext3rd/evolve/metadata.py) and mercurial package versions from the second file (e.g. debian/control) and compares them using a set of rules to find any issues. Rules: - if `minimumhgversion` is a feature release, the first version from `testedwith` should belong to that feature release - if `minimumhgversion` is a bugfix release, the first version from `testedwith` should be the same - mercurial package versions (from both Depends and Build-Depends sections) should match `minimumhgversion` Usage: $0 MFILE CFILE where MFILE contains extension metadata and CFILE is a debian/control file. """ from __future__ import print_function import argparse import os import re def grepall(workdir, linere): for root, dirs, files in os.walk(workdir): for fname in files: if not fname.endswith('.py'): continue path = os.path.join(root, fname) with open(path, 'r') as src: for line in src: for groups in linere.findall(line): yield path, groups def main(): ap = argparse.ArgumentParser() ap.add_argument('mfile', help='.py file with `testedwith`') ap.add_argument('cfile', help='debian/control file') opts = ap.parse_args() mre = re.compile(r"^minimumhgversion = b'([0-9.]+)'") mtre = re.compile(r"^testedwith = b'([0-9.]+) ") minversion = '' mintestedversion = '' with open(opts.mfile, 'r') as src: for line in src: if not minversion: groups = mre.findall(line) if groups: minversion = groups[0] if not mintestedversion: groups = mtre.findall(line) if groups: mintestedversion = groups[0] if not minversion: print('could not find `minimumhgversion` variable in %s' % opts.mfile) if not mintestedversion: print('could not find `testedwith` variable in %s' % opts.mfile) if minversion.count('.') > 1: # `minversion` is a bugfix release if minversion != mintestedversion: print('`minimumhgversion` is a bugfix release, the first version ' 'in `testedwith` should be the same: %s and %s' % (minversion, mintestedversion)) else: # matching X.Y to determine the "feature release" version frelre = re.compile(r"([0-9]+).([0-9]+)") if frelre.findall(minversion) != frelre.findall(mintestedversion): print('the first version in `testedwith` does not belong to the ' 'same feature release as `minimumhgversion`: %s and %s' % (mintestedversion, minversion)) cre = re.compile(r"^ mercurial \(>= ([0-9.]+)\)") depversion = '' with open(opts.cfile, 'r') as src: for line in src: groups = cre.findall(line) if groups: depversion = groups[0] if minversion != depversion: print('versions differ: %s from `minimumhgversion`, %s ' 'from dependencies' % (minversion, depversion)) if not depversion: print('could not find dependency on mercurial in %s' % opts.cfile) if __name__ == '__main__': main()