Changeset 684 for branches


Ignore:
Timestamp:
Oct 25, 2007 11:54:07 AM (12 years ago)
Author:
jpfasano
Message:

Added two new functions.

svnRevision(url) returns the Revision number for svn copy at url
newer(source,target) returns true if target should be rebuilt (ie source newer than target). The expectation is that source is the coin-or svn repository and target is on the local machines file system. There is no need to rebuild and retest if nothing has changed. This function checks externals to see if any externals have changed requiring a rebuild.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/testScripts/NBsvnCommand.py

    r681 r684  
    44import urllib2
    55import re
     6import sys
    67
    78import NBlogMessages
     
    4546  latestStableVersion=latestStableVersionRepeated2Times[0]
    4647  return latestStableVersion
     48
     49#------------------------------------------------------------------------
     50# Return svn revision number or url
     51# If not found the return -1
     52#------------------------------------------------------------------------
     53def svnRevision(url) :
     54  retVal=-1
     55  result = NBosCommand.run('svn info '+url)
     56  if result['returnCode']==0 :
     57    reg=r'Revision: (\d+)'
     58    found=re.findall(reg,result['stdout'])
     59    if len(found)!=0 :
     60      retVal=int(found[0])
     61  return retVal
    4762 
     63
     64#------------------------------------------------------------------------
     65# newer(source, target)
     66# Return true if source and is more recently modified than target,
     67# (ie return true if source is newer than target and target needs
     68# to be rebuilt).
     69#
     70# If either sourrce or target don't exist then true is returned.
     71#
     72#------------------------------------------------------------------------
     73def newer(source,target) :
     74
     75  #print '------------------------'
     76  #print source
     77  #print target
     78  #print '------------------------'
     79  #print ' '
    4880 
    49  
     81  tarRev=svnRevision(target)
     82  if tarRev==-1 :
     83    # Target probably does not exist. It does not have an svn revision
     84    # nubmer, so return that it is out of date.
     85    return True
     86
     87  srcRev=svnRevision(source)
     88  if srcRev==-1 :
     89    # Source should exist. Something is wrong that will be caught
     90    # when an 'svn checkout' is done.
     91    return True
     92
     93  if srcRev>tarRev :
     94    return True
     95
     96  # if there is an externals file then process it
     97  extFileName=os.path.join(target,"Externals")
     98  if os.path.isfile(extFileName) :
     99    extFilePtr = open(extFileName, "r")
     100    line = extFilePtr.readline()
     101
     102    while line:
     103      line=line.strip()
     104      if line!='' :
     105        if line[0]!='#':
     106          reg=r'(\S+)(\s+)(\S+)'
     107          found=re.findall(reg,line)
     108          if len(found)!=1:
     109            # something is wrong. Do a rebuild
     110            return True
     111          found=found[0]
     112          if len(found)!=3 :
     113            # something is wrong. Do a rebuild
     114            return True
     115          extTarget=os.path.join(target,found[0])
     116          extSource=found[2]
     117          # Recursive call to see if external indicates rebuild
     118          if newer(extSource,extTarget) :
     119            extFilePtr.close()
     120            return True
     121      line = extFilePtr.readline()
     122
     123    extFilePtr.close()
     124
     125  return False
     126
Note: See TracChangeset for help on using the changeset viewer.