The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1 | # Copyright (C) 2008 The Android Open Source Project |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | import os |
Conley Owens | d21720d | 2012-04-16 11:02:21 -0700 | [diff] [blame] | 16 | import platform |
Conley Owens | 971de8e | 2012-04-16 10:36:08 -0700 | [diff] [blame] | 17 | import re |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 18 | import sys |
Mike Frysinger | acf63b2 | 2019-06-13 02:24:21 -0400 | [diff] [blame] | 19 | import urllib.parse |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 20 | |
| 21 | from color import Coloring |
Shawn O. Pearce | c95583b | 2009-03-03 17:47:06 -0800 | [diff] [blame] | 22 | from command import InteractiveCommand, MirrorSafeCommand |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 23 | from error import ManifestParseError |
Jonathan Nieder | 9371979 | 2015-03-17 11:29:58 -0700 | [diff] [blame] | 24 | from project import SyncBuffer |
Shawn O. Pearce | f322b9a | 2011-09-19 14:50:58 -0700 | [diff] [blame] | 25 | from git_config import GitConfig |
Mike Frysinger | 82caef6 | 2020-02-11 18:51:08 -0500 | [diff] [blame] | 26 | from git_command import git_require, MIN_GIT_VERSION_SOFT, MIN_GIT_VERSION_HARD |
Jack Neus | c474c9c | 2021-07-26 23:08:54 +0000 | [diff] [blame] | 27 | import fetch |
Renaud Paquay | a65adf7 | 2016-11-03 10:37:53 -0700 | [diff] [blame] | 28 | import platform_utils |
Mike Frysinger | 3599cc3 | 2020-02-29 02:53:41 -0500 | [diff] [blame] | 29 | from wrapper import Wrapper |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 30 | |
David Pursehouse | 819827a | 2020-02-12 15:20:19 +0900 | [diff] [blame] | 31 | |
Shawn O. Pearce | c95583b | 2009-03-03 17:47:06 -0800 | [diff] [blame] | 32 | class Init(InteractiveCommand, MirrorSafeCommand): |
Mike Frysinger | 4f21054 | 2021-06-14 16:05:19 -0400 | [diff] [blame] | 33 | COMMON = True |
LaMont Jones | 409407a | 2022-04-05 21:21:56 +0000 | [diff] [blame] | 34 | MULTI_MANIFEST_SUPPORT = True |
Mike Frysinger | 401c6f0 | 2021-02-18 15:20:15 -0500 | [diff] [blame] | 35 | helpSummary = "Initialize a repo client checkout in the current directory" |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 36 | helpUsage = """ |
Mike Frysinger | 401c6f0 | 2021-02-18 15:20:15 -0500 | [diff] [blame] | 37 | %prog [options] [manifest url] |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 38 | """ |
| 39 | helpDescription = """ |
| 40 | The '%prog' command is run once to install and initialize repo. |
| 41 | The latest repo source code and manifest collection is downloaded |
| 42 | from the server and is installed in the .repo/ directory in the |
| 43 | current working directory. |
| 44 | |
Mike Frysinger | 401c6f0 | 2021-02-18 15:20:15 -0500 | [diff] [blame] | 45 | When creating a new checkout, the manifest URL is the only required setting. |
| 46 | It may be specified using the --manifest-url option, or as the first optional |
| 47 | argument. |
| 48 | |
Shawn O. Pearce | 77bb4af | 2009-04-18 11:33:32 -0700 | [diff] [blame] | 49 | The optional -b argument can be used to select the manifest branch |
Mike Frysinger | 50a81de | 2020-09-06 15:51:21 -0400 | [diff] [blame] | 50 | to checkout and use. If no branch is specified, the remote's default |
Mike Frysinger | 23882b3 | 2021-02-23 15:43:07 -0500 | [diff] [blame] | 51 | branch is used. This is equivalent to using -b HEAD. |
Shawn O. Pearce | 77bb4af | 2009-04-18 11:33:32 -0700 | [diff] [blame] | 52 | |
| 53 | The optional -m argument can be used to specify an alternate manifest |
| 54 | to be used. If no manifest is specified, the manifest default.xml |
| 55 | will be used. |
| 56 | |
Jack Neus | c474c9c | 2021-07-26 23:08:54 +0000 | [diff] [blame] | 57 | If the --standalone-manifest argument is set, the manifest will be downloaded |
| 58 | directly from the specified --manifest-url as a static file (rather than |
| 59 | setting up a manifest git checkout). With --standalone-manifest, the manifest |
| 60 | will be fully static and will not be re-downloaded during subsesquent |
| 61 | `repo init` and `repo sync` calls. |
| 62 | |
Shawn O. Pearce | 8844338 | 2010-10-08 10:02:09 +0200 | [diff] [blame] | 63 | The --reference option can be used to point to a directory that |
| 64 | has the content of a --mirror sync. This will make the working |
| 65 | directory use as much data as possible from the local reference |
| 66 | directory when fetching from the server. This will make the sync |
| 67 | go a lot faster by reducing data traffic on the network. |
| 68 | |
Nikolai Merinov | 09f0abb | 2018-10-19 15:07:05 +0500 | [diff] [blame] | 69 | The --dissociate option can be used to borrow the objects from |
| 70 | the directory specified with the --reference option only to reduce |
| 71 | network transfer, and stop borrowing from them after a first clone |
| 72 | is made by making necessary local copies of borrowed objects. |
| 73 | |
Hu xiuyun | 9711a98 | 2015-12-11 11:16:41 +0800 | [diff] [blame] | 74 | The --no-clone-bundle option disables any attempt to use |
| 75 | $URL/clone.bundle to bootstrap a new Git repository from a |
| 76 | resumeable bundle file on a content delivery network. This |
| 77 | may be necessary if there are problems with the local Python |
| 78 | HTTP client or proxy configuration, but the Git binary works. |
Shawn O. Pearce | 8844338 | 2010-10-08 10:02:09 +0200 | [diff] [blame] | 79 | |
Mike Frysinger | b8f7bb0 | 2018-10-10 01:05:11 -0400 | [diff] [blame] | 80 | # Switching Manifest Branches |
Shawn O. Pearce | 77bb4af | 2009-04-18 11:33:32 -0700 | [diff] [blame] | 81 | |
| 82 | To switch to another manifest branch, `repo init -b otherbranch` |
| 83 | may be used in an existing client. However, as this only updates the |
| 84 | manifest, a subsequent `repo sync` (or `repo sync -d`) is necessary |
| 85 | to update the working directory files. |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 86 | """ |
| 87 | |
Mike Frysinger | 9180a07 | 2021-04-13 14:57:40 -0400 | [diff] [blame] | 88 | def _CommonOptions(self, p): |
| 89 | """Disable due to re-use of Wrapper().""" |
| 90 | |
Mike Frysinger | 66098f7 | 2020-02-05 00:01:59 -0500 | [diff] [blame] | 91 | def _Options(self, p, gitc_init=False): |
Mike Frysinger | 9a734a3 | 2021-04-08 19:14:15 -0400 | [diff] [blame] | 92 | Wrapper().InitParser(p, gitc_init=gitc_init) |
LaMont Jones | cc879a9 | 2021-11-18 22:40:18 +0000 | [diff] [blame] | 93 | m = p.add_option_group('Multi-manifest') |
| 94 | m.add_option('--outer-manifest', action='store_true', |
| 95 | help='operate starting at the outermost manifest') |
| 96 | m.add_option('--no-outer-manifest', dest='outer_manifest', |
| 97 | action='store_false', default=None, |
| 98 | help='do not operate on outer manifests') |
| 99 | m.add_option('--this-manifest-only', action='store_true', default=None, |
| 100 | help='only operate on this (sub)manifest') |
| 101 | m.add_option('--no-this-manifest-only', '--all-manifests', |
| 102 | dest='this_manifest_only', action='store_false', |
| 103 | help='operate on this manifest and its submanifests') |
Victor Boivie | 841be34 | 2011-04-05 11:31:10 +0200 | [diff] [blame] | 104 | |
David Pursehouse | 3f5ea0b | 2012-11-17 03:13:09 +0900 | [diff] [blame] | 105 | def _RegisteredEnvironmentOptions(self): |
| 106 | return {'REPO_MANIFEST_URL': 'manifest_url', |
| 107 | 'REPO_MIRROR_LOCATION': 'reference'} |
| 108 | |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 109 | def _SyncManifest(self, opt): |
LaMont Jones | 9b03f15 | 2022-03-29 23:01:18 +0000 | [diff] [blame] | 110 | """Call manifestProject.Sync with arguments from opt. |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 111 | |
LaMont Jones | 9b03f15 | 2022-03-29 23:01:18 +0000 | [diff] [blame] | 112 | Args: |
| 113 | opt: options from optparse. |
| 114 | """ |
| 115 | if not self.manifest.manifestProject.Sync( |
| 116 | manifest_url=opt.manifest_url, |
| 117 | manifest_branch=opt.manifest_branch, |
| 118 | standalone_manifest=opt.standalone_manifest, |
| 119 | groups=opt.groups, |
| 120 | platform=opt.platform, |
| 121 | mirror=opt.mirror, |
| 122 | dissociate=opt.dissociate, |
| 123 | reference=opt.reference, |
| 124 | worktree=opt.worktree, |
| 125 | submodules=opt.submodules, |
| 126 | archive=opt.archive, |
| 127 | partial_clone=opt.partial_clone, |
| 128 | clone_filter=opt.clone_filter, |
| 129 | partial_clone_exclude=opt.partial_clone_exclude, |
| 130 | clone_bundle=opt.clone_bundle, |
| 131 | git_lfs=opt.git_lfs, |
| 132 | use_superproject=opt.use_superproject, |
| 133 | verbose=opt.verbose, |
| 134 | current_branch_only=opt.current_branch_only, |
| 135 | tags=opt.tags, |
LaMont Jones | 409407a | 2022-04-05 21:21:56 +0000 | [diff] [blame] | 136 | depth=opt.depth, |
LaMont Jones | 55ee304 | 2022-04-06 17:10:21 +0000 | [diff] [blame] | 137 | git_event_log=self.git_event_log, |
LaMont Jones | 409407a | 2022-04-05 21:21:56 +0000 | [diff] [blame] | 138 | manifest_name=opt.manifest_name): |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 139 | sys.exit(1) |
| 140 | |
Shawn O. Pearce | 37dbf2b | 2009-07-02 10:53:04 -0700 | [diff] [blame] | 141 | def _Prompt(self, prompt, value): |
Mike Frysinger | ab85fe7 | 2019-07-04 17:35:11 -0400 | [diff] [blame] | 142 | print('%-10s [%s]: ' % (prompt, value), end='') |
| 143 | # TODO: When we require Python 3, use flush=True w/print above. |
| 144 | sys.stdout.flush() |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 145 | a = sys.stdin.readline().strip() |
Shawn O. Pearce | 37dbf2b | 2009-07-02 10:53:04 -0700 | [diff] [blame] | 146 | if a == '': |
| 147 | return value |
| 148 | return a |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 149 | |
Mike Frysinger | 0b88891 | 2020-02-21 22:48:40 -0500 | [diff] [blame] | 150 | def _ShouldConfigureUser(self, opt): |
Mike Frysinger | 8c1e9cb | 2020-09-06 14:53:18 -0400 | [diff] [blame] | 151 | gc = self.client.globalConfig |
Victor Boivie | 841be34 | 2011-04-05 11:31:10 +0200 | [diff] [blame] | 152 | mp = self.manifest.manifestProject |
| 153 | |
| 154 | # If we don't have local settings, get from global. |
| 155 | if not mp.config.Has('user.name') or not mp.config.Has('user.email'): |
| 156 | if not gc.Has('user.name') or not gc.Has('user.email'): |
| 157 | return True |
| 158 | |
| 159 | mp.config.SetString('user.name', gc.GetString('user.name')) |
| 160 | mp.config.SetString('user.email', gc.GetString('user.email')) |
| 161 | |
Mike Frysinger | 0b88891 | 2020-02-21 22:48:40 -0500 | [diff] [blame] | 162 | if not opt.quiet: |
| 163 | print() |
| 164 | print('Your identity is: %s <%s>' % (mp.config.GetString('user.name'), |
| 165 | mp.config.GetString('user.email'))) |
| 166 | print("If you want to change this, please re-run 'repo init' with --config-name") |
Victor Boivie | 841be34 | 2011-04-05 11:31:10 +0200 | [diff] [blame] | 167 | return False |
| 168 | |
Mike Frysinger | 0b88891 | 2020-02-21 22:48:40 -0500 | [diff] [blame] | 169 | def _ConfigureUser(self, opt): |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 170 | mp = self.manifest.manifestProject |
| 171 | |
Shawn O. Pearce | 37dbf2b | 2009-07-02 10:53:04 -0700 | [diff] [blame] | 172 | while True: |
Mike Frysinger | 0b88891 | 2020-02-21 22:48:40 -0500 | [diff] [blame] | 173 | if not opt.quiet: |
| 174 | print() |
David Pursehouse | 54a4e60 | 2020-02-12 14:31:05 +0900 | [diff] [blame] | 175 | name = self._Prompt('Your Name', mp.UserName) |
Shawn O. Pearce | 37dbf2b | 2009-07-02 10:53:04 -0700 | [diff] [blame] | 176 | email = self._Prompt('Your Email', mp.UserEmail) |
| 177 | |
Mike Frysinger | 0b88891 | 2020-02-21 22:48:40 -0500 | [diff] [blame] | 178 | if not opt.quiet: |
| 179 | print() |
Sarah Owens | cecd1d8 | 2012-11-01 22:59:27 -0700 | [diff] [blame] | 180 | print('Your identity is: %s <%s>' % (name, email)) |
Mike Frysinger | ab85fe7 | 2019-07-04 17:35:11 -0400 | [diff] [blame] | 181 | print('is this correct [y/N]? ', end='') |
| 182 | # TODO: When we require Python 3, use flush=True w/print above. |
| 183 | sys.stdout.flush() |
David Pursehouse | fc24124 | 2012-11-14 09:19:39 +0900 | [diff] [blame] | 184 | a = sys.stdin.readline().strip().lower() |
Nico Sallembien | 6d7508b | 2010-04-01 11:03:53 -0700 | [diff] [blame] | 185 | if a in ('yes', 'y', 't', 'true'): |
Shawn O. Pearce | 37dbf2b | 2009-07-02 10:53:04 -0700 | [diff] [blame] | 186 | break |
| 187 | |
| 188 | if name != mp.UserName: |
| 189 | mp.config.SetString('user.name', name) |
| 190 | if email != mp.UserEmail: |
| 191 | mp.config.SetString('user.email', email) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 192 | |
| 193 | def _HasColorSet(self, gc): |
| 194 | for n in ['ui', 'diff', 'status']: |
| 195 | if gc.Has('color.%s' % n): |
| 196 | return True |
| 197 | return False |
| 198 | |
| 199 | def _ConfigureColor(self): |
Mike Frysinger | 8c1e9cb | 2020-09-06 14:53:18 -0400 | [diff] [blame] | 200 | gc = self.client.globalConfig |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 201 | if self._HasColorSet(gc): |
| 202 | return |
| 203 | |
| 204 | class _Test(Coloring): |
| 205 | def __init__(self): |
| 206 | Coloring.__init__(self, gc, 'test color display') |
| 207 | self._on = True |
| 208 | out = _Test() |
| 209 | |
Sarah Owens | cecd1d8 | 2012-11-01 22:59:27 -0700 | [diff] [blame] | 210 | print() |
| 211 | print("Testing colorized output (for 'repo diff', 'repo status'):") |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 212 | |
David Pursehouse | 8f62fb7 | 2012-11-14 12:09:38 +0900 | [diff] [blame] | 213 | for c in ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan']: |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 214 | out.write(' ') |
| 215 | out.printer(fg=c)(' %-6s ', c) |
| 216 | out.write(' ') |
| 217 | out.printer(fg='white', bg='black')(' %s ' % 'white') |
| 218 | out.nl() |
| 219 | |
David Pursehouse | 8f62fb7 | 2012-11-14 12:09:38 +0900 | [diff] [blame] | 220 | for c in ['bold', 'dim', 'ul', 'reverse']: |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 221 | out.write(' ') |
| 222 | out.printer(fg='black', attr=c)(' %-6s ', c) |
| 223 | out.nl() |
| 224 | |
Mike Frysinger | ab85fe7 | 2019-07-04 17:35:11 -0400 | [diff] [blame] | 225 | print('Enable color display in this user account (y/N)? ', end='') |
| 226 | # TODO: When we require Python 3, use flush=True w/print above. |
| 227 | sys.stdout.flush() |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 228 | a = sys.stdin.readline().strip().lower() |
| 229 | if a in ('y', 'yes', 't', 'true', 'on'): |
| 230 | gc.SetString('color.ui', 'auto') |
| 231 | |
Mike Frysinger | 0b88891 | 2020-02-21 22:48:40 -0500 | [diff] [blame] | 232 | def _DisplayResult(self, opt): |
Yang Zhenhui | 75cc353 | 2012-10-23 15:41:54 +0800 | [diff] [blame] | 233 | if self.manifest.IsMirror: |
| 234 | init_type = 'mirror ' |
| 235 | else: |
| 236 | init_type = '' |
| 237 | |
Mike Frysinger | 0b88891 | 2020-02-21 22:48:40 -0500 | [diff] [blame] | 238 | if not opt.quiet: |
| 239 | print() |
| 240 | print('repo %shas been initialized in %s' % |
| 241 | (init_type, self.manifest.topdir)) |
Yang Zhenhui | 75cc353 | 2012-10-23 15:41:54 +0800 | [diff] [blame] | 242 | |
| 243 | current_dir = os.getcwd() |
| 244 | if current_dir != self.manifest.topdir: |
David Pursehouse | 3576596 | 2013-01-29 09:49:48 +0900 | [diff] [blame] | 245 | print('If this is not the directory in which you want to initialize ' |
Sarah Owens | cecd1d8 | 2012-11-01 22:59:27 -0700 | [diff] [blame] | 246 | 'repo, please run:') |
| 247 | print(' rm -r %s/.repo' % self.manifest.topdir) |
| 248 | print('and try again.') |
Yang Zhenhui | 75cc353 | 2012-10-23 15:41:54 +0800 | [diff] [blame] | 249 | |
Mike Frysinger | ae6cb08 | 2019-08-27 01:10:59 -0400 | [diff] [blame] | 250 | def ValidateOptions(self, opt, args): |
Victor Boivie | 297e7c6 | 2012-10-05 14:50:05 +0200 | [diff] [blame] | 251 | if opt.reference: |
Samuel Holland | baa0009 | 2018-01-22 10:57:29 -0600 | [diff] [blame] | 252 | opt.reference = os.path.expanduser(opt.reference) |
Victor Boivie | 297e7c6 | 2012-10-05 14:50:05 +0200 | [diff] [blame] | 253 | |
Julien Campergue | 335f5ef | 2013-10-16 11:02:35 +0200 | [diff] [blame] | 254 | # Check this here, else manifest will be tagged "not new" and init won't be |
| 255 | # possible anymore without removing the .repo/manifests directory. |
Raman Tenneti | 6bd89aa | 2021-11-16 11:48:09 -0800 | [diff] [blame] | 256 | if opt.mirror: |
| 257 | if opt.archive: |
| 258 | self.OptionParser.error('--mirror and --archive cannot be used ' |
| 259 | 'together.') |
| 260 | if opt.use_superproject is not None: |
| 261 | self.OptionParser.error('--mirror and --use-superproject cannot be ' |
| 262 | 'used together.') |
Mike Frysinger | ae6cb08 | 2019-08-27 01:10:59 -0400 | [diff] [blame] | 263 | |
Raman Tenneti | 4a478ed | 2021-11-17 18:38:24 -0800 | [diff] [blame] | 264 | if opt.standalone_manifest and (opt.manifest_branch or |
| 265 | opt.manifest_name != 'default.xml'): |
Jack Neus | c474c9c | 2021-07-26 23:08:54 +0000 | [diff] [blame] | 266 | self.OptionParser.error('--manifest-branch and --manifest-name cannot' |
| 267 | ' be used with --standalone-manifest.') |
| 268 | |
Mike Frysinger | 0578ebf | 2020-08-27 01:50:12 -0400 | [diff] [blame] | 269 | if args: |
Mike Frysinger | 401c6f0 | 2021-02-18 15:20:15 -0500 | [diff] [blame] | 270 | if opt.manifest_url: |
| 271 | self.OptionParser.error( |
| 272 | '--manifest-url option and URL argument both specified: only use ' |
| 273 | 'one to select the manifest URL.') |
| 274 | |
| 275 | opt.manifest_url = args.pop(0) |
| 276 | |
| 277 | if args: |
| 278 | self.OptionParser.error('too many arguments to init') |
Mike Frysinger | 0578ebf | 2020-08-27 01:50:12 -0400 | [diff] [blame] | 279 | |
Mike Frysinger | ae6cb08 | 2019-08-27 01:10:59 -0400 | [diff] [blame] | 280 | def Execute(self, opt, args): |
Mike Frysinger | 82caef6 | 2020-02-11 18:51:08 -0500 | [diff] [blame] | 281 | git_require(MIN_GIT_VERSION_HARD, fail=True) |
| 282 | if not git_require(MIN_GIT_VERSION_SOFT): |
| 283 | print('repo: warning: git-%s+ will soon be required; please upgrade your ' |
| 284 | 'version of git to maintain support.' |
| 285 | % ('.'.join(str(x) for x in MIN_GIT_VERSION_SOFT),), |
| 286 | file=sys.stderr) |
Julien Campergue | 335f5ef | 2013-10-16 11:02:35 +0200 | [diff] [blame] | 287 | |
Mike Frysinger | 7936ce8 | 2020-02-29 02:53:41 -0500 | [diff] [blame] | 288 | rp = self.manifest.repoProject |
| 289 | |
| 290 | # Handle new --repo-url requests. |
| 291 | if opt.repo_url: |
| 292 | remote = rp.GetRemote('origin') |
| 293 | remote.url = opt.repo_url |
| 294 | remote.Save() |
| 295 | |
Mike Frysinger | 3599cc3 | 2020-02-29 02:53:41 -0500 | [diff] [blame] | 296 | # Handle new --repo-rev requests. |
| 297 | if opt.repo_rev: |
| 298 | wrapper = Wrapper() |
Mike Frysinger | 4aa8584 | 2022-01-25 02:10:28 -0500 | [diff] [blame] | 299 | try: |
| 300 | remote_ref, rev = wrapper.check_repo_rev( |
| 301 | rp.gitdir, opt.repo_rev, repo_verify=opt.repo_verify, quiet=opt.quiet) |
| 302 | except wrapper.CloneFailure: |
| 303 | print('fatal: double check your --repo-rev setting.', file=sys.stderr) |
| 304 | sys.exit(1) |
Mike Frysinger | 3599cc3 | 2020-02-29 02:53:41 -0500 | [diff] [blame] | 305 | branch = rp.GetBranch('default') |
| 306 | branch.merge = remote_ref |
Mike Frysinger | 5e2f32f | 2020-12-05 22:57:19 -0500 | [diff] [blame] | 307 | rp.work_git.reset('--hard', rev) |
Mike Frysinger | 3599cc3 | 2020-02-29 02:53:41 -0500 | [diff] [blame] | 308 | branch.Save() |
| 309 | |
Mike Frysinger | 979d5bd | 2020-02-09 02:28:34 -0500 | [diff] [blame] | 310 | if opt.worktree: |
| 311 | # Older versions of git supported worktree, but had dangerous gc bugs. |
| 312 | git_require((2, 15, 0), fail=True, msg='git gc worktree corruption') |
| 313 | |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 314 | self._SyncManifest(opt) |
Raman Tenneti | 21dce3d | 2021-02-09 00:26:31 -0800 | [diff] [blame] | 315 | |
Shawn O. Pearce | 8630f39 | 2009-03-19 10:17:12 -0700 | [diff] [blame] | 316 | if os.isatty(0) and os.isatty(1) and not self.manifest.IsMirror: |
Mike Frysinger | 0b88891 | 2020-02-21 22:48:40 -0500 | [diff] [blame] | 317 | if opt.config_name or self._ShouldConfigureUser(opt): |
| 318 | self._ConfigureUser(opt) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 319 | self._ConfigureColor() |
| 320 | |
Mike Frysinger | 0b88891 | 2020-02-21 22:48:40 -0500 | [diff] [blame] | 321 | self._DisplayResult(opt) |