comparison setup.py @ 50168:593f5e4076ff stable

setup: support building from an ongoing merge Before this change the two parents from the merge would duplicate some command output and modify some others in a way python 3.11 chokes on.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 22 Feb 2023 18:30:47 +0100
parents 010a1e73f69e
children 596a6b9b0570
comparison
equal deleted inserted replaced
50100:812a9fbf4380 50168:593f5e4076ff
335 numerictags = [] 335 numerictags = []
336 cmd = ['log', '-r', '.', '--template', '{tags}\n'] 336 cmd = ['log', '-r', '.', '--template', '{tags}\n']
337 pieces = sysstr(hg.run(cmd)).split() 337 pieces = sysstr(hg.run(cmd)).split()
338 numerictags = [t for t in pieces if t[0:1].isdigit()] 338 numerictags = [t for t in pieces if t[0:1].isdigit()]
339 hgid = sysstr(hg.run(['id', '-i'])).strip() 339 hgid = sysstr(hg.run(['id', '-i'])).strip()
340 if hgid.count('+') == 2:
341 hgid = hgid.replace("+", ".", 1)
340 if not hgid: 342 if not hgid:
341 eprint("/!\\") 343 eprint("/!\\")
342 eprint(r"/!\ Unable to determine hg version from local repository") 344 eprint(r"/!\ Unable to determine hg version from local repository")
343 eprint(r"/!\ Failed to retrieve current revision tags") 345 eprint(r"/!\ Failed to retrieve current revision tags")
344 return '' 346 return ''
345 if numerictags: # tag(s) found 347 if numerictags: # tag(s) found
346 version = numerictags[-1] 348 version = numerictags[-1]
347 if hgid.endswith('+'): # propagate the dirty status to the tag 349 if hgid.endswith('+'): # propagate the dirty status to the tag
348 version += '+' 350 version += '+'
349 else: # no tag found on the checked out revision 351 else: # no tag found on the checked out revision
350 ltagcmd = ['parents', '--template', '{latesttag}'] 352 ltagcmd = ['log', '--rev', 'wdir()', '--template', '{latesttag}']
351 ltag = sysstr(hg.run(ltagcmd)) 353 ltag = sysstr(hg.run(ltagcmd))
352 if not ltag: 354 if not ltag:
353 eprint("/!\\") 355 eprint("/!\\")
354 eprint(r"/!\ Unable to determine hg version from local repository") 356 eprint(r"/!\ Unable to determine hg version from local repository")
355 eprint( 357 eprint(
356 r"/!\ Failed to retrieve current revision distance to lated tag" 358 r"/!\ Failed to retrieve current revision distance to lated tag"
357 ) 359 )
358 return '' 360 return ''
359 changessincecmd = ['log', '-T', 'x\n', '-r', "only(.,'%s')" % ltag] 361 changessincecmd = [
362 'log',
363 '-T',
364 'x\n',
365 '-r',
366 "only(parents(),'%s')" % ltag,
367 ]
360 changessince = len(hg.run(changessincecmd).splitlines()) 368 changessince = len(hg.run(changessincecmd).splitlines())
361 version = '%s+hg%s.%s' % (ltag, changessince, hgid) 369 version = '%s+hg%s.%s' % (ltag, changessince, hgid)
362 if version.endswith('+'): 370 if version.endswith('+'):
363 version = version[:-1] + 'local' + time.strftime('%Y%m%d') 371 version = version[:-1] + 'local' + time.strftime('%Y%m%d')
364 return version 372 return version