Fix FindSpecRefs to be Python 2.4 compatible and get the SVN revision

in a more obvious fashion.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55791 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2008-09-04 20:26:14 +00:00
Родитель 7ad1b1fa07
Коммит 6aa9e8af34
1 изменённых файлов: 23 добавлений и 42 удалений

Просмотреть файл

@ -354,24 +354,21 @@ def scanFile(path, filename):
print >>sys.stderr,'WARNING: Unable to open:',path print >>sys.stderr,'WARNING: Unable to open:',path
return return
try: for i,ln in enumerate(f):
for i,ln in enumerate(f): ignore = set()
ignore = set() for m in nameAndSpecRefRE.finditer(ln):
for m in nameAndSpecRefRE.finditer(ln): section = m.group(2)
section = m.group(2) name = m.group(1)
name = m.group(1) if section.endswith('.'):
if section.endswith('.'): section = section[:-1]
section = section[:-1] yield RefItem(name, section, filename, path, i+1)
yield RefItem(name, section, filename, path, i+1) ignore.add(section)
ignore.add(section) for m in loneSpecRefRE.finditer(ln):
for m in loneSpecRefRE.finditer(ln): section = m.group(1)
section = m.group(1) if section.endswith('.'):
if section.endswith('.'): section = section[:-1]
section = section[:-1] if section not in ignore:
if section not in ignore: yield RefItem(None, section, filename, path, i+1)
yield RefItem(None, section, filename, path, i+1)
finally:
f.close()
### ###
@ -450,30 +447,14 @@ def sorted(l):
return l return l
def getRevision(path): def getRevision(path):
import svn, svn.core, svn.client import subprocess
p = subprocess.Popen(['svn', 'info', path],
revision = [None] stdin=open('/dev/null','r'),
stdout=subprocess.PIPE)
def info_cb(path, info, pool): for ln in p.stdout.read(1024).split('\n'):
revision[0] = info.rev if ln.startswith('Revision:'):
return ln.split(':',1)[1].strip()
try: return None
root = os.path.abspath(path)
svn.core.apr_initialize()
pool = svn.core.svn_pool_create(None)
ctx = svn.client.svn_client_ctx_t()
svn.client.svn_client_info(root,
None,
None,
info_cb,
False,
ctx,
pool)
svn.core.svn_pool_destroy(pool)
except:
pass
return revision[0]
def buildRefTree(references): def buildRefTree(references):
root = (None, {}, []) root = (None, {}, [])