summaryrefslogtreecommitdiffstats
path: root/manifest_xml.py
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2009-05-19 14:58:02 -0700
committerShawn O. Pearce <sop@google.com>2009-05-29 09:31:28 -0700
commitd1f70d9929ddd2748ccc9c1dd2f9603068e1f3e6 (patch)
tree746fa0d1ace702f114357d1798bc67eddd1b79a9 /manifest_xml.py
parentc8a300f6397dad7db00c3654ff6e50e9519ed7c9 (diff)
downloadgit-repo-d1f70d9929ddd2748ccc9c1dd2f9603068e1f3e6.tar.gz
Refactor how projects parse remotes so it can be replaced
We now feed Project a RemoteSpec, instead of the Remote directly from the XmlManifest. This way the RemoteSpec already has the full project URL, rather than just the base, permitting other types of manifests to produce the URL in their own style. Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'manifest_xml.py')
-rw-r--r--manifest_xml.py26
1 files changed, 20 insertions, 6 deletions
diff --git a/manifest_xml.py b/manifest_xml.py
index 46976538..5c5617ac 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -18,8 +18,7 @@ import sys
18import xml.dom.minidom 18import xml.dom.minidom
19 19
20from git_config import GitConfig, IsId 20from git_config import GitConfig, IsId
21from project import Project, MetaProject, R_HEADS, HEAD 21from project import RemoteSpec, Project, MetaProject, R_HEADS, HEAD
22from remote import Remote
23from error import ManifestParseError 22from error import ManifestParseError
24 23
25MANIFEST_FILE_NAME = 'manifest.xml' 24MANIFEST_FILE_NAME = 'manifest.xml'
@@ -31,6 +30,21 @@ class _Default(object):
31 revision = None 30 revision = None
32 remote = None 31 remote = None
33 32
33class _XmlRemote(object):
34 def __init__(self,
35 name,
36 fetch=None,
37 review=None):
38 self.name = name
39 self.fetchUrl = fetch
40 self.reviewUrl = review
41
42 def ToRemoteSpec(self, projectName):
43 url = self.fetchUrl
44 while url.endswith('/'):
45 url = url[:-1]
46 url += '/%s.git' % projectName
47 return RemoteSpec(self.name, url, self.reviewUrl)
34 48
35class XmlManifest(object): 49class XmlManifest(object):
36 """manages the repo configuration file""" 50 """manages the repo configuration file"""
@@ -257,7 +271,7 @@ class XmlManifest(object):
257 271
258 if name is None: 272 if name is None:
259 s = m_url.rindex('/') + 1 273 s = m_url.rindex('/') + 1
260 remote = Remote('origin', fetch = m_url[:s]) 274 remote = _XmlRemote('origin', m_url[:s])
261 name = m_url[s:] 275 name = m_url[s:]
262 276
263 if name.endswith('.git'): 277 if name.endswith('.git'):
@@ -268,7 +282,7 @@ class XmlManifest(object):
268 gitdir = os.path.join(self.topdir, '%s.git' % name) 282 gitdir = os.path.join(self.topdir, '%s.git' % name)
269 project = Project(manifest = self, 283 project = Project(manifest = self,
270 name = name, 284 name = name,
271 remote = remote, 285 remote = remote.ToRemoteSpec(name),
272 gitdir = gitdir, 286 gitdir = gitdir,
273 worktree = None, 287 worktree = None,
274 relpath = None, 288 relpath = None,
@@ -284,7 +298,7 @@ class XmlManifest(object):
284 review = node.getAttribute('review') 298 review = node.getAttribute('review')
285 if review == '': 299 if review == '':
286 review = None 300 review = None
287 return Remote(name=name, fetch=fetch, review=review) 301 return _XmlRemote(name, fetch, review)
288 302
289 def _ParseDefault(self, node): 303 def _ParseDefault(self, node):
290 """ 304 """
@@ -337,7 +351,7 @@ class XmlManifest(object):
337 351
338 project = Project(manifest = self, 352 project = Project(manifest = self,
339 name = name, 353 name = name,
340 remote = remote, 354 remote = remote.ToRemoteSpec(name),
341 gitdir = gitdir, 355 gitdir = gitdir,
342 worktree = worktree, 356 worktree = worktree,
343 relpath = path, 357 relpath = path,