detect mercurial subrepositories

This commit is contained in:
Sebastian Sdorra
2011-11-28 16:53:08 +01:00
parent 7cfb796810
commit 4d15700052

View File

@@ -57,7 +57,14 @@ name = getName(path)
length = 0 length = 0
paths = [] paths = []
repo = hg.repository(ui.ui(), path = repositoryPath) repo = hg.repository(ui.ui(), path = repositoryPath)
mf = repo[revision].manifest() subrepos = {}
revCtx = repo[revision]
mf = revCtx.manifest()
hgsub = revCtx.filectx('.hgsub').data().split('\n')
for line in hgsub:
parts = line.split('=')
if len(parts) > 1:
subrepos[parts[0].strip()] = parts[1].strip()
if path is "": if path is "":
length = 1 length = 1
@@ -72,6 +79,10 @@ else:
files = [] files = []
directories = [] directories = []
for k, v in subrepos.iteritems():
if k.startswith(path):
directories.append(k)
for p in paths: for p in paths:
parts = p.split('/') parts = p.split('/')
depth = len(parts) depth = len(parts)
@@ -91,23 +102,26 @@ print ' <revision>' + revision + '</revision>'
# todo print tag, and branch # todo print tag, and branch
print ' <files>' print ' <files>'
for dir in directories: for dir in directories:
print ' <file>' print ' <file>'
print ' <name>' + getName(dir) + '</name>' print ' <name>' + getName(dir) + '</name>'
print ' <path>' + dir + '</path>' print ' <path>' + dir + '</path>'
print ' <directory>true</directory>' print ' <directory>true</directory>'
print ' </file>' subrepo = subrepos[dir]
if subrepo != None:
print ' <subRepositoryUrl>' + subrepo + '<subRepositoryUrl>'
print ' </file>'
for file in files: for file in files:
linkrev = repo[file.linkrev()] linkrev = repo[file.linkrev()]
time = int(linkrev.date()[0]) * 1000 time = int(linkrev.date()[0]) * 1000
desc = linkrev.description() desc = linkrev.description()
print ' <file>' print ' <file>'
print ' <name>' + getName(file.path()) + '</name>' print ' <name>' + getName(file.path()) + '</name>'
print ' <path>' + file.path() + '</path>' print ' <path>' + file.path() + '</path>'
print ' <directory>false</directory>' print ' <directory>false</directory>'
print ' <length>' + str(file.size()) + '</length>' print ' <length>' + str(file.size()) + '</length>'
print ' <lastModified>' + str(time).split('.')[0] + '</lastModified>' print ' <lastModified>' + str(time).split('.')[0] + '</lastModified>'
print ' <description>' + desc + '</description>' print ' <description>' + desc + '</description>'
print ' </file>' print ' </file>'
print ' </files>' print ' </files>'
print '</browser-result>' print '</browser-result>'