manifest_xml.py 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274
  1. # -*- coding:utf-8 -*-
  2. #
  3. # Copyright (C) 2008 The Android Open Source Project
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. from __future__ import print_function
  17. import itertools
  18. import os
  19. import re
  20. import sys
  21. import xml.dom.minidom
  22. from pyversion import is_python3
  23. if is_python3():
  24. import urllib.parse
  25. else:
  26. import imp
  27. import urlparse
  28. urllib = imp.new_module('urllib')
  29. urllib.parse = urlparse
  30. import gitc_utils
  31. from git_config import GitConfig, IsId
  32. from git_refs import R_HEADS, HEAD
  33. import platform_utils
  34. from project import RemoteSpec, Project, MetaProject
  35. from error import (ManifestParseError, ManifestInvalidPathError,
  36. ManifestInvalidRevisionError)
  37. MANIFEST_FILE_NAME = 'manifest.xml'
  38. LOCAL_MANIFEST_NAME = 'local_manifest.xml'
  39. LOCAL_MANIFESTS_DIR_NAME = 'local_manifests'
  40. # urljoin gets confused if the scheme is not known.
  41. urllib.parse.uses_relative.extend([
  42. 'ssh',
  43. 'git',
  44. 'persistent-https',
  45. 'sso',
  46. 'rpc'])
  47. urllib.parse.uses_netloc.extend([
  48. 'ssh',
  49. 'git',
  50. 'persistent-https',
  51. 'sso',
  52. 'rpc'])
  53. def XmlBool(node, attr, default=None):
  54. """Determine boolean value of |node|'s |attr|.
  55. Invalid values will issue a non-fatal warning.
  56. Args:
  57. node: XML node whose attributes we access.
  58. attr: The attribute to access.
  59. default: If the attribute is not set (value is empty), then use this.
  60. Returns:
  61. True if the attribute is a valid string representing true.
  62. False if the attribute is a valid string representing false.
  63. |default| otherwise.
  64. """
  65. value = node.getAttribute(attr)
  66. s = value.lower()
  67. if s == '':
  68. return default
  69. elif s in {'yes', 'true', '1'}:
  70. return True
  71. elif s in {'no', 'false', '0'}:
  72. return False
  73. else:
  74. print('warning: manifest: %s="%s": ignoring invalid XML boolean' %
  75. (attr, value), file=sys.stderr)
  76. return default
  77. def XmlInt(node, attr, default=None):
  78. """Determine integer value of |node|'s |attr|.
  79. Args:
  80. node: XML node whose attributes we access.
  81. attr: The attribute to access.
  82. default: If the attribute is not set (value is empty), then use this.
  83. Returns:
  84. The number if the attribute is a valid number.
  85. Raises:
  86. ManifestParseError: The number is invalid.
  87. """
  88. value = node.getAttribute(attr)
  89. if not value:
  90. return default
  91. try:
  92. return int(value)
  93. except ValueError:
  94. raise ManifestParseError('manifest: invalid %s="%s" integer' %
  95. (attr, value))
  96. class _Default(object):
  97. """Project defaults within the manifest."""
  98. revisionExpr = None
  99. destBranchExpr = None
  100. upstreamExpr = None
  101. remote = None
  102. sync_j = 1
  103. sync_c = False
  104. sync_s = False
  105. sync_tags = True
  106. def __eq__(self, other):
  107. return self.__dict__ == other.__dict__
  108. def __ne__(self, other):
  109. return self.__dict__ != other.__dict__
  110. class _XmlRemote(object):
  111. def __init__(self,
  112. name,
  113. alias=None,
  114. fetch=None,
  115. pushUrl=None,
  116. manifestUrl=None,
  117. review=None,
  118. revision=None):
  119. self.name = name
  120. self.fetchUrl = fetch
  121. self.pushUrl = pushUrl
  122. self.manifestUrl = manifestUrl
  123. self.remoteAlias = alias
  124. self.reviewUrl = review
  125. self.revision = revision
  126. self.resolvedFetchUrl = self._resolveFetchUrl()
  127. def __eq__(self, other):
  128. return self.__dict__ == other.__dict__
  129. def __ne__(self, other):
  130. return self.__dict__ != other.__dict__
  131. def _resolveFetchUrl(self):
  132. url = self.fetchUrl.rstrip('/')
  133. manifestUrl = self.manifestUrl.rstrip('/')
  134. # urljoin will gets confused over quite a few things. The ones we care
  135. # about here are:
  136. # * no scheme in the base url, like <hostname:port>
  137. # We handle no scheme by replacing it with an obscure protocol, gopher
  138. # and then replacing it with the original when we are done.
  139. if manifestUrl.find(':') != manifestUrl.find('/') - 1:
  140. url = urllib.parse.urljoin('gopher://' + manifestUrl, url)
  141. url = re.sub(r'^gopher://', '', url)
  142. else:
  143. url = urllib.parse.urljoin(manifestUrl, url)
  144. return url
  145. def ToRemoteSpec(self, projectName):
  146. fetchUrl = self.resolvedFetchUrl.rstrip('/')
  147. url = fetchUrl + '/' + projectName
  148. remoteName = self.name
  149. if self.remoteAlias:
  150. remoteName = self.remoteAlias
  151. return RemoteSpec(remoteName,
  152. url=url,
  153. pushUrl=self.pushUrl,
  154. review=self.reviewUrl,
  155. orig_name=self.name,
  156. fetchUrl=self.fetchUrl)
  157. class XmlManifest(object):
  158. """manages the repo configuration file"""
  159. def __init__(self, repodir):
  160. self.repodir = os.path.abspath(repodir)
  161. self.topdir = os.path.dirname(self.repodir)
  162. self.manifestFile = os.path.join(self.repodir, MANIFEST_FILE_NAME)
  163. self.globalConfig = GitConfig.ForUser()
  164. self.isGitcClient = False
  165. self._load_local_manifests = True
  166. self.repoProject = MetaProject(self, 'repo',
  167. gitdir=os.path.join(repodir, 'repo/.git'),
  168. worktree=os.path.join(repodir, 'repo'))
  169. mp = MetaProject(self, 'manifests',
  170. gitdir=os.path.join(repodir, 'manifests.git'),
  171. worktree=os.path.join(repodir, 'manifests'))
  172. self.manifestProject = mp
  173. # This is a bit hacky, but we're in a chicken & egg situation: all the
  174. # normal repo settings live in the manifestProject which we just setup
  175. # above, so we couldn't easily query before that. We assume Project()
  176. # init doesn't care if this changes afterwards.
  177. if os.path.exists(mp.gitdir) and mp.config.GetBoolean('repo.worktree'):
  178. mp.use_git_worktrees = True
  179. self._Unload()
  180. def Override(self, name, load_local_manifests=True):
  181. """Use a different manifest, just for the current instantiation.
  182. """
  183. path = None
  184. # Look for a manifest by path in the filesystem (including the cwd).
  185. if not load_local_manifests:
  186. local_path = os.path.abspath(name)
  187. if os.path.isfile(local_path):
  188. path = local_path
  189. # Look for manifests by name from the manifests repo.
  190. if path is None:
  191. path = os.path.join(self.manifestProject.worktree, name)
  192. if not os.path.isfile(path):
  193. raise ManifestParseError('manifest %s not found' % name)
  194. old = self.manifestFile
  195. try:
  196. self._load_local_manifests = load_local_manifests
  197. self.manifestFile = path
  198. self._Unload()
  199. self._Load()
  200. finally:
  201. self.manifestFile = old
  202. def Link(self, name):
  203. """Update the repo metadata to use a different manifest.
  204. """
  205. self.Override(name)
  206. # Old versions of repo would generate symlinks we need to clean up.
  207. if os.path.lexists(self.manifestFile):
  208. platform_utils.remove(self.manifestFile)
  209. # This file is interpreted as if it existed inside the manifest repo.
  210. # That allows us to use <include> with the relative file name.
  211. with open(self.manifestFile, 'w') as fp:
  212. fp.write("""<?xml version="1.0" encoding="UTF-8"?>
  213. <!--
  214. DO NOT EDIT THIS FILE! It is generated by repo and changes will be discarded.
  215. If you want to use a different manifest, use `repo init -m <file>` instead.
  216. If you want to customize your checkout by overriding manifest settings, use
  217. the local_manifests/ directory instead.
  218. For more information on repo manifests, check out:
  219. https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
  220. -->
  221. <manifest>
  222. <include name="%s" />
  223. </manifest>
  224. """ % (name,))
  225. def _RemoteToXml(self, r, doc, root):
  226. e = doc.createElement('remote')
  227. root.appendChild(e)
  228. e.setAttribute('name', r.name)
  229. e.setAttribute('fetch', r.fetchUrl)
  230. if r.pushUrl is not None:
  231. e.setAttribute('pushurl', r.pushUrl)
  232. if r.remoteAlias is not None:
  233. e.setAttribute('alias', r.remoteAlias)
  234. if r.reviewUrl is not None:
  235. e.setAttribute('review', r.reviewUrl)
  236. if r.revision is not None:
  237. e.setAttribute('revision', r.revision)
  238. def _ParseGroups(self, groups):
  239. return [x for x in re.split(r'[,\s]+', groups) if x]
  240. def ToXml(self, peg_rev=False, peg_rev_upstream=True, peg_rev_dest_branch=True, groups=None):
  241. """Return the current manifest XML."""
  242. mp = self.manifestProject
  243. if groups is None:
  244. groups = mp.config.GetString('manifest.groups')
  245. if groups:
  246. groups = self._ParseGroups(groups)
  247. doc = xml.dom.minidom.Document()
  248. root = doc.createElement('manifest')
  249. doc.appendChild(root)
  250. # Save out the notice. There's a little bit of work here to give it the
  251. # right whitespace, which assumes that the notice is automatically indented
  252. # by 4 by minidom.
  253. if self.notice:
  254. notice_element = root.appendChild(doc.createElement('notice'))
  255. notice_lines = self.notice.splitlines()
  256. indented_notice = ('\n'.join(" " * 4 + line for line in notice_lines))[4:]
  257. notice_element.appendChild(doc.createTextNode(indented_notice))
  258. d = self.default
  259. for r in sorted(self.remotes):
  260. self._RemoteToXml(self.remotes[r], doc, root)
  261. if self.remotes:
  262. root.appendChild(doc.createTextNode(''))
  263. have_default = False
  264. e = doc.createElement('default')
  265. if d.remote:
  266. have_default = True
  267. e.setAttribute('remote', d.remote.name)
  268. if d.revisionExpr:
  269. have_default = True
  270. e.setAttribute('revision', d.revisionExpr)
  271. if d.destBranchExpr:
  272. have_default = True
  273. e.setAttribute('dest-branch', d.destBranchExpr)
  274. if d.upstreamExpr:
  275. have_default = True
  276. e.setAttribute('upstream', d.upstreamExpr)
  277. if d.sync_j > 1:
  278. have_default = True
  279. e.setAttribute('sync-j', '%d' % d.sync_j)
  280. if d.sync_c:
  281. have_default = True
  282. e.setAttribute('sync-c', 'true')
  283. if d.sync_s:
  284. have_default = True
  285. e.setAttribute('sync-s', 'true')
  286. if not d.sync_tags:
  287. have_default = True
  288. e.setAttribute('sync-tags', 'false')
  289. if have_default:
  290. root.appendChild(e)
  291. root.appendChild(doc.createTextNode(''))
  292. if self._manifest_server:
  293. e = doc.createElement('manifest-server')
  294. e.setAttribute('url', self._manifest_server)
  295. root.appendChild(e)
  296. root.appendChild(doc.createTextNode(''))
  297. def output_projects(parent, parent_node, projects):
  298. for project_name in projects:
  299. for project in self._projects[project_name]:
  300. output_project(parent, parent_node, project)
  301. def output_project(parent, parent_node, p):
  302. if not p.MatchesGroups(groups):
  303. return
  304. name = p.name
  305. relpath = p.relpath
  306. if parent:
  307. name = self._UnjoinName(parent.name, name)
  308. relpath = self._UnjoinRelpath(parent.relpath, relpath)
  309. e = doc.createElement('project')
  310. parent_node.appendChild(e)
  311. e.setAttribute('name', name)
  312. if relpath != name:
  313. e.setAttribute('path', relpath)
  314. remoteName = None
  315. if d.remote:
  316. remoteName = d.remote.name
  317. if not d.remote or p.remote.orig_name != remoteName:
  318. remoteName = p.remote.orig_name
  319. e.setAttribute('remote', remoteName)
  320. if peg_rev:
  321. if self.IsMirror:
  322. value = p.bare_git.rev_parse(p.revisionExpr + '^0')
  323. else:
  324. value = p.work_git.rev_parse(HEAD + '^0')
  325. e.setAttribute('revision', value)
  326. if peg_rev_upstream:
  327. if p.upstream:
  328. e.setAttribute('upstream', p.upstream)
  329. elif value != p.revisionExpr:
  330. # Only save the origin if the origin is not a sha1, and the default
  331. # isn't our value
  332. e.setAttribute('upstream', p.revisionExpr)
  333. if peg_rev_dest_branch:
  334. if p.dest_branch:
  335. e.setAttribute('dest-branch', p.dest_branch)
  336. elif value != p.revisionExpr:
  337. e.setAttribute('dest-branch', p.revisionExpr)
  338. else:
  339. revision = self.remotes[p.remote.orig_name].revision or d.revisionExpr
  340. if not revision or revision != p.revisionExpr:
  341. e.setAttribute('revision', p.revisionExpr)
  342. if (p.upstream and (p.upstream != p.revisionExpr or
  343. p.upstream != d.upstreamExpr)):
  344. e.setAttribute('upstream', p.upstream)
  345. if p.dest_branch and p.dest_branch != d.destBranchExpr:
  346. e.setAttribute('dest-branch', p.dest_branch)
  347. for c in p.copyfiles:
  348. ce = doc.createElement('copyfile')
  349. ce.setAttribute('src', c.src)
  350. ce.setAttribute('dest', c.dest)
  351. e.appendChild(ce)
  352. for l in p.linkfiles:
  353. le = doc.createElement('linkfile')
  354. le.setAttribute('src', l.src)
  355. le.setAttribute('dest', l.dest)
  356. e.appendChild(le)
  357. default_groups = ['all', 'name:%s' % p.name, 'path:%s' % p.relpath]
  358. egroups = [g for g in p.groups if g not in default_groups]
  359. if egroups:
  360. e.setAttribute('groups', ','.join(egroups))
  361. for a in p.annotations:
  362. if a.keep == "true":
  363. ae = doc.createElement('annotation')
  364. ae.setAttribute('name', a.name)
  365. ae.setAttribute('value', a.value)
  366. e.appendChild(ae)
  367. if p.sync_c:
  368. e.setAttribute('sync-c', 'true')
  369. if p.sync_s:
  370. e.setAttribute('sync-s', 'true')
  371. if not p.sync_tags:
  372. e.setAttribute('sync-tags', 'false')
  373. if p.clone_depth:
  374. e.setAttribute('clone-depth', str(p.clone_depth))
  375. self._output_manifest_project_extras(p, e)
  376. if p.subprojects:
  377. subprojects = set(subp.name for subp in p.subprojects)
  378. output_projects(p, e, list(sorted(subprojects)))
  379. projects = set(p.name for p in self._paths.values() if not p.parent)
  380. output_projects(None, root, list(sorted(projects)))
  381. if self._repo_hooks_project:
  382. root.appendChild(doc.createTextNode(''))
  383. e = doc.createElement('repo-hooks')
  384. e.setAttribute('in-project', self._repo_hooks_project.name)
  385. e.setAttribute('enabled-list',
  386. ' '.join(self._repo_hooks_project.enabled_repo_hooks))
  387. root.appendChild(e)
  388. return doc
  389. def ToDict(self, **kwargs):
  390. """Return the current manifest as a dictionary."""
  391. # Elements that may only appear once.
  392. SINGLE_ELEMENTS = {
  393. 'notice',
  394. 'default',
  395. 'manifest-server',
  396. 'repo-hooks',
  397. }
  398. # Elements that may be repeated.
  399. MULTI_ELEMENTS = {
  400. 'remote',
  401. 'remove-project',
  402. 'project',
  403. 'extend-project',
  404. 'include',
  405. # These are children of 'project' nodes.
  406. 'annotation',
  407. 'project',
  408. 'copyfile',
  409. 'linkfile',
  410. }
  411. doc = self.ToXml(**kwargs)
  412. ret = {}
  413. def append_children(ret, node):
  414. for child in node.childNodes:
  415. if child.nodeType == xml.dom.Node.ELEMENT_NODE:
  416. attrs = child.attributes
  417. element = dict((attrs.item(i).localName, attrs.item(i).value)
  418. for i in range(attrs.length))
  419. if child.nodeName in SINGLE_ELEMENTS:
  420. ret[child.nodeName] = element
  421. elif child.nodeName in MULTI_ELEMENTS:
  422. ret.setdefault(child.nodeName, []).append(element)
  423. else:
  424. raise ManifestParseError('Unhandled element "%s"' % (child.nodeName,))
  425. append_children(element, child)
  426. append_children(ret, doc.firstChild)
  427. return ret
  428. def Save(self, fd, **kwargs):
  429. """Write the current manifest out to the given file descriptor."""
  430. doc = self.ToXml(**kwargs)
  431. doc.writexml(fd, '', ' ', '\n', 'UTF-8')
  432. def _output_manifest_project_extras(self, p, e):
  433. """Manifests can modify e if they support extra project attributes."""
  434. pass
  435. @property
  436. def paths(self):
  437. self._Load()
  438. return self._paths
  439. @property
  440. def projects(self):
  441. self._Load()
  442. return list(self._paths.values())
  443. @property
  444. def remotes(self):
  445. self._Load()
  446. return self._remotes
  447. @property
  448. def default(self):
  449. self._Load()
  450. return self._default
  451. @property
  452. def repo_hooks_project(self):
  453. self._Load()
  454. return self._repo_hooks_project
  455. @property
  456. def notice(self):
  457. self._Load()
  458. return self._notice
  459. @property
  460. def manifest_server(self):
  461. self._Load()
  462. return self._manifest_server
  463. @property
  464. def CloneBundle(self):
  465. clone_bundle = self.manifestProject.config.GetBoolean('repo.clonebundle')
  466. if clone_bundle is None:
  467. return False if self.manifestProject.config.GetBoolean('repo.partialclone') else True
  468. else:
  469. return clone_bundle
  470. @property
  471. def CloneFilter(self):
  472. if self.manifestProject.config.GetBoolean('repo.partialclone'):
  473. return self.manifestProject.config.GetString('repo.clonefilter')
  474. return None
  475. @property
  476. def IsMirror(self):
  477. return self.manifestProject.config.GetBoolean('repo.mirror')
  478. @property
  479. def UseGitWorktrees(self):
  480. return self.manifestProject.config.GetBoolean('repo.worktree')
  481. @property
  482. def IsArchive(self):
  483. return self.manifestProject.config.GetBoolean('repo.archive')
  484. @property
  485. def HasSubmodules(self):
  486. return self.manifestProject.config.GetBoolean('repo.submodules')
  487. def _Unload(self):
  488. self._loaded = False
  489. self._projects = {}
  490. self._paths = {}
  491. self._remotes = {}
  492. self._default = None
  493. self._repo_hooks_project = None
  494. self._notice = None
  495. self.branch = None
  496. self._manifest_server = None
  497. def _Load(self):
  498. if not self._loaded:
  499. m = self.manifestProject
  500. b = m.GetBranch(m.CurrentBranch).merge
  501. if b is not None and b.startswith(R_HEADS):
  502. b = b[len(R_HEADS):]
  503. self.branch = b
  504. nodes = []
  505. nodes.append(self._ParseManifestXml(self.manifestFile,
  506. self.manifestProject.worktree))
  507. if self._load_local_manifests:
  508. if os.path.exists(os.path.join(self.repodir, LOCAL_MANIFEST_NAME)):
  509. print('error: %s is not supported; put local manifests in `%s`'
  510. 'instead' % (LOCAL_MANIFEST_NAME,
  511. os.path.join(self.repodir, LOCAL_MANIFESTS_DIR_NAME)),
  512. file=sys.stderr)
  513. sys.exit(1)
  514. local_dir = os.path.abspath(os.path.join(self.repodir,
  515. LOCAL_MANIFESTS_DIR_NAME))
  516. try:
  517. for local_file in sorted(platform_utils.listdir(local_dir)):
  518. if local_file.endswith('.xml'):
  519. local = os.path.join(local_dir, local_file)
  520. nodes.append(self._ParseManifestXml(local, self.repodir))
  521. except OSError:
  522. pass
  523. try:
  524. self._ParseManifest(nodes)
  525. except ManifestParseError as e:
  526. # There was a problem parsing, unload ourselves in case they catch
  527. # this error and try again later, we will show the correct error
  528. self._Unload()
  529. raise e
  530. if self.IsMirror:
  531. self._AddMetaProjectMirror(self.repoProject)
  532. self._AddMetaProjectMirror(self.manifestProject)
  533. self._loaded = True
  534. def _ParseManifestXml(self, path, include_root):
  535. try:
  536. root = xml.dom.minidom.parse(path)
  537. except (OSError, xml.parsers.expat.ExpatError) as e:
  538. raise ManifestParseError("error parsing manifest %s: %s" % (path, e))
  539. if not root or not root.childNodes:
  540. raise ManifestParseError("no root node in %s" % (path,))
  541. for manifest in root.childNodes:
  542. if manifest.nodeName == 'manifest':
  543. break
  544. else:
  545. raise ManifestParseError("no <manifest> in %s" % (path,))
  546. nodes = []
  547. for node in manifest.childNodes:
  548. if node.nodeName == 'include':
  549. name = self._reqatt(node, 'name')
  550. fp = os.path.join(include_root, name)
  551. if not os.path.isfile(fp):
  552. raise ManifestParseError("include %s doesn't exist or isn't a file"
  553. % (name,))
  554. try:
  555. nodes.extend(self._ParseManifestXml(fp, include_root))
  556. # should isolate this to the exact exception, but that's
  557. # tricky. actual parsing implementation may vary.
  558. except (KeyboardInterrupt, RuntimeError, SystemExit):
  559. raise
  560. except Exception as e:
  561. raise ManifestParseError(
  562. "failed parsing included manifest %s: %s" % (name, e))
  563. else:
  564. nodes.append(node)
  565. return nodes
  566. def _ParseManifest(self, node_list):
  567. for node in itertools.chain(*node_list):
  568. if node.nodeName == 'remote':
  569. remote = self._ParseRemote(node)
  570. if remote:
  571. if remote.name in self._remotes:
  572. if remote != self._remotes[remote.name]:
  573. raise ManifestParseError(
  574. 'remote %s already exists with different attributes' %
  575. (remote.name))
  576. else:
  577. self._remotes[remote.name] = remote
  578. for node in itertools.chain(*node_list):
  579. if node.nodeName == 'default':
  580. new_default = self._ParseDefault(node)
  581. if self._default is None:
  582. self._default = new_default
  583. elif new_default != self._default:
  584. raise ManifestParseError('duplicate default in %s' %
  585. (self.manifestFile))
  586. if self._default is None:
  587. self._default = _Default()
  588. for node in itertools.chain(*node_list):
  589. if node.nodeName == 'notice':
  590. if self._notice is not None:
  591. raise ManifestParseError(
  592. 'duplicate notice in %s' %
  593. (self.manifestFile))
  594. self._notice = self._ParseNotice(node)
  595. for node in itertools.chain(*node_list):
  596. if node.nodeName == 'manifest-server':
  597. url = self._reqatt(node, 'url')
  598. if self._manifest_server is not None:
  599. raise ManifestParseError(
  600. 'duplicate manifest-server in %s' %
  601. (self.manifestFile))
  602. self._manifest_server = url
  603. def recursively_add_projects(project):
  604. projects = self._projects.setdefault(project.name, [])
  605. if project.relpath is None:
  606. raise ManifestParseError(
  607. 'missing path for %s in %s' %
  608. (project.name, self.manifestFile))
  609. if project.relpath in self._paths:
  610. raise ManifestParseError(
  611. 'duplicate path %s in %s' %
  612. (project.relpath, self.manifestFile))
  613. self._paths[project.relpath] = project
  614. projects.append(project)
  615. for subproject in project.subprojects:
  616. recursively_add_projects(subproject)
  617. for node in itertools.chain(*node_list):
  618. if node.nodeName == 'project':
  619. project = self._ParseProject(node)
  620. recursively_add_projects(project)
  621. if node.nodeName == 'extend-project':
  622. name = self._reqatt(node, 'name')
  623. if name not in self._projects:
  624. raise ManifestParseError('extend-project element specifies non-existent '
  625. 'project: %s' % name)
  626. path = node.getAttribute('path')
  627. groups = node.getAttribute('groups')
  628. if groups:
  629. groups = self._ParseGroups(groups)
  630. revision = node.getAttribute('revision')
  631. remote = node.getAttribute('remote')
  632. if remote:
  633. remote = self._get_remote(node)
  634. for p in self._projects[name]:
  635. if path and p.relpath != path:
  636. continue
  637. if groups:
  638. p.groups.extend(groups)
  639. if revision:
  640. p.revisionExpr = revision
  641. if IsId(revision):
  642. p.revisionId = revision
  643. else:
  644. p.revisionId = None
  645. if remote:
  646. p.remote = remote.ToRemoteSpec(name)
  647. if node.nodeName == 'repo-hooks':
  648. # Get the name of the project and the (space-separated) list of enabled.
  649. repo_hooks_project = self._reqatt(node, 'in-project')
  650. enabled_repo_hooks = self._reqatt(node, 'enabled-list').split()
  651. # Only one project can be the hooks project
  652. if self._repo_hooks_project is not None:
  653. raise ManifestParseError(
  654. 'duplicate repo-hooks in %s' %
  655. (self.manifestFile))
  656. # Store a reference to the Project.
  657. try:
  658. repo_hooks_projects = self._projects[repo_hooks_project]
  659. except KeyError:
  660. raise ManifestParseError(
  661. 'project %s not found for repo-hooks' %
  662. (repo_hooks_project))
  663. if len(repo_hooks_projects) != 1:
  664. raise ManifestParseError(
  665. 'internal error parsing repo-hooks in %s' %
  666. (self.manifestFile))
  667. self._repo_hooks_project = repo_hooks_projects[0]
  668. # Store the enabled hooks in the Project object.
  669. self._repo_hooks_project.enabled_repo_hooks = enabled_repo_hooks
  670. if node.nodeName == 'remove-project':
  671. name = self._reqatt(node, 'name')
  672. if name not in self._projects:
  673. raise ManifestParseError('remove-project element specifies non-existent '
  674. 'project: %s' % name)
  675. for p in self._projects[name]:
  676. del self._paths[p.relpath]
  677. del self._projects[name]
  678. # If the manifest removes the hooks project, treat it as if it deleted
  679. # the repo-hooks element too.
  680. if self._repo_hooks_project and (self._repo_hooks_project.name == name):
  681. self._repo_hooks_project = None
  682. def _AddMetaProjectMirror(self, m):
  683. name = None
  684. m_url = m.GetRemote(m.remote.name).url
  685. if m_url.endswith('/.git'):
  686. raise ManifestParseError('refusing to mirror %s' % m_url)
  687. if self._default and self._default.remote:
  688. url = self._default.remote.resolvedFetchUrl
  689. if not url.endswith('/'):
  690. url += '/'
  691. if m_url.startswith(url):
  692. remote = self._default.remote
  693. name = m_url[len(url):]
  694. if name is None:
  695. s = m_url.rindex('/') + 1
  696. manifestUrl = self.manifestProject.config.GetString('remote.origin.url')
  697. remote = _XmlRemote('origin', fetch=m_url[:s], manifestUrl=manifestUrl)
  698. name = m_url[s:]
  699. if name.endswith('.git'):
  700. name = name[:-4]
  701. if name not in self._projects:
  702. m.PreSync()
  703. gitdir = os.path.join(self.topdir, '%s.git' % name)
  704. project = Project(manifest=self,
  705. name=name,
  706. remote=remote.ToRemoteSpec(name),
  707. gitdir=gitdir,
  708. objdir=gitdir,
  709. worktree=None,
  710. relpath=name or None,
  711. revisionExpr=m.revisionExpr,
  712. revisionId=None)
  713. self._projects[project.name] = [project]
  714. self._paths[project.relpath] = project
  715. def _ParseRemote(self, node):
  716. """
  717. reads a <remote> element from the manifest file
  718. """
  719. name = self._reqatt(node, 'name')
  720. alias = node.getAttribute('alias')
  721. if alias == '':
  722. alias = None
  723. fetch = self._reqatt(node, 'fetch')
  724. pushUrl = node.getAttribute('pushurl')
  725. if pushUrl == '':
  726. pushUrl = None
  727. review = node.getAttribute('review')
  728. if review == '':
  729. review = None
  730. revision = node.getAttribute('revision')
  731. if revision == '':
  732. revision = None
  733. manifestUrl = self.manifestProject.config.GetString('remote.origin.url')
  734. return _XmlRemote(name, alias, fetch, pushUrl, manifestUrl, review, revision)
  735. def _ParseDefault(self, node):
  736. """
  737. reads a <default> element from the manifest file
  738. """
  739. d = _Default()
  740. d.remote = self._get_remote(node)
  741. d.revisionExpr = node.getAttribute('revision')
  742. if d.revisionExpr == '':
  743. d.revisionExpr = None
  744. d.destBranchExpr = node.getAttribute('dest-branch') or None
  745. d.upstreamExpr = node.getAttribute('upstream') or None
  746. d.sync_j = XmlInt(node, 'sync-j', 1)
  747. if d.sync_j <= 0:
  748. raise ManifestParseError('%s: sync-j must be greater than 0, not "%s"' %
  749. (self.manifestFile, d.sync_j))
  750. d.sync_c = XmlBool(node, 'sync-c', False)
  751. d.sync_s = XmlBool(node, 'sync-s', False)
  752. d.sync_tags = XmlBool(node, 'sync-tags', True)
  753. return d
  754. def _ParseNotice(self, node):
  755. """
  756. reads a <notice> element from the manifest file
  757. The <notice> element is distinct from other tags in the XML in that the
  758. data is conveyed between the start and end tag (it's not an empty-element
  759. tag).
  760. The white space (carriage returns, indentation) for the notice element is
  761. relevant and is parsed in a way that is based on how python docstrings work.
  762. In fact, the code is remarkably similar to here:
  763. http://www.python.org/dev/peps/pep-0257/
  764. """
  765. # Get the data out of the node...
  766. notice = node.childNodes[0].data
  767. # Figure out minimum indentation, skipping the first line (the same line
  768. # as the <notice> tag)...
  769. minIndent = sys.maxsize
  770. lines = notice.splitlines()
  771. for line in lines[1:]:
  772. lstrippedLine = line.lstrip()
  773. if lstrippedLine:
  774. indent = len(line) - len(lstrippedLine)
  775. minIndent = min(indent, minIndent)
  776. # Strip leading / trailing blank lines and also indentation.
  777. cleanLines = [lines[0].strip()]
  778. for line in lines[1:]:
  779. cleanLines.append(line[minIndent:].rstrip())
  780. # Clear completely blank lines from front and back...
  781. while cleanLines and not cleanLines[0]:
  782. del cleanLines[0]
  783. while cleanLines and not cleanLines[-1]:
  784. del cleanLines[-1]
  785. return '\n'.join(cleanLines)
  786. def _JoinName(self, parent_name, name):
  787. return os.path.join(parent_name, name)
  788. def _UnjoinName(self, parent_name, name):
  789. return os.path.relpath(name, parent_name)
  790. def _ParseProject(self, node, parent=None, **extra_proj_attrs):
  791. """
  792. reads a <project> element from the manifest file
  793. """
  794. name = self._reqatt(node, 'name')
  795. if parent:
  796. name = self._JoinName(parent.name, name)
  797. remote = self._get_remote(node)
  798. if remote is None:
  799. remote = self._default.remote
  800. if remote is None:
  801. raise ManifestParseError("no remote for project %s within %s" %
  802. (name, self.manifestFile))
  803. revisionExpr = node.getAttribute('revision') or remote.revision
  804. if not revisionExpr:
  805. revisionExpr = self._default.revisionExpr
  806. if not revisionExpr:
  807. raise ManifestParseError("no revision for project %s within %s" %
  808. (name, self.manifestFile))
  809. path = node.getAttribute('path')
  810. if not path:
  811. path = name
  812. if path.startswith('/'):
  813. raise ManifestParseError("project %s path cannot be absolute in %s" %
  814. (name, self.manifestFile))
  815. rebase = XmlBool(node, 'rebase', True)
  816. sync_c = XmlBool(node, 'sync-c', False)
  817. sync_s = XmlBool(node, 'sync-s', self._default.sync_s)
  818. sync_tags = XmlBool(node, 'sync-tags', self._default.sync_tags)
  819. clone_depth = XmlInt(node, 'clone-depth')
  820. if clone_depth is not None and clone_depth <= 0:
  821. raise ManifestParseError('%s: clone-depth must be greater than 0, not "%s"' %
  822. (self.manifestFile, clone_depth))
  823. dest_branch = node.getAttribute('dest-branch') or self._default.destBranchExpr
  824. upstream = node.getAttribute('upstream') or self._default.upstreamExpr
  825. groups = ''
  826. if node.hasAttribute('groups'):
  827. groups = node.getAttribute('groups')
  828. groups = self._ParseGroups(groups)
  829. if parent is None:
  830. relpath, worktree, gitdir, objdir, use_git_worktrees = \
  831. self.GetProjectPaths(name, path)
  832. else:
  833. use_git_worktrees = False
  834. relpath, worktree, gitdir, objdir = \
  835. self.GetSubprojectPaths(parent, name, path)
  836. default_groups = ['all', 'name:%s' % name, 'path:%s' % relpath]
  837. groups.extend(set(default_groups).difference(groups))
  838. if self.IsMirror and node.hasAttribute('force-path'):
  839. if XmlBool(node, 'force-path', False):
  840. gitdir = os.path.join(self.topdir, '%s.git' % path)
  841. project = Project(manifest=self,
  842. name=name,
  843. remote=remote.ToRemoteSpec(name),
  844. gitdir=gitdir,
  845. objdir=objdir,
  846. worktree=worktree,
  847. relpath=relpath,
  848. revisionExpr=revisionExpr,
  849. revisionId=None,
  850. rebase=rebase,
  851. groups=groups,
  852. sync_c=sync_c,
  853. sync_s=sync_s,
  854. sync_tags=sync_tags,
  855. clone_depth=clone_depth,
  856. upstream=upstream,
  857. parent=parent,
  858. dest_branch=dest_branch,
  859. use_git_worktrees=use_git_worktrees,
  860. **extra_proj_attrs)
  861. for n in node.childNodes:
  862. if n.nodeName == 'copyfile':
  863. self._ParseCopyFile(project, n)
  864. if n.nodeName == 'linkfile':
  865. self._ParseLinkFile(project, n)
  866. if n.nodeName == 'annotation':
  867. self._ParseAnnotation(project, n)
  868. if n.nodeName == 'project':
  869. project.subprojects.append(self._ParseProject(n, parent=project))
  870. return project
  871. def GetProjectPaths(self, name, path):
  872. # The manifest entries might have trailing slashes. Normalize them to avoid
  873. # unexpected filesystem behavior since we do string concatenation below.
  874. path = path.rstrip('/')
  875. name = name.rstrip('/')
  876. use_git_worktrees = False
  877. relpath = path
  878. if self.IsMirror:
  879. worktree = None
  880. gitdir = os.path.join(self.topdir, '%s.git' % name)
  881. objdir = gitdir
  882. else:
  883. worktree = os.path.join(self.topdir, path).replace('\\', '/')
  884. gitdir = os.path.join(self.repodir, 'projects', '%s.git' % path)
  885. # We allow people to mix git worktrees & non-git worktrees for now.
  886. # This allows for in situ migration of repo clients.
  887. if os.path.exists(gitdir) or not self.UseGitWorktrees:
  888. objdir = os.path.join(self.repodir, 'project-objects', '%s.git' % name)
  889. else:
  890. use_git_worktrees = True
  891. gitdir = os.path.join(self.repodir, 'worktrees', '%s.git' % name)
  892. objdir = gitdir
  893. return relpath, worktree, gitdir, objdir, use_git_worktrees
  894. def GetProjectsWithName(self, name):
  895. return self._projects.get(name, [])
  896. def GetSubprojectName(self, parent, submodule_path):
  897. return os.path.join(parent.name, submodule_path)
  898. def _JoinRelpath(self, parent_relpath, relpath):
  899. return os.path.join(parent_relpath, relpath)
  900. def _UnjoinRelpath(self, parent_relpath, relpath):
  901. return os.path.relpath(relpath, parent_relpath)
  902. def GetSubprojectPaths(self, parent, name, path):
  903. # The manifest entries might have trailing slashes. Normalize them to avoid
  904. # unexpected filesystem behavior since we do string concatenation below.
  905. path = path.rstrip('/')
  906. name = name.rstrip('/')
  907. relpath = self._JoinRelpath(parent.relpath, path)
  908. gitdir = os.path.join(parent.gitdir, 'subprojects', '%s.git' % path)
  909. objdir = os.path.join(parent.gitdir, 'subproject-objects', '%s.git' % name)
  910. if self.IsMirror:
  911. worktree = None
  912. else:
  913. worktree = os.path.join(parent.worktree, path).replace('\\', '/')
  914. return relpath, worktree, gitdir, objdir
  915. @staticmethod
  916. def _CheckLocalPath(path, symlink=False):
  917. """Verify |path| is reasonable for use in <copyfile> & <linkfile>."""
  918. if '~' in path:
  919. return '~ not allowed (due to 8.3 filenames on Windows filesystems)'
  920. # Some filesystems (like Apple's HFS+) try to normalize Unicode codepoints
  921. # which means there are alternative names for ".git". Reject paths with
  922. # these in it as there shouldn't be any reasonable need for them here.
  923. # The set of codepoints here was cribbed from jgit's implementation:
  924. # https://eclipse.googlesource.com/jgit/jgit/+/9110037e3e9461ff4dac22fee84ef3694ed57648/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java#884
  925. BAD_CODEPOINTS = {
  926. u'\u200C', # ZERO WIDTH NON-JOINER
  927. u'\u200D', # ZERO WIDTH JOINER
  928. u'\u200E', # LEFT-TO-RIGHT MARK
  929. u'\u200F', # RIGHT-TO-LEFT MARK
  930. u'\u202A', # LEFT-TO-RIGHT EMBEDDING
  931. u'\u202B', # RIGHT-TO-LEFT EMBEDDING
  932. u'\u202C', # POP DIRECTIONAL FORMATTING
  933. u'\u202D', # LEFT-TO-RIGHT OVERRIDE
  934. u'\u202E', # RIGHT-TO-LEFT OVERRIDE
  935. u'\u206A', # INHIBIT SYMMETRIC SWAPPING
  936. u'\u206B', # ACTIVATE SYMMETRIC SWAPPING
  937. u'\u206C', # INHIBIT ARABIC FORM SHAPING
  938. u'\u206D', # ACTIVATE ARABIC FORM SHAPING
  939. u'\u206E', # NATIONAL DIGIT SHAPES
  940. u'\u206F', # NOMINAL DIGIT SHAPES
  941. u'\uFEFF', # ZERO WIDTH NO-BREAK SPACE
  942. }
  943. if BAD_CODEPOINTS & set(path):
  944. # This message is more expansive than reality, but should be fine.
  945. return 'Unicode combining characters not allowed'
  946. # Assume paths might be used on case-insensitive filesystems.
  947. path = path.lower()
  948. # Split up the path by its components. We can't use os.path.sep exclusively
  949. # as some platforms (like Windows) will convert / to \ and that bypasses all
  950. # our constructed logic here. Especially since manifest authors only use
  951. # / in their paths.
  952. resep = re.compile(r'[/%s]' % re.escape(os.path.sep))
  953. parts = resep.split(path)
  954. # Some people use src="." to create stable links to projects. Lets allow
  955. # that but reject all other uses of "." to keep things simple.
  956. if parts != ['.']:
  957. for part in set(parts):
  958. if part in {'.', '..', '.git'} or part.startswith('.repo'):
  959. return 'bad component: %s' % (part,)
  960. if not symlink and resep.match(path[-1]):
  961. return 'dirs not allowed'
  962. # NB: The two abspath checks here are to handle platforms with multiple
  963. # filesystem path styles (e.g. Windows).
  964. norm = os.path.normpath(path)
  965. if (norm == '..' or
  966. (len(norm) >= 3 and norm.startswith('..') and resep.match(norm[0])) or
  967. os.path.isabs(norm) or
  968. norm.startswith('/')):
  969. return 'path cannot be outside'
  970. @classmethod
  971. def _ValidateFilePaths(cls, element, src, dest):
  972. """Verify |src| & |dest| are reasonable for <copyfile> & <linkfile>.
  973. We verify the path independent of any filesystem state as we won't have a
  974. checkout available to compare to. i.e. This is for parsing validation
  975. purposes only.
  976. We'll do full/live sanity checking before we do the actual filesystem
  977. modifications in _CopyFile/_LinkFile/etc...
  978. """
  979. # |dest| is the file we write to or symlink we create.
  980. # It is relative to the top of the repo client checkout.
  981. msg = cls._CheckLocalPath(dest)
  982. if msg:
  983. raise ManifestInvalidPathError(
  984. '<%s> invalid "dest": %s: %s' % (element, dest, msg))
  985. # |src| is the file we read from or path we point to for symlinks.
  986. # It is relative to the top of the git project checkout.
  987. msg = cls._CheckLocalPath(src, symlink=element == 'linkfile')
  988. if msg:
  989. raise ManifestInvalidPathError(
  990. '<%s> invalid "src": %s: %s' % (element, src, msg))
  991. def _ParseCopyFile(self, project, node):
  992. src = self._reqatt(node, 'src')
  993. dest = self._reqatt(node, 'dest')
  994. if not self.IsMirror:
  995. # src is project relative;
  996. # dest is relative to the top of the tree.
  997. # We only validate paths if we actually plan to process them.
  998. self._ValidateFilePaths('copyfile', src, dest)
  999. project.AddCopyFile(src, dest, self.topdir)
  1000. def _ParseLinkFile(self, project, node):
  1001. src = self._reqatt(node, 'src')
  1002. dest = self._reqatt(node, 'dest')
  1003. if not self.IsMirror:
  1004. # src is project relative;
  1005. # dest is relative to the top of the tree.
  1006. # We only validate paths if we actually plan to process them.
  1007. self._ValidateFilePaths('linkfile', src, dest)
  1008. project.AddLinkFile(src, dest, self.topdir)
  1009. def _ParseAnnotation(self, project, node):
  1010. name = self._reqatt(node, 'name')
  1011. value = self._reqatt(node, 'value')
  1012. try:
  1013. keep = self._reqatt(node, 'keep').lower()
  1014. except ManifestParseError:
  1015. keep = "true"
  1016. if keep != "true" and keep != "false":
  1017. raise ManifestParseError('optional "keep" attribute must be '
  1018. '"true" or "false"')
  1019. project.AddAnnotation(name, value, keep)
  1020. def _get_remote(self, node):
  1021. name = node.getAttribute('remote')
  1022. if not name:
  1023. return None
  1024. v = self._remotes.get(name)
  1025. if not v:
  1026. raise ManifestParseError("remote %s not defined in %s" %
  1027. (name, self.manifestFile))
  1028. return v
  1029. def _reqatt(self, node, attname):
  1030. """
  1031. reads a required attribute from the node.
  1032. """
  1033. v = node.getAttribute(attname)
  1034. if not v:
  1035. raise ManifestParseError("no %s in <%s> within %s" %
  1036. (attname, node.nodeName, self.manifestFile))
  1037. return v
  1038. def projectsDiff(self, manifest):
  1039. """return the projects differences between two manifests.
  1040. The diff will be from self to given manifest.
  1041. """
  1042. fromProjects = self.paths
  1043. toProjects = manifest.paths
  1044. fromKeys = sorted(fromProjects.keys())
  1045. toKeys = sorted(toProjects.keys())
  1046. diff = {'added': [], 'removed': [], 'changed': [], 'unreachable': []}
  1047. for proj in fromKeys:
  1048. if proj not in toKeys:
  1049. diff['removed'].append(fromProjects[proj])
  1050. else:
  1051. fromProj = fromProjects[proj]
  1052. toProj = toProjects[proj]
  1053. try:
  1054. fromRevId = fromProj.GetCommitRevisionId()
  1055. toRevId = toProj.GetCommitRevisionId()
  1056. except ManifestInvalidRevisionError:
  1057. diff['unreachable'].append((fromProj, toProj))
  1058. else:
  1059. if fromRevId != toRevId:
  1060. diff['changed'].append((fromProj, toProj))
  1061. toKeys.remove(proj)
  1062. for proj in toKeys:
  1063. diff['added'].append(toProjects[proj])
  1064. return diff
  1065. class GitcManifest(XmlManifest):
  1066. def __init__(self, repodir, gitc_client_name):
  1067. """Initialize the GitcManifest object."""
  1068. super(GitcManifest, self).__init__(repodir)
  1069. self.isGitcClient = True
  1070. self.gitc_client_name = gitc_client_name
  1071. self.gitc_client_dir = os.path.join(gitc_utils.get_gitc_manifest_dir(),
  1072. gitc_client_name)
  1073. self.manifestFile = os.path.join(self.gitc_client_dir, '.manifest')
  1074. def _ParseProject(self, node, parent=None):
  1075. """Override _ParseProject and add support for GITC specific attributes."""
  1076. return super(GitcManifest, self)._ParseProject(
  1077. node, parent=parent, old_revision=node.getAttribute('old-revision'))
  1078. def _output_manifest_project_extras(self, p, e):
  1079. """Output GITC Specific Project attributes"""
  1080. if p.old_revision:
  1081. e.setAttribute('old-revision', str(p.old_revision))