diff options
Diffstat (limited to 'subcmds/init.py')
| -rw-r--r-- | subcmds/init.py | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/subcmds/init.py b/subcmds/init.py index 99007d60..7aaa7f17 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | # See the License for the specific language governing permissions and | 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. | 14 | # limitations under the License. |
| 15 | 15 | ||
| 16 | from __future__ import print_function | ||
| 16 | import os | 17 | import os |
| 17 | import platform | 18 | import platform |
| 18 | import re | 19 | import re |
| @@ -123,12 +124,12 @@ to update the working directory files. | |||
| 123 | 124 | ||
| 124 | if is_new: | 125 | if is_new: |
| 125 | if not opt.manifest_url: | 126 | if not opt.manifest_url: |
| 126 | print >>sys.stderr, 'fatal: manifest url (-u) is required.' | 127 | print('fatal: manifest url (-u) is required.', file=sys.stderr) |
| 127 | sys.exit(1) | 128 | sys.exit(1) |
| 128 | 129 | ||
| 129 | if not opt.quiet: | 130 | if not opt.quiet: |
| 130 | print >>sys.stderr, 'Get %s' \ | 131 | print('Get %s' % GitConfig.ForUser().UrlInsteadOf(opt.manifest_url), |
| 131 | % GitConfig.ForUser().UrlInsteadOf(opt.manifest_url) | 132 | file=sys.stderr) |
| 132 | m._InitGitDir() | 133 | m._InitGitDir() |
| 133 | 134 | ||
| 134 | if opt.manifest_branch: | 135 | if opt.manifest_branch: |
| @@ -159,7 +160,7 @@ to update the working directory files. | |||
| 159 | elif opt.platform in all_platforms: | 160 | elif opt.platform in all_platforms: |
| 160 | groups.extend(platformize(opt.platform)) | 161 | groups.extend(platformize(opt.platform)) |
| 161 | elif opt.platform != 'none': | 162 | elif opt.platform != 'none': |
| 162 | print >>sys.stderr, 'fatal: invalid platform flag' | 163 | print('fatal: invalid platform flag', file=sys.stderr) |
| 163 | sys.exit(1) | 164 | sys.exit(1) |
| 164 | 165 | ||
| 165 | groups = [x for x in groups if x] | 166 | groups = [x for x in groups if x] |
| @@ -175,12 +176,13 @@ to update the working directory files. | |||
| 175 | if is_new: | 176 | if is_new: |
| 176 | m.config.SetString('repo.mirror', 'true') | 177 | m.config.SetString('repo.mirror', 'true') |
| 177 | else: | 178 | else: |
| 178 | print >>sys.stderr, 'fatal: --mirror not supported on existing client' | 179 | print('fatal: --mirror not supported on existing client', |
| 180 | file=sys.stderr) | ||
| 179 | sys.exit(1) | 181 | sys.exit(1) |
| 180 | 182 | ||
| 181 | if not m.Sync_NetworkHalf(is_new=is_new): | 183 | if not m.Sync_NetworkHalf(is_new=is_new): |
| 182 | r = m.GetRemote(m.remote.name) | 184 | r = m.GetRemote(m.remote.name) |
| 183 | print >>sys.stderr, 'fatal: cannot obtain manifest %s' % r.url | 185 | print('fatal: cannot obtain manifest %s' % r.url, file=sys.stderr) |
| 184 | 186 | ||
| 185 | # Better delete the manifest git dir if we created it; otherwise next | 187 | # Better delete the manifest git dir if we created it; otherwise next |
| 186 | # time (when user fixes problems) we won't go through the "is_new" logic. | 188 | # time (when user fixes problems) we won't go through the "is_new" logic. |
| @@ -197,19 +199,19 @@ to update the working directory files. | |||
| 197 | 199 | ||
| 198 | if is_new or m.CurrentBranch is None: | 200 | if is_new or m.CurrentBranch is None: |
| 199 | if not m.StartBranch('default'): | 201 | if not m.StartBranch('default'): |
| 200 | print >>sys.stderr, 'fatal: cannot create default in manifest' | 202 | print('fatal: cannot create default in manifest', file=sys.stderr) |
| 201 | sys.exit(1) | 203 | sys.exit(1) |
| 202 | 204 | ||
| 203 | def _LinkManifest(self, name): | 205 | def _LinkManifest(self, name): |
| 204 | if not name: | 206 | if not name: |
| 205 | print >>sys.stderr, 'fatal: manifest name (-m) is required.' | 207 | print('fatal: manifest name (-m) is required.', file=sys.stderr) |
| 206 | sys.exit(1) | 208 | sys.exit(1) |
| 207 | 209 | ||
| 208 | try: | 210 | try: |
| 209 | self.manifest.Link(name) | 211 | self.manifest.Link(name) |
| 210 | except ManifestParseError as e: | 212 | except ManifestParseError as e: |
| 211 | print >>sys.stderr, "fatal: manifest '%s' not available" % name | 213 | print("fatal: manifest '%s' not available" % name, file=sys.stderr) |
| 212 | print >>sys.stderr, 'fatal: %s' % str(e) | 214 | print('fatal: %s' % str(e), file=sys.stderr) |
| 213 | sys.exit(1) | 215 | sys.exit(1) |
| 214 | 216 | ||
| 215 | def _Prompt(self, prompt, value): | 217 | def _Prompt(self, prompt, value): |
| @@ -231,22 +233,22 @@ to update the working directory files. | |||
| 231 | mp.config.SetString('user.name', gc.GetString('user.name')) | 233 | mp.config.SetString('user.name', gc.GetString('user.name')) |
| 232 | mp.config.SetString('user.email', gc.GetString('user.email')) | 234 | mp.config.SetString('user.email', gc.GetString('user.email')) |
| 233 | 235 | ||
| 234 | print '' | 236 | print() |
| 235 | print 'Your identity is: %s <%s>' % (mp.config.GetString('user.name'), | 237 | print('Your identity is: %s <%s>' % (mp.config.GetString('user.name'), |
| 236 | mp.config.GetString('user.email')) | 238 | mp.config.GetString('user.email'))) |
| 237 | print 'If you want to change this, please re-run \'repo init\' with --config-name' | 239 | print('If you want to change this, please re-run \'repo init\' with --config-name') |
| 238 | return False | 240 | return False |
| 239 | 241 | ||
| 240 | def _ConfigureUser(self): | 242 | def _ConfigureUser(self): |
| 241 | mp = self.manifest.manifestProject | 243 | mp = self.manifest.manifestProject |
| 242 | 244 | ||
| 243 | while True: | 245 | while True: |
| 244 | print '' | 246 | print() |
| 245 | name = self._Prompt('Your Name', mp.UserName) | 247 | name = self._Prompt('Your Name', mp.UserName) |
| 246 | email = self._Prompt('Your Email', mp.UserEmail) | 248 | email = self._Prompt('Your Email', mp.UserEmail) |
| 247 | 249 | ||
| 248 | print '' | 250 | print() |
| 249 | print 'Your identity is: %s <%s>' % (name, email) | 251 | print('Your identity is: %s <%s>' % (name, email)) |
| 250 | sys.stdout.write('is this correct [y/N]? ') | 252 | sys.stdout.write('is this correct [y/N]? ') |
| 251 | a = sys.stdin.readline().strip().lower() | 253 | a = sys.stdin.readline().strip().lower() |
| 252 | if a in ('yes', 'y', 't', 'true'): | 254 | if a in ('yes', 'y', 't', 'true'): |
| @@ -274,8 +276,8 @@ to update the working directory files. | |||
| 274 | self._on = True | 276 | self._on = True |
| 275 | out = _Test() | 277 | out = _Test() |
| 276 | 278 | ||
| 277 | print '' | 279 | print() |
| 278 | print "Testing colorized output (for 'repo diff', 'repo status'):" | 280 | print("Testing colorized output (for 'repo diff', 'repo status'):") |
| 279 | 281 | ||
| 280 | for c in ['black','red','green','yellow','blue','magenta','cyan']: | 282 | for c in ['black','red','green','yellow','blue','magenta','cyan']: |
| 281 | out.write(' ') | 283 | out.write(' ') |
| @@ -319,14 +321,16 @@ to update the working directory files. | |||
| 319 | else: | 321 | else: |
| 320 | init_type = '' | 322 | init_type = '' |
| 321 | 323 | ||
| 322 | print '' | 324 | print() |
| 323 | print 'repo %shas been initialized in %s' % (init_type, self.manifest.topdir) | 325 | print('repo %shas been initialized in %s' |
| 326 | % (init_type, self.manifest.topdir)) | ||
| 324 | 327 | ||
| 325 | current_dir = os.getcwd() | 328 | current_dir = os.getcwd() |
| 326 | if current_dir != self.manifest.topdir: | 329 | if current_dir != self.manifest.topdir: |
| 327 | print 'If this is not the directory in which you want to initialize repo, please run:' | 330 | print('If this is not the directory in which you want to initialize' |
| 328 | print ' rm -r %s/.repo' % self.manifest.topdir | 331 | 'repo, please run:') |
| 329 | print 'and try again.' | 332 | print(' rm -r %s/.repo' % self.manifest.topdir) |
| 333 | print('and try again.') | ||
| 330 | 334 | ||
| 331 | def Execute(self, opt, args): | 335 | def Execute(self, opt, args): |
| 332 | git_require(MIN_GIT_VERSION, fail=True) | 336 | git_require(MIN_GIT_VERSION, fail=True) |
