diff options
Diffstat (limited to 'subcmds/init.py')
-rw-r--r-- | subcmds/init.py | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/subcmds/init.py b/subcmds/init.py index 1c23d620..e80d698b 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
@@ -23,6 +23,7 @@ from error import ManifestParseError | |||
23 | from project import SyncBuffer | 23 | from project import SyncBuffer |
24 | from git_config import GitConfig | 24 | from git_config import GitConfig |
25 | from git_command import git_require, MIN_GIT_VERSION | 25 | from git_command import git_require, MIN_GIT_VERSION |
26 | from git_config import GitConfig | ||
26 | 27 | ||
27 | class Init(InteractiveCommand, MirrorSafeCommand): | 28 | class Init(InteractiveCommand, MirrorSafeCommand): |
28 | common = True | 29 | common = True |
@@ -36,6 +37,20 @@ The latest repo source code and manifest collection is downloaded | |||
36 | from the server and is installed in the .repo/ directory in the | 37 | from the server and is installed in the .repo/ directory in the |
37 | current working directory. | 38 | current working directory. |
38 | 39 | ||
40 | The optional -u argument can be used to specify a URL to the | ||
41 | manifest project. It is also possible to have a git configuration | ||
42 | section as below to use 'identifier' as argument to -u: | ||
43 | |||
44 | [repo-manifest "identifier"] | ||
45 | url = ... | ||
46 | server = ... | ||
47 | reference = ... | ||
48 | |||
49 | Only the url is required - the others are optional. | ||
50 | |||
51 | If no -u argument is specified, the 'repo-manifest' section named | ||
52 | 'default' will be used if present. | ||
53 | |||
39 | The optional -b argument can be used to select the manifest branch | 54 | The optional -b argument can be used to select the manifest branch |
40 | to checkout and use. If no branch is specified, master is assumed. | 55 | to checkout and use. If no branch is specified, master is assumed. |
41 | 56 | ||
@@ -69,7 +84,7 @@ to update the working directory files. | |||
69 | # Manifest | 84 | # Manifest |
70 | g = p.add_option_group('Manifest options') | 85 | g = p.add_option_group('Manifest options') |
71 | g.add_option('-u', '--manifest-url', | 86 | g.add_option('-u', '--manifest-url', |
72 | dest='manifest_url', | 87 | dest='manifest_url', default='default', |
73 | help='manifest repository location', metavar='URL') | 88 | help='manifest repository location', metavar='URL') |
74 | g.add_option('-b', '--manifest-branch', | 89 | g.add_option('-b', '--manifest-branch', |
75 | dest='manifest_branch', | 90 | dest='manifest_branch', |
@@ -102,10 +117,25 @@ to update the working directory files. | |||
102 | def _SyncManifest(self, opt): | 117 | def _SyncManifest(self, opt): |
103 | m = self.manifest.manifestProject | 118 | m = self.manifest.manifestProject |
104 | is_new = not m.Exists | 119 | is_new = not m.Exists |
120 | manifest_server = None | ||
121 | |||
122 | # The manifest url may point out a manifest section in the config | ||
123 | key = 'repo-manifest.%s.' % opt.manifest_url | ||
124 | if GitConfig.ForUser().GetString(key + 'url'): | ||
125 | opt.manifest_url = GitConfig.ForUser().GetString(key + 'url') | ||
126 | |||
127 | # Also copy other options to the manifest config if not specified already. | ||
128 | if not opt.reference: | ||
129 | opt.reference = GitConfig.ForUser().GetString(key + 'reference') | ||
130 | manifest_server = GitConfig.ForUser().GetString(key + 'server') | ||
105 | 131 | ||
106 | if is_new: | 132 | if is_new: |
107 | if not opt.manifest_url: | 133 | if not opt.manifest_url or opt.manifest_url == 'default': |
108 | print >>sys.stderr, 'fatal: manifest url (-u) is required.' | 134 | print >>sys.stderr, """\ |
135 | fatal: missing manifest url (-u) and no default found. | ||
136 | |||
137 | tip: The global git configuration key 'repo-manifest.default.url' can | ||
138 | be used to specify a default url.""" | ||
109 | sys.exit(1) | 139 | sys.exit(1) |
110 | 140 | ||
111 | if not opt.quiet: | 141 | if not opt.quiet: |
@@ -129,6 +159,9 @@ to update the working directory files. | |||
129 | r.ResetFetch() | 159 | r.ResetFetch() |
130 | r.Save() | 160 | r.Save() |
131 | 161 | ||
162 | if manifest_server: | ||
163 | m.config.SetString('repo.manifest-server', manifest_server) | ||
164 | |||
132 | if opt.reference: | 165 | if opt.reference: |
133 | m.config.SetString('repo.reference', opt.reference) | 166 | m.config.SetString('repo.reference', opt.reference) |
134 | 167 | ||