diff options
author | Shawn O. Pearce <sop@google.com> | 2009-05-19 14:58:02 -0700 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2009-05-29 09:31:28 -0700 |
commit | d1f70d9929ddd2748ccc9c1dd2f9603068e1f3e6 (patch) | |
tree | 746fa0d1ace702f114357d1798bc67eddd1b79a9 /project.py | |
parent | c8a300f6397dad7db00c3654ff6e50e9519ed7c9 (diff) | |
download | git-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 'project.py')
-rw-r--r-- | project.py | 25 |
1 files changed, 13 insertions, 12 deletions
@@ -26,7 +26,6 @@ from git_command import GitCommand | |||
26 | from git_config import GitConfig, IsId | 26 | from git_config import GitConfig, IsId |
27 | from error import GitError, ImportError, UploadError | 27 | from error import GitError, ImportError, UploadError |
28 | from error import ManifestInvalidRevisionError | 28 | from error import ManifestInvalidRevisionError |
29 | from remote import Remote | ||
30 | 29 | ||
31 | from git_refs import GitRefs, HEAD, R_HEADS, R_TAGS, R_PUB, R_M | 30 | from git_refs import GitRefs, HEAD, R_HEADS, R_TAGS, R_PUB, R_M |
32 | 31 | ||
@@ -212,6 +211,14 @@ class _CopyFile: | |||
212 | except IOError: | 211 | except IOError: |
213 | _error('Cannot copy file %s to %s', src, dest) | 212 | _error('Cannot copy file %s to %s', src, dest) |
214 | 213 | ||
214 | class RemoteSpec(object): | ||
215 | def __init__(self, | ||
216 | name, | ||
217 | url = None, | ||
218 | review = None): | ||
219 | self.name = name | ||
220 | self.url = url | ||
221 | self.review = review | ||
215 | 222 | ||
216 | class Project(object): | 223 | class Project(object): |
217 | def __init__(self, | 224 | def __init__(self, |
@@ -1061,17 +1068,11 @@ class Project(object): | |||
1061 | raise | 1068 | raise |
1062 | 1069 | ||
1063 | def _InitRemote(self): | 1070 | def _InitRemote(self): |
1064 | if self.remote.fetchUrl: | 1071 | if self.remote.url: |
1065 | remote = self.GetRemote(self.remote.name) | 1072 | remote = self.GetRemote(self.remote.name) |
1066 | 1073 | remote.url = self.remote.url | |
1067 | url = self.remote.fetchUrl | 1074 | remote.review = self.remote.review |
1068 | while url.endswith('/'): | 1075 | remote.projectname = self.name |
1069 | url = url[:-1] | ||
1070 | url += '/%s.git' % self.name | ||
1071 | remote.url = url | ||
1072 | remote.review = self.remote.reviewUrl | ||
1073 | if remote.projectname is None: | ||
1074 | remote.projectname = self.name | ||
1075 | 1076 | ||
1076 | if self.worktree: | 1077 | if self.worktree: |
1077 | remote.ResetFetch(mirror=False) | 1078 | remote.ResetFetch(mirror=False) |
@@ -1426,7 +1427,7 @@ class MetaProject(Project): | |||
1426 | name = name, | 1427 | name = name, |
1427 | gitdir = gitdir, | 1428 | gitdir = gitdir, |
1428 | worktree = worktree, | 1429 | worktree = worktree, |
1429 | remote = Remote('origin'), | 1430 | remote = RemoteSpec('origin'), |
1430 | relpath = '.repo/%s' % name, | 1431 | relpath = '.repo/%s' % name, |
1431 | revision = 'refs/heads/master') | 1432 | revision = 'refs/heads/master') |
1432 | 1433 | ||