diff options
| -rw-r--r-- | manifest_xml.py | 26 | ||||
| -rw-r--r-- | project.py | 25 | ||||
| -rw-r--r-- | remote.py | 22 | ||||
| -rw-r--r-- | subcmds/init.py | 1 |
4 files changed, 33 insertions, 41 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 | |||
| 18 | import xml.dom.minidom | 18 | import xml.dom.minidom |
| 19 | 19 | ||
| 20 | from git_config import GitConfig, IsId | 20 | from git_config import GitConfig, IsId |
| 21 | from project import Project, MetaProject, R_HEADS, HEAD | 21 | from project import RemoteSpec, Project, MetaProject, R_HEADS, HEAD |
| 22 | from remote import Remote | ||
| 23 | from error import ManifestParseError | 22 | from error import ManifestParseError |
| 24 | 23 | ||
| 25 | MANIFEST_FILE_NAME = 'manifest.xml' | 24 | MANIFEST_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 | ||
| 33 | class _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 | ||
| 35 | class XmlManifest(object): | 49 | class 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, |
| @@ -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 | ||
diff --git a/remote.py b/remote.py deleted file mode 100644 index bb8f740c..00000000 --- a/remote.py +++ /dev/null | |||
| @@ -1,22 +0,0 @@ | |||
| 1 | # | ||
| 2 | # Copyright (C) 2008 The Android Open Source Project | ||
| 3 | # | ||
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | # you may not use this file except in compliance with the License. | ||
| 6 | # You may obtain a copy of the License at | ||
| 7 | # | ||
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | # | ||
| 10 | # Unless required by applicable law or agreed to in writing, software | ||
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | # See the License for the specific language governing permissions and | ||
| 14 | # limitations under the License. | ||
| 15 | |||
| 16 | class Remote(object): | ||
| 17 | def __init__(self, name, | ||
| 18 | fetch=None, | ||
| 19 | review=None): | ||
| 20 | self.name = name | ||
| 21 | self.fetchUrl = fetch | ||
| 22 | self.reviewUrl = review | ||
diff --git a/subcmds/init.py b/subcmds/init.py index 90b76e8b..0d0fcd06 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
| @@ -19,7 +19,6 @@ import sys | |||
| 19 | from color import Coloring | 19 | from color import Coloring |
| 20 | from command import InteractiveCommand, MirrorSafeCommand | 20 | from command import InteractiveCommand, MirrorSafeCommand |
| 21 | from error import ManifestParseError | 21 | from error import ManifestParseError |
| 22 | from remote import Remote | ||
| 23 | from project import SyncBuffer | 22 | from project import SyncBuffer |
| 24 | from git_command import git, MIN_GIT_VERSION | 23 | from git_command import git, MIN_GIT_VERSION |
| 25 | 24 | ||
