def svn_version():
    _version = version()
    src_dir = get_base_dir()

    revision = 0
    base_url = None
    urlre = re.compile('url="([^"]+)"')
    revre = re.compile('committed-rev="(\d+)"')

    for base, dirs, files in os.walk(src_dir):
        if '.svn' not in dirs:
            dirs[:] = []
            continue    # no sense walking uncontrolled subdirs
        dirs.remove('.svn')
        f = open(os.path.join(base, '.svn', 'entries'))
        data = f.read()
        f.close()

        if data[:1] in ('8', '9') or data[:2] == '10':
            # SVN >= 1.4
            data = [ d.splitlines() for d in data.split('\n\x0c\n') ]
            del data[0][0] # get rid of the '8'
            dirurl = data[0][3]
            try:
                localrev = max([int(d[9]) for d in data if len(d)>9 and d[9]])
            except __HOLE__:
                pass # may be some newly added directory
        elif data.startswith('<?xml'):
            # SVN <= 1.3
            dirurl = urlre.search(data).group(1)    # get repository URL
            revs = [int(m.group(1)) for m in revre.finditer(data)]
            if revs:
                localrev = max(revs)
        else:
            from warnings import warn
            warn("unrecognized .svn/entries format; skipping "+base)
            dirs[:] = []
            continue
        if base_url is None:
            base_url = dirurl+'/'   # save the root url
        elif not dirurl.startswith(base_url):
            dirs[:] = []
            continue    # not part of the same svn tree, skip it
        revision = max(revision, localrev)


    result = _version
    if revision:
        result += '-' + str(revision)

    if 'dev' in _version:
        result = fix_alphabeta(result, 'dev')
    elif 'alpha' in _version:
        result = fix_alphabeta(result, 'alpha')
    if 'beta' in _version:
        result = fix_alphabeta(result, 'beta')

    return result
dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/lxml-3.3.6/versioninfo.py/svn_version