Changeset 981 for trunk/GSASIIpath.py


Ignore:
Timestamp:
Jul 7, 2013 9:58:08 AM (8 years ago)
Author:
toby
Message:

introduce regress option; fix esd printing; more docs; new Mac app with drag & drop for open; control reset of ref list on load

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpath.py

    r939 r981  
    8080    "svn/bin" in the location of the GSASII source files.
    8181
    82     :returns: None if svn is not found.
     82    :returns: None if svn is not found or an absolute path to the subversion
     83    executable file .
    8384    '''
    8485    def is_exe(fpath):
     
    9293        exe_file = os.path.join(path, svnprog)
    9394        if is_exe(exe_file):
    94             return exe_file
     95            return os.path.abspath(exe_file)
     96
     97def svnGetLog(fpath=os.path.split(__file__)[0],version=None):
     98    '''Get the revision log information for a specific version of the
     99
     100    :param str fpath: path to repository dictionary, defaults to directory where
     101       the current file is located.
     102    :param int version: the version number to be looked up or None (default)
     103       for the latest version.
     104
     105    :returns: a dictionary with keys (one hopes) 'author', 'date', 'msg', and 'revision'
     106
     107    '''
     108    import subprocess
     109    import xml.etree.ElementTree as ET
     110    svn = whichsvn()
     111    if not svn: return
     112    if version is not None:
     113        vstr = '-r'+str(version)
     114    else:
     115        vstr = '-rHEAD'
     116
     117    cmd = [svn,'log',fpath,'--xml',vstr]
     118    s = subprocess.Popen(cmd,
     119                         stdout=subprocess.PIPE,stderr=subprocess.PIPE)
     120    out,err = s.communicate()
     121    if err:
     122        print 'out=',out
     123        print 'err=',err
     124        return None
     125    x = ET.fromstring(out)
     126    d = {}
     127    for i in x.iter('logentry'):
     128        d = {'revision':i.attrib.get('revision','?')}
     129        for j in i:
     130            d[j.tag] = j.text
     131        break # only need the first
     132    return d
    95133
    96134def svnGetRev(fpath=os.path.split(__file__)[0],local=True):
    97     '''This obtains the version number for the either the latest local last update
     135    '''Obtain the version number for the either the last update of the local version
    98136    or contacts the subversion server to get the latest update version (# of Head).
    99137
    100     :param fpath: path to repository dictionary, defaults to directory where
     138    :param str fpath: path to repository dictionary, defaults to directory where
    101139       the current file is located
    102     :param local: determines the type of version number, where
     140    :param bool local: determines the type of version number, where
    103141       True (default): returns the latest installed update
    104142       False: returns the version number of Head on the server
     
    155193    return changed
    156194
    157 def svnUpdateDir(fpath=os.path.split(__file__)[0]):
     195def svnUpdateDir(fpath=os.path.split(__file__)[0],version=None):
    158196    '''This performs an update of the files in a local directory from a server.
    159197
     
    172210    svn = whichsvn()
    173211    if not svn: return
    174     cmd = [svn,'update',fpath,'-rHEAD',
     212    if version:
     213        verstr = '-r' + str(version)
     214    else:
     215        verstr = '-rHEAD'
     216    cmd = [svn,'update',fpath,verstr,
    175217           '--non-interactive',
    176218           '--accept','theirs-conflict','--force']
     
    178220                         stdout=subprocess.PIPE,stderr=subprocess.PIPE)
    179221    out,err = s.communicate()
    180     if err: return
     222    print out
     223    if err:
     224        print err
     225        return
    181226    l = out.split()
    182227    updates = {}
     
    186231        t = changetype.get(i[0])
    187232        if not t: continue
    188         updates[j] = t
     233        f = os.path.split(j)[1]
     234        if updates.get(t):
     235            updates[t] += ', '+f
     236        else:
     237            updates[t] = f
    189238    return updates
Note: See TracChangeset for help on using the changeset viewer.