Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 5a8fbcb in mainline for tools/config.py


Ignore:
Timestamp:
2009-08-11T13:29:30Z (12 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master
Children:
5ab1648
Parents:
040f5c1
Message:

better way of generating revision identification via bzr version-info

  • display stderr to indicate any errors/warnings
  • get revision number, uncommited flag, revision id
  • ignore revision identification completely on exported trees
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/config.py

    r040f5c1 r5a8fbcb  
    3434import os
    3535import re
    36 import commands
     36import time
     37import subprocess
    3738import xtui
    3839
     
    225226        "Create output configuration"
    226227       
    227         revision = commands.getoutput('bzr version-info --custom --template="{revision_id}" 2> /dev/null')
    228         timestamp = commands.getoutput('date "+%Y-%m-%d %H:%M:%S"')
     228        timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
     229        version = subprocess.Popen(['bzr', 'version-info', '--custom', '--template={clean}:{revno}:{revision_id}'], stdout = subprocess.PIPE).communicate()[0].split(':')
     230       
     231        if (len(version) == 3):
     232                revision = version[1]
     233                if (version[0] != 1):
     234                        revision += 'M'
     235                revision += ' (%s)' % version[2]
     236        else:
     237                revision = None
    229238       
    230239        outmk = file(mkname, 'w')
     
    266275                        outdf.write(' -D%s=%s -D%s_%s' % (varname, default, varname, default))
    267276       
    268         outmk.write('REVISION = %s\n' % revision)
     277        if (revision is not None):
     278                outmk.write('REVISION = %s\n' % revision)
     279                outmc.write('#define REVISION %s\n' % revision)
     280                outdf.write(' "-DREVISION=%s"' % revision)
     281       
    269282        outmk.write('TIMESTAMP = %s\n' % timestamp)
    270        
    271         outmc.write('#define REVISION %s\n' % revision)
    272283        outmc.write('#define TIMESTAMP %s\n' % timestamp)
    273        
    274         outdf.write(' "-DREVISION=%s" "-DTIMESTAMP=%s"\n' % (revision, timestamp))
     284        outdf.write(' "-DTIMESTAMP=%s"\n' % timestamp)
    275285       
    276286        outmk.close()
Note: See TracChangeset for help on using the changeset viewer.