Mercurial > evolve
view tests/testlib/check-min-versions.py @ 6655:81fe0a498447 stable
topic: internal config option to fix hg pick behavior (issue6406)
After some consideration, hg pick was made to always use current topic (and
topic namespace), even if it's not set, in which case the resulting changeset
will not have any topic.
Previously the intended behavior was to only update topic if there was an
active topic, and not touch commit extras at all otherwise. That wasn't ideal,
since pick doesn't change active topic, and amending the just-picked commit
would unset its topic without clear user's intent to do so and to their
surprise.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Sat, 27 Jan 2024 17:36:39 -0300 |
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()