diff options
-rw-r--r-- | editor.py | 7 | ||||
-rw-r--r-- | git_command.py | 5 | ||||
-rw-r--r-- | git_config.py | 6 | ||||
-rwxr-xr-x | main.py | 50 | ||||
-rw-r--r-- | manifest_xml.py | 8 | ||||
-rwxr-xr-x | pager.py | 3 | ||||
-rw-r--r-- | project.py | 14 | ||||
-rwxr-xr-x | repo | 126 | ||||
-rw-r--r-- | subcmds/abandon.py | 15 | ||||
-rw-r--r-- | subcmds/branches.py | 3 | ||||
-rw-r--r-- | subcmds/checkout.py | 8 | ||||
-rw-r--r-- | subcmds/cherry_pick.py | 21 | ||||
-rw-r--r-- | subcmds/download.py | 21 | ||||
-rw-r--r-- | subcmds/forall.py | 3 | ||||
-rw-r--r-- | subcmds/grep.py | 8 | ||||
-rw-r--r-- | subcmds/help.py | 33 | ||||
-rw-r--r-- | subcmds/init.py | 52 | ||||
-rw-r--r-- | subcmds/list.py | 3 | ||||
-rw-r--r-- | subcmds/manifest.py | 7 | ||||
-rw-r--r-- | subcmds/overview.py | 7 | ||||
-rw-r--r-- | subcmds/prune.py | 5 | ||||
-rw-r--r-- | subcmds/rebase.py | 14 | ||||
-rw-r--r-- | subcmds/selfupdate.py | 3 | ||||
-rw-r--r-- | subcmds/stage.py | 5 | ||||
-rw-r--r-- | subcmds/start.py | 10 | ||||
-rw-r--r-- | subcmds/status.py | 2 | ||||
-rw-r--r-- | subcmds/sync.py | 102 | ||||
-rw-r--r-- | subcmds/upload.py | 41 | ||||
-rw-r--r-- | subcmds/version.py | 13 | ||||
-rw-r--r-- | trace.py | 3 |
30 files changed, 310 insertions, 288 deletions
@@ -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 re | 18 | import re |
18 | import sys | 19 | import sys |
@@ -53,10 +54,10 @@ class Editor(object): | |||
53 | return e | 54 | return e |
54 | 55 | ||
55 | if os.getenv('TERM') == 'dumb': | 56 | if os.getenv('TERM') == 'dumb': |
56 | print >>sys.stderr,\ | 57 | print( |
57 | """No editor specified in GIT_EDITOR, core.editor, VISUAL or EDITOR. | 58 | """No editor specified in GIT_EDITOR, core.editor, VISUAL or EDITOR. |
58 | Tried to fall back to vi but terminal is dumb. Please configure at | 59 | Tried to fall back to vi but terminal is dumb. Please configure at |
59 | least one of these before using this command.""" | 60 | least one of these before using this command.""", file=sys.stderr) |
60 | sys.exit(1) | 61 | sys.exit(1) |
61 | 62 | ||
62 | return 'vi' | 63 | return 'vi' |
@@ -67,7 +68,7 @@ least one of these before using this command.""" | |||
67 | 68 | ||
68 | Args: | 69 | Args: |
69 | data : the text to edit | 70 | data : the text to edit |
70 | 71 | ||
71 | Returns: | 72 | Returns: |
72 | new value of edited text; None if editing did not succeed | 73 | new value of edited text; None if editing did not succeed |
73 | """ | 74 | """ |
diff --git a/git_command.py b/git_command.py index e5e28f3c..d347dd61 100644 --- a/git_command.py +++ b/git_command.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 sys | 18 | import sys |
18 | import subprocess | 19 | import subprocess |
@@ -92,7 +93,7 @@ class _GitCall(object): | |||
92 | ver_str[len('git version '):].strip().split('-')[0].split('.')[0:3] | 93 | ver_str[len('git version '):].strip().split('-')[0].split('.')[0:3] |
93 | )) | 94 | )) |
94 | else: | 95 | else: |
95 | print >>sys.stderr, 'fatal: "%s" unsupported' % ver_str | 96 | print('fatal: "%s" unsupported' % ver_str, file=sys.stderr) |
96 | sys.exit(1) | 97 | sys.exit(1) |
97 | return _git_version | 98 | return _git_version |
98 | 99 | ||
@@ -111,7 +112,7 @@ def git_require(min_version, fail=False): | |||
111 | return True | 112 | return True |
112 | if fail: | 113 | if fail: |
113 | need = '.'.join(map(str, min_version)) | 114 | need = '.'.join(map(str, min_version)) |
114 | print >>sys.stderr, 'fatal: git %s or later required' % need | 115 | print('fatal: git %s or later required' % need, file=sys.stderr) |
115 | sys.exit(1) | 116 | sys.exit(1) |
116 | return False | 117 | return False |
117 | 118 | ||
diff --git a/git_config.py b/git_config.py index f60893ee..6bb92003 100644 --- a/git_config.py +++ b/git_config.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 cPickle | 17 | import cPickle |
17 | import os | 18 | import os |
18 | import re | 19 | import re |
@@ -463,9 +464,8 @@ def _open_ssh(host, port=None): | |||
463 | p = subprocess.Popen(command) | 464 | p = subprocess.Popen(command) |
464 | except Exception as e: | 465 | except Exception as e: |
465 | _ssh_master = False | 466 | _ssh_master = False |
466 | print >>sys.stderr, \ | 467 | print('\nwarn: cannot enable ssh control master for %s:%s\n%s' |
467 | '\nwarn: cannot enable ssh control master for %s:%s\n%s' \ | 468 | % (host,port, str(e)), file=sys.stderr) |
468 | % (host,port, str(e)) | ||
469 | return False | 469 | return False |
470 | 470 | ||
471 | _master_processes.append(p) | 471 | _master_processes.append(p) |
@@ -14,6 +14,7 @@ | |||
14 | # See the License for the specific language governing permissions and | 14 | # See the License for the specific language governing permissions and |
15 | # limitations under the License. | 15 | # limitations under the License. |
16 | 16 | ||
17 | from __future__ import print_function | ||
17 | import getpass | 18 | import getpass |
18 | import imp | 19 | import imp |
19 | import netrc | 20 | import netrc |
@@ -98,15 +99,14 @@ class _Repo(object): | |||
98 | if name == 'help': | 99 | if name == 'help': |
99 | name = 'version' | 100 | name = 'version' |
100 | else: | 101 | else: |
101 | print >>sys.stderr, 'fatal: invalid usage of --version' | 102 | print('fatal: invalid usage of --version', file=sys.stderr) |
102 | return 1 | 103 | return 1 |
103 | 104 | ||
104 | try: | 105 | try: |
105 | cmd = self.commands[name] | 106 | cmd = self.commands[name] |
106 | except KeyError: | 107 | except KeyError: |
107 | print >>sys.stderr,\ | 108 | print("repo: '%s' is not a repo command. See 'repo help'." % name, |
108 | "repo: '%s' is not a repo command. See 'repo help'."\ | 109 | file=sys.stderr) |
109 | % name | ||
110 | return 1 | 110 | return 1 |
111 | 111 | ||
112 | cmd.repodir = self.repodir | 112 | cmd.repodir = self.repodir |
@@ -114,9 +114,8 @@ class _Repo(object): | |||
114 | Editor.globalConfig = cmd.manifest.globalConfig | 114 | Editor.globalConfig = cmd.manifest.globalConfig |
115 | 115 | ||
116 | if not isinstance(cmd, MirrorSafeCommand) and cmd.manifest.IsMirror: | 116 | if not isinstance(cmd, MirrorSafeCommand) and cmd.manifest.IsMirror: |
117 | print >>sys.stderr, \ | 117 | print("fatal: '%s' requires a working directory" % name, |
118 | "fatal: '%s' requires a working directory"\ | 118 | file=sys.stderr) |
119 | % name | ||
120 | return 1 | 119 | return 1 |
121 | 120 | ||
122 | copts, cargs = cmd.OptionParser.parse_args(argv) | 121 | copts, cargs = cmd.OptionParser.parse_args(argv) |
@@ -142,22 +141,21 @@ class _Repo(object): | |||
142 | minutes, seconds = divmod(remainder, 60) | 141 | minutes, seconds = divmod(remainder, 60) |
143 | if gopts.time: | 142 | if gopts.time: |
144 | if hours == 0: | 143 | if hours == 0: |
145 | print >>sys.stderr, 'real\t%dm%.3fs' \ | 144 | print('real\t%dm%.3fs' % (minutes, seconds), file=sys.stderr) |
146 | % (minutes, seconds) | ||
147 | else: | 145 | else: |
148 | print >>sys.stderr, 'real\t%dh%dm%.3fs' \ | 146 | print('real\t%dh%dm%.3fs' % (hours, minutes, seconds), |
149 | % (hours, minutes, seconds) | 147 | file=sys.stderr) |
150 | except DownloadError as e: | 148 | except DownloadError as e: |
151 | print >>sys.stderr, 'error: %s' % str(e) | 149 | print('error: %s' % str(e), file=sys.stderr) |
152 | return 1 | 150 | return 1 |
153 | except ManifestInvalidRevisionError as e: | 151 | except ManifestInvalidRevisionError as e: |
154 | print >>sys.stderr, 'error: %s' % str(e) | 152 | print('error: %s' % str(e), file=sys.stderr) |
155 | return 1 | 153 | return 1 |
156 | except NoSuchProjectError as e: | 154 | except NoSuchProjectError as e: |
157 | if e.name: | 155 | if e.name: |
158 | print >>sys.stderr, 'error: project %s not found' % e.name | 156 | print('error: project %s not found' % e.name, file=sys.stderr) |
159 | else: | 157 | else: |
160 | print >>sys.stderr, 'error: no project in current directory' | 158 | print('error: no project in current directory', file=sys.stderr) |
161 | return 1 | 159 | return 1 |
162 | 160 | ||
163 | return result | 161 | return result |
@@ -183,7 +181,7 @@ def _CheckWrapperVersion(ver, repo_path): | |||
183 | repo_path = '~/bin/repo' | 181 | repo_path = '~/bin/repo' |
184 | 182 | ||
185 | if not ver: | 183 | if not ver: |
186 | print >>sys.stderr, 'no --wrapper-version argument' | 184 | print('no --wrapper-version argument', file=sys.stderr) |
187 | sys.exit(1) | 185 | sys.exit(1) |
188 | 186 | ||
189 | exp = _CurrentWrapperVersion() | 187 | exp = _CurrentWrapperVersion() |
@@ -193,25 +191,25 @@ def _CheckWrapperVersion(ver, repo_path): | |||
193 | 191 | ||
194 | exp_str = '.'.join(map(str, exp)) | 192 | exp_str = '.'.join(map(str, exp)) |
195 | if exp[0] > ver[0] or ver < (0, 4): | 193 | if exp[0] > ver[0] or ver < (0, 4): |
196 | print >>sys.stderr, """ | 194 | print(""" |
197 | !!! A new repo command (%5s) is available. !!! | 195 | !!! A new repo command (%5s) is available. !!! |
198 | !!! You must upgrade before you can continue: !!! | 196 | !!! You must upgrade before you can continue: !!! |
199 | 197 | ||
200 | cp %s %s | 198 | cp %s %s |
201 | """ % (exp_str, _MyWrapperPath(), repo_path) | 199 | """ % (exp_str, _MyWrapperPath(), repo_path), file=sys.stderr) |
202 | sys.exit(1) | 200 | sys.exit(1) |
203 | 201 | ||
204 | if exp > ver: | 202 | if exp > ver: |
205 | print >>sys.stderr, """ | 203 | print(""" |
206 | ... A new repo command (%5s) is available. | 204 | ... A new repo command (%5s) is available. |
207 | ... You should upgrade soon: | 205 | ... You should upgrade soon: |
208 | 206 | ||
209 | cp %s %s | 207 | cp %s %s |
210 | """ % (exp_str, _MyWrapperPath(), repo_path) | 208 | """ % (exp_str, _MyWrapperPath(), repo_path), file=sys.stderr) |
211 | 209 | ||
212 | def _CheckRepoDir(repo_dir): | 210 | def _CheckRepoDir(repo_dir): |
213 | if not repo_dir: | 211 | if not repo_dir: |
214 | print >>sys.stderr, 'no --repo-dir argument' | 212 | print('no --repo-dir argument', file=sys.stderr) |
215 | sys.exit(1) | 213 | sys.exit(1) |
216 | 214 | ||
217 | def _PruneOptions(argv, opt): | 215 | def _PruneOptions(argv, opt): |
@@ -281,7 +279,7 @@ def _AddPasswordFromUserInput(handler, msg, req): | |||
281 | url = req.get_full_url() | 279 | url = req.get_full_url() |
282 | user, password = handler.passwd.find_user_password(None, url) | 280 | user, password = handler.passwd.find_user_password(None, url) |
283 | if user is None: | 281 | if user is None: |
284 | print msg | 282 | print(msg) |
285 | try: | 283 | try: |
286 | user = raw_input('User: ') | 284 | user = raw_input('User: ') |
287 | password = getpass.getpass() | 285 | password = getpass.getpass() |
@@ -388,10 +386,10 @@ def _Main(argv): | |||
388 | finally: | 386 | finally: |
389 | close_ssh() | 387 | close_ssh() |
390 | except KeyboardInterrupt: | 388 | except KeyboardInterrupt: |
391 | print >>sys.stderr, 'aborted by user' | 389 | print('aborted by user', file=sys.stderr) |
392 | result = 1 | 390 | result = 1 |
393 | except ManifestParseError as mpe: | 391 | except ManifestParseError as mpe: |
394 | print >>sys.stderr, 'fatal: %s' % mpe | 392 | print('fatal: %s' % mpe, file=sys.stderr) |
395 | result = 1 | 393 | result = 1 |
396 | except RepoChangedException as rce: | 394 | except RepoChangedException as rce: |
397 | # If repo changed, re-exec ourselves. | 395 | # If repo changed, re-exec ourselves. |
@@ -401,8 +399,8 @@ def _Main(argv): | |||
401 | try: | 399 | try: |
402 | os.execv(__file__, argv) | 400 | os.execv(__file__, argv) |
403 | except OSError as e: | 401 | except OSError as e: |
404 | print >>sys.stderr, 'fatal: cannot restart repo after upgrade' | 402 | print('fatal: cannot restart repo after upgrade', file=sys.stderr) |
405 | print >>sys.stderr, 'fatal: %s' % e | 403 | print('fatal: %s' % e, file=sys.stderr) |
406 | result = 128 | 404 | result = 128 |
407 | 405 | ||
408 | sys.exit(result) | 406 | sys.exit(result) |
diff --git a/manifest_xml.py b/manifest_xml.py index 31987248..bb93bca3 100644 --- a/manifest_xml.py +++ b/manifest_xml.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 itertools | 17 | import itertools |
17 | import os | 18 | import os |
18 | import re | 19 | import re |
@@ -306,8 +307,9 @@ class XmlManifest(object): | |||
306 | 307 | ||
307 | local = os.path.join(self.repodir, LOCAL_MANIFEST_NAME) | 308 | local = os.path.join(self.repodir, LOCAL_MANIFEST_NAME) |
308 | if os.path.exists(local): | 309 | if os.path.exists(local): |
309 | print >>sys.stderr, 'warning: %s is deprecated; put local manifests in %s instead' % \ | 310 | print('warning: %s is deprecated; put local manifests in %s instead' |
310 | (LOCAL_MANIFEST_NAME, LOCAL_MANIFESTS_DIR_NAME) | 311 | % (LOCAL_MANIFEST_NAME, LOCAL_MANIFESTS_DIR_NAME), |
312 | file=sys.stderr) | ||
311 | nodes.append(self._ParseManifestXml(local, self.repodir)) | 313 | nodes.append(self._ParseManifestXml(local, self.repodir)) |
312 | 314 | ||
313 | local_dir = os.path.abspath(os.path.join(self.repodir, LOCAL_MANIFESTS_DIR_NAME)) | 315 | local_dir = os.path.abspath(os.path.join(self.repodir, LOCAL_MANIFESTS_DIR_NAME)) |
@@ -317,7 +319,7 @@ class XmlManifest(object): | |||
317 | try: | 319 | try: |
318 | nodes.append(self._ParseManifestXml(local_file, self.repodir)) | 320 | nodes.append(self._ParseManifestXml(local_file, self.repodir)) |
319 | except ManifestParseError as e: | 321 | except ManifestParseError as e: |
320 | print >>sys.stderr, '%s' % str(e) | 322 | print('%s' % str(e), file=sys.stderr) |
321 | except OSError: | 323 | except OSError: |
322 | pass | 324 | pass |
323 | 325 | ||
@@ -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 select | 18 | import select |
18 | import sys | 19 | import sys |
@@ -49,7 +50,7 @@ def RunPager(globalConfig): | |||
49 | 50 | ||
50 | _BecomePager(pager) | 51 | _BecomePager(pager) |
51 | except Exception: | 52 | except Exception: |
52 | print >>sys.stderr, "fatal: cannot start pager '%s'" % pager | 53 | print("fatal: cannot start pager '%s'" % pager, file=sys.stderr) |
53 | sys.exit(255) | 54 | sys.exit(255) |
54 | 55 | ||
55 | def _SelectPager(globalConfig): | 56 | def _SelectPager(globalConfig): |
@@ -12,6 +12,7 @@ | |||
12 | # See the License for the specific language governing permissions and | 12 | # See the License for the specific language governing permissions and |
13 | # limitations under the License. | 13 | # limitations under the License. |
14 | 14 | ||
15 | from __future__ import print_function | ||
15 | import traceback | 16 | import traceback |
16 | import errno | 17 | import errno |
17 | import filecmp | 18 | import filecmp |
@@ -50,7 +51,7 @@ def _lwrite(path, content): | |||
50 | 51 | ||
51 | def _error(fmt, *args): | 52 | def _error(fmt, *args): |
52 | msg = fmt % args | 53 | msg = fmt % args |
53 | print >>sys.stderr, 'error: %s' % msg | 54 | print('error: %s' % msg, file=sys.stderr) |
54 | 55 | ||
55 | def not_rev(r): | 56 | def not_rev(r): |
56 | return '^' + r | 57 | return '^' + r |
@@ -683,9 +684,9 @@ class Project(object): | |||
683 | if not os.path.isdir(self.worktree): | 684 | if not os.path.isdir(self.worktree): |
684 | if output_redir == None: | 685 | if output_redir == None: |
685 | output_redir = sys.stdout | 686 | output_redir = sys.stdout |
686 | print >>output_redir, '' | 687 | print(file=output_redir) |
687 | print >>output_redir, 'project %s/' % self.relpath | 688 | print('project %s/' % self.relpath, file=output_redir) |
688 | print >>output_redir, ' missing (run "repo sync")' | 689 | print(' missing (run "repo sync")', file=output_redir) |
689 | return | 690 | return |
690 | 691 | ||
691 | self.work_git.update_index('-q', | 692 | self.work_git.update_index('-q', |
@@ -785,7 +786,7 @@ class Project(object): | |||
785 | out.project('project %s/' % self.relpath) | 786 | out.project('project %s/' % self.relpath) |
786 | out.nl() | 787 | out.nl() |
787 | has_diff = True | 788 | has_diff = True |
788 | print line[:-1] | 789 | print(line[:-1]) |
789 | p.Wait() | 790 | p.Wait() |
790 | 791 | ||
791 | 792 | ||
@@ -1586,7 +1587,8 @@ class Project(object): | |||
1586 | # returned another error with the HTTP error code being 400 or above. | 1587 | # returned another error with the HTTP error code being 400 or above. |
1587 | # This return code only appears if -f, --fail is used. | 1588 | # This return code only appears if -f, --fail is used. |
1588 | if not quiet: | 1589 | if not quiet: |
1589 | print >> sys.stderr, "Server does not provide clone.bundle; ignoring." | 1590 | print("Server does not provide clone.bundle; ignoring.", |
1591 | file=sys.stderr) | ||
1590 | return False | 1592 | return False |
1591 | 1593 | ||
1592 | if os.path.exists(tmpPath): | 1594 | if os.path.exists(tmpPath): |
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | ## repo default configuration | 3 | ## repo default configuration |
4 | ## | 4 | ## |
5 | from __future__ import print_function | ||
5 | REPO_URL='https://gerrit.googlesource.com/git-repo' | 6 | REPO_URL='https://gerrit.googlesource.com/git-repo' |
6 | REPO_REV='stable' | 7 | REPO_REV='stable' |
7 | 8 | ||
@@ -215,16 +216,15 @@ def _Init(args): | |||
215 | if branch.startswith('refs/heads/'): | 216 | if branch.startswith('refs/heads/'): |
216 | branch = branch[len('refs/heads/'):] | 217 | branch = branch[len('refs/heads/'):] |
217 | if branch.startswith('refs/'): | 218 | if branch.startswith('refs/'): |
218 | print >>sys.stderr, "fatal: invalid branch name '%s'" % branch | 219 | print("fatal: invalid branch name '%s'" % branch, file=sys.stderr) |
219 | raise CloneFailure() | 220 | raise CloneFailure() |
220 | 221 | ||
221 | if not os.path.isdir(repodir): | 222 | if not os.path.isdir(repodir): |
222 | try: | 223 | try: |
223 | os.mkdir(repodir) | 224 | os.mkdir(repodir) |
224 | except OSError as e: | 225 | except OSError as e: |
225 | print >>sys.stderr, \ | 226 | print('fatal: cannot make %s directory: %s' |
226 | 'fatal: cannot make %s directory: %s' % ( | 227 | % (repodir, e.strerror), file=sys.stderr) |
227 | repodir, e.strerror) | ||
228 | # Don't faise CloneFailure; that would delete the | 228 | # Don't faise CloneFailure; that would delete the |
229 | # name. Instead exit immediately. | 229 | # name. Instead exit immediately. |
230 | # | 230 | # |
@@ -248,8 +248,8 @@ def _Init(args): | |||
248 | _Checkout(dst, branch, rev, opt.quiet) | 248 | _Checkout(dst, branch, rev, opt.quiet) |
249 | except CloneFailure: | 249 | except CloneFailure: |
250 | if opt.quiet: | 250 | if opt.quiet: |
251 | print >>sys.stderr, \ | 251 | print('fatal: repo init failed; run without --quiet to see why', |
252 | 'fatal: repo init failed; run without --quiet to see why' | 252 | file=sys.stderr) |
253 | raise | 253 | raise |
254 | 254 | ||
255 | 255 | ||
@@ -258,12 +258,12 @@ def _CheckGitVersion(): | |||
258 | try: | 258 | try: |
259 | proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) | 259 | proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) |
260 | except OSError as e: | 260 | except OSError as e: |
261 | print >>sys.stderr | 261 | print(file=sys.stderr) |
262 | print >>sys.stderr, "fatal: '%s' is not available" % GIT | 262 | print("fatal: '%s' is not available" % GIT, file=sys.stderr) |
263 | print >>sys.stderr, 'fatal: %s' % e | 263 | print('fatal: %s' % e, file=sys.stderr) |
264 | print >>sys.stderr | 264 | print(file=sys.stderr) |
265 | print >>sys.stderr, 'Please make sure %s is installed'\ | 265 | print('Please make sure %s is installed and in your path.' % GIT, |
266 | ' and in your path.' % GIT | 266 | file=sys.stderr) |
267 | raise CloneFailure() | 267 | raise CloneFailure() |
268 | 268 | ||
269 | ver_str = proc.stdout.read().strip() | 269 | ver_str = proc.stdout.read().strip() |
@@ -271,14 +271,14 @@ def _CheckGitVersion(): | |||
271 | proc.wait() | 271 | proc.wait() |
272 | 272 | ||
273 | if not ver_str.startswith('git version '): | 273 | if not ver_str.startswith('git version '): |
274 | print >>sys.stderr, 'error: "%s" unsupported' % ver_str | 274 | print('error: "%s" unsupported' % ver_str, file=sys.stderr) |
275 | raise CloneFailure() | 275 | raise CloneFailure() |
276 | 276 | ||
277 | ver_str = ver_str[len('git version '):].strip() | 277 | ver_str = ver_str[len('git version '):].strip() |
278 | ver_act = tuple(map(int, ver_str.split('.')[0:3])) | 278 | ver_act = tuple(map(int, ver_str.split('.')[0:3])) |
279 | if ver_act < MIN_GIT_VERSION: | 279 | if ver_act < MIN_GIT_VERSION: |
280 | need = '.'.join(map(str, MIN_GIT_VERSION)) | 280 | need = '.'.join(map(str, MIN_GIT_VERSION)) |
281 | print >>sys.stderr, 'fatal: git %s or later required' % need | 281 | print('fatal: git %s or later required' % need, file=sys.stderr) |
282 | raise CloneFailure() | 282 | raise CloneFailure() |
283 | 283 | ||
284 | 284 | ||
@@ -305,18 +305,16 @@ def SetupGnuPG(quiet): | |||
305 | try: | 305 | try: |
306 | os.mkdir(home_dot_repo) | 306 | os.mkdir(home_dot_repo) |
307 | except OSError as e: | 307 | except OSError as e: |
308 | print >>sys.stderr, \ | 308 | print('fatal: cannot make %s directory: %s' |
309 | 'fatal: cannot make %s directory: %s' % ( | 309 | % (home_dot_repo, e.strerror), file=sys.stderr) |
310 | home_dot_repo, e.strerror) | ||
311 | sys.exit(1) | 310 | sys.exit(1) |
312 | 311 | ||
313 | if not os.path.isdir(gpg_dir): | 312 | if not os.path.isdir(gpg_dir): |
314 | try: | 313 | try: |
315 | os.mkdir(gpg_dir, stat.S_IRWXU) | 314 | os.mkdir(gpg_dir, stat.S_IRWXU) |
316 | except OSError as e: | 315 | except OSError as e: |
317 | print >>sys.stderr, \ | 316 | print('fatal: cannot make %s directory: %s' % (gpg_dir, e.strerror), |
318 | 'fatal: cannot make %s directory: %s' % ( | 317 | file=sys.stderr) |
319 | gpg_dir, e.strerror) | ||
320 | sys.exit(1) | 318 | sys.exit(1) |
321 | 319 | ||
322 | env = os.environ.copy() | 320 | env = os.environ.copy() |
@@ -329,16 +327,16 @@ def SetupGnuPG(quiet): | |||
329 | stdin = subprocess.PIPE) | 327 | stdin = subprocess.PIPE) |
330 | except OSError as e: | 328 | except OSError as e: |
331 | if not quiet: | 329 | if not quiet: |
332 | print >>sys.stderr, 'warning: gpg (GnuPG) is not available.' | 330 | print('warning: gpg (GnuPG) is not available.', file=sys.stderr) |
333 | print >>sys.stderr, 'warning: Installing it is strongly encouraged.' | 331 | print('warning: Installing it is strongly encouraged.', file=sys.stderr) |
334 | print >>sys.stderr | 332 | print(file=sys.stderr) |
335 | return False | 333 | return False |
336 | 334 | ||
337 | proc.stdin.write(MAINTAINER_KEYS) | 335 | proc.stdin.write(MAINTAINER_KEYS) |
338 | proc.stdin.close() | 336 | proc.stdin.close() |
339 | 337 | ||
340 | if proc.wait() != 0: | 338 | if proc.wait() != 0: |
341 | print >>sys.stderr, 'fatal: registering repo maintainer keys failed' | 339 | print('fatal: registering repo maintainer keys failed', file=sys.stderr) |
342 | sys.exit(1) | 340 | sys.exit(1) |
343 | 341 | ||
344 | 342 | ||
@@ -382,7 +380,7 @@ def _InitHttp(): | |||
382 | 380 | ||
383 | def _Fetch(url, local, src, quiet): | 381 | def _Fetch(url, local, src, quiet): |
384 | if not quiet: | 382 | if not quiet: |
385 | print >>sys.stderr, 'Get %s' % url | 383 | print('Get %s' % url, file=sys.stderr) |
386 | 384 | ||
387 | cmd = [GIT, 'fetch'] | 385 | cmd = [GIT, 'fetch'] |
388 | if quiet: | 386 | if quiet: |
@@ -431,16 +429,16 @@ def _DownloadBundle(url, local, quiet): | |||
431 | except urllib.error.HTTPError as e: | 429 | except urllib.error.HTTPError as e: |
432 | if e.code == 404: | 430 | if e.code == 404: |
433 | return False | 431 | return False |
434 | print >>sys.stderr, 'fatal: Cannot get %s' % url | 432 | print('fatal: Cannot get %s' % url, file=sys.stderr) |
435 | print >>sys.stderr, 'fatal: HTTP error %s' % e.code | 433 | print('fatal: HTTP error %s' % e.code, file=sys.stderr) |
436 | raise CloneFailure() | 434 | raise CloneFailure() |
437 | except urllib.error.URLError as e: | 435 | except urllib.error.URLError as e: |
438 | print >>sys.stderr, 'fatal: Cannot get %s' % url | 436 | print('fatal: Cannot get %s' % url, file=sys.stderr) |
439 | print >>sys.stderr, 'fatal: error %s' % e.reason | 437 | print('fatal: error %s' % e.reason, file=sys.stderr) |
440 | raise CloneFailure() | 438 | raise CloneFailure() |
441 | try: | 439 | try: |
442 | if not quiet: | 440 | if not quiet: |
443 | print >>sys.stderr, 'Get %s' % url | 441 | print('Get %s' % url, file=sys.stderr) |
444 | while True: | 442 | while True: |
445 | buf = r.read(8192) | 443 | buf = r.read(8192) |
446 | if buf == '': | 444 | if buf == '': |
@@ -464,24 +462,23 @@ def _Clone(url, local, quiet): | |||
464 | try: | 462 | try: |
465 | os.mkdir(local) | 463 | os.mkdir(local) |
466 | except OSError as e: | 464 | except OSError as e: |
467 | print >>sys.stderr, \ | 465 | print('fatal: cannot make %s directory: %s' % (local, e.strerror), |
468 | 'fatal: cannot make %s directory: %s' \ | 466 | file=sys.stderr) |
469 | % (local, e.strerror) | ||
470 | raise CloneFailure() | 467 | raise CloneFailure() |
471 | 468 | ||
472 | cmd = [GIT, 'init', '--quiet'] | 469 | cmd = [GIT, 'init', '--quiet'] |
473 | try: | 470 | try: |
474 | proc = subprocess.Popen(cmd, cwd = local) | 471 | proc = subprocess.Popen(cmd, cwd = local) |
475 | except OSError as e: | 472 | except OSError as e: |
476 | print >>sys.stderr | 473 | print(file=sys.stderr) |
477 | print >>sys.stderr, "fatal: '%s' is not available" % GIT | 474 | print("fatal: '%s' is not available" % GIT, file=sys.stderr) |
478 | print >>sys.stderr, 'fatal: %s' % e | 475 | print('fatal: %s' % e, file=sys.stderr) |
479 | print >>sys.stderr | 476 | print(file=sys.stderr) |
480 | print >>sys.stderr, 'Please make sure %s is installed'\ | 477 | print('Please make sure %s is installed and in your path.' % GIT, |
481 | ' and in your path.' % GIT | 478 | file=sys.stderr) |
482 | raise CloneFailure() | 479 | raise CloneFailure() |
483 | if proc.wait() != 0: | 480 | if proc.wait() != 0: |
484 | print >>sys.stderr, 'fatal: could not create %s' % local | 481 | print('fatal: could not create %s' % local, file=sys.stderr) |
485 | raise CloneFailure() | 482 | raise CloneFailure() |
486 | 483 | ||
487 | _InitHttp() | 484 | _InitHttp() |
@@ -509,21 +506,18 @@ def _Verify(cwd, branch, quiet): | |||
509 | proc.stderr.close() | 506 | proc.stderr.close() |
510 | 507 | ||
511 | if proc.wait() != 0 or not cur: | 508 | if proc.wait() != 0 or not cur: |
512 | print >>sys.stderr | 509 | print(file=sys.stderr) |
513 | print >>sys.stderr,\ | 510 | print("fatal: branch '%s' has not been signed" % branch, file=sys.stderr) |
514 | "fatal: branch '%s' has not been signed" \ | ||
515 | % branch | ||
516 | raise CloneFailure() | 511 | raise CloneFailure() |
517 | 512 | ||
518 | m = re.compile(r'^(.*)-[0-9]{1,}-g[0-9a-f]{1,}$').match(cur) | 513 | m = re.compile(r'^(.*)-[0-9]{1,}-g[0-9a-f]{1,}$').match(cur) |
519 | if m: | 514 | if m: |
520 | cur = m.group(1) | 515 | cur = m.group(1) |
521 | if not quiet: | 516 | if not quiet: |
522 | print >>sys.stderr | 517 | print(file=sys.stderr) |
523 | print >>sys.stderr, \ | 518 | print("info: Ignoring branch '%s'; using tagged release '%s'" |
524 | "info: Ignoring branch '%s'; using tagged release '%s'" \ | 519 | % (branch, cur), file=sys.stderr) |
525 | % (branch, cur) | 520 | print(file=sys.stderr) |
526 | print >>sys.stderr | ||
527 | 521 | ||
528 | env = os.environ.copy() | 522 | env = os.environ.copy() |
529 | env['GNUPGHOME'] = gpg_dir.encode() | 523 | env['GNUPGHOME'] = gpg_dir.encode() |
@@ -541,10 +535,10 @@ def _Verify(cwd, branch, quiet): | |||
541 | proc.stderr.close() | 535 | proc.stderr.close() |
542 | 536 | ||
543 | if proc.wait() != 0: | 537 | if proc.wait() != 0: |
544 | print >>sys.stderr | 538 | print(file=sys.stderr) |
545 | print >>sys.stderr, out | 539 | print(out, file=sys.stderr) |
546 | print >>sys.stderr, err | 540 | print(err, file=sys.stderr) |
547 | print >>sys.stderr | 541 | print(file=sys.stderr) |
548 | raise CloneFailure() | 542 | raise CloneFailure() |
549 | return '%s^0' % cur | 543 | return '%s^0' % cur |
550 | 544 | ||
@@ -611,7 +605,7 @@ def _ParseArguments(args): | |||
611 | 605 | ||
612 | 606 | ||
613 | def _Usage(): | 607 | def _Usage(): |
614 | print >>sys.stderr,\ | 608 | print( |
615 | """usage: repo COMMAND [ARGS] | 609 | """usage: repo COMMAND [ARGS] |
616 | 610 | ||
617 | repo is not yet installed. Use "repo init" to install it here. | 611 | repo is not yet installed. Use "repo init" to install it here. |
@@ -622,7 +616,7 @@ The most commonly used repo commands are: | |||
622 | help Display detailed help on a command | 616 | help Display detailed help on a command |
623 | 617 | ||
624 | For access to the full online help, install repo ("repo init"). | 618 | For access to the full online help, install repo ("repo init"). |
625 | """ | 619 | """, file=sys.stderr) |
626 | sys.exit(1) | 620 | sys.exit(1) |
627 | 621 | ||
628 | 622 | ||
@@ -632,25 +626,23 @@ def _Help(args): | |||
632 | init_optparse.print_help() | 626 | init_optparse.print_help() |
633 | sys.exit(0) | 627 | sys.exit(0) |
634 | else: | 628 | else: |
635 | print >>sys.stderr,\ | 629 | print("error: '%s' is not a bootstrap command.\n" |
636 | "error: '%s' is not a bootstrap command.\n"\ | 630 | ' For access to online help, install repo ("repo init").' |
637 | ' For access to online help, install repo ("repo init").'\ | 631 | % args[0], file=sys.stderr) |
638 | % args[0] | ||
639 | else: | 632 | else: |
640 | _Usage() | 633 | _Usage() |
641 | sys.exit(1) | 634 | sys.exit(1) |
642 | 635 | ||
643 | 636 | ||
644 | def _NotInstalled(): | 637 | def _NotInstalled(): |
645 | print >>sys.stderr,\ | 638 | print('error: repo is not installed. Use "repo init" to install it here.', |
646 | 'error: repo is not installed. Use "repo init" to install it here.' | 639 | file=sys.stderr) |
647 | sys.exit(1) | 640 | sys.exit(1) |
648 | 641 | ||
649 | 642 | ||
650 | def _NoCommands(cmd): | 643 | def _NoCommands(cmd): |
651 | print >>sys.stderr,\ | 644 | print("""error: command '%s' requires repo to be installed first. |
652 | """error: command '%s' requires repo to be installed first. | 645 | Use "repo init" to install it here.""" % cmd, file=sys.stderr) |
653 | Use "repo init" to install it here.""" % cmd | ||
654 | sys.exit(1) | 646 | sys.exit(1) |
655 | 647 | ||
656 | 648 | ||
@@ -687,7 +679,7 @@ def _SetDefaultsTo(gitdir): | |||
687 | proc.stderr.close() | 679 | proc.stderr.close() |
688 | 680 | ||
689 | if proc.wait() != 0: | 681 | if proc.wait() != 0: |
690 | print >>sys.stderr, 'fatal: %s has no current branch' % gitdir | 682 | print('fatal: %s has no current branch' % gitdir, file=sys.stderr) |
691 | sys.exit(1) | 683 | sys.exit(1) |
692 | 684 | ||
693 | 685 | ||
@@ -736,8 +728,8 @@ def main(orig_args): | |||
736 | try: | 728 | try: |
737 | os.execv(repo_main, me) | 729 | os.execv(repo_main, me) |
738 | except OSError as e: | 730 | except OSError as e: |
739 | print >>sys.stderr, "fatal: unable to start %s" % repo_main | 731 | print("fatal: unable to start %s" % repo_main, file=sys.stderr) |
740 | print >>sys.stderr, "fatal: %s" % e | 732 | print("fatal: %s" % e, file=sys.stderr) |
741 | sys.exit(148) | 733 | sys.exit(148) |
742 | 734 | ||
743 | 735 | ||
diff --git a/subcmds/abandon.py b/subcmds/abandon.py index e17ab2b6..b94ccdd3 100644 --- a/subcmds/abandon.py +++ b/subcmds/abandon.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 sys | 17 | import sys |
17 | from command import Command | 18 | from command import Command |
18 | from git_command import git | 19 | from git_command import git |
@@ -36,7 +37,7 @@ It is equivalent to "git branch -D <branchname>". | |||
36 | 37 | ||
37 | nb = args[0] | 38 | nb = args[0] |
38 | if not git.check_ref_format('heads/%s' % nb): | 39 | if not git.check_ref_format('heads/%s' % nb): |
39 | print >>sys.stderr, "error: '%s' is not a valid name" % nb | 40 | print("error: '%s' is not a valid name" % nb, file=sys.stderr) |
40 | sys.exit(1) | 41 | sys.exit(1) |
41 | 42 | ||
42 | nb = args[0] | 43 | nb = args[0] |
@@ -58,13 +59,13 @@ It is equivalent to "git branch -D <branchname>". | |||
58 | 59 | ||
59 | if err: | 60 | if err: |
60 | for p in err: | 61 | for p in err: |
61 | print >>sys.stderr,\ | 62 | print("error: %s/: cannot abandon %s" % (p.relpath, nb), |
62 | "error: %s/: cannot abandon %s" \ | 63 | file=sys.stderr) |
63 | % (p.relpath, nb) | ||
64 | sys.exit(1) | 64 | sys.exit(1) |
65 | elif not success: | 65 | elif not success: |
66 | print >>sys.stderr, 'error: no project has branch %s' % nb | 66 | print('error: no project has branch %s' % nb, file=sys.stderr) |
67 | sys.exit(1) | 67 | sys.exit(1) |
68 | else: | 68 | else: |
69 | print >>sys.stderr, 'Abandoned in %d project(s):\n %s' % ( | 69 | print('Abandoned in %d project(s):\n %s' |
70 | len(success), '\n '.join(p.relpath for p in success)) | 70 | % (len(success), '\n '.join(p.relpath for p in success)), |
71 | file=sys.stderr) | ||
diff --git a/subcmds/branches.py b/subcmds/branches.py index a7ba3d6d..06d45abe 100644 --- a/subcmds/branches.py +++ b/subcmds/branches.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 sys | 17 | import sys |
17 | from color import Coloring | 18 | from color import Coloring |
18 | from command import Command | 19 | from command import Command |
@@ -107,7 +108,7 @@ is shown, then the branch appears in all projects. | |||
107 | names.sort() | 108 | names.sort() |
108 | 109 | ||
109 | if not names: | 110 | if not names: |
110 | print >>sys.stderr, ' (no branches)' | 111 | print(' (no branches)', file=sys.stderr) |
111 | return | 112 | return |
112 | 113 | ||
113 | width = 25 | 114 | width = 25 |
diff --git a/subcmds/checkout.py b/subcmds/checkout.py index bfbe9921..cbbca106 100644 --- a/subcmds/checkout.py +++ b/subcmds/checkout.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 sys | 17 | import sys |
17 | from command import Command | 18 | from command import Command |
18 | from progress import Progress | 19 | from progress import Progress |
@@ -55,10 +56,9 @@ The command is equivalent to: | |||
55 | 56 | ||
56 | if err: | 57 | if err: |
57 | for p in err: | 58 | for p in err: |
58 | print >>sys.stderr,\ | 59 | print("error: %s/: cannot checkout %s" % (p.relpath, nb), |
59 | "error: %s/: cannot checkout %s" \ | 60 | file=sys.stderr) |
60 | % (p.relpath, nb) | ||
61 | sys.exit(1) | 61 | sys.exit(1) |
62 | elif not success: | 62 | elif not success: |
63 | print >>sys.stderr, 'error: no project has branch %s' % nb | 63 | print('error: no project has branch %s' % nb, file=sys.stderr) |
64 | sys.exit(1) | 64 | sys.exit(1) |
diff --git a/subcmds/cherry_pick.py b/subcmds/cherry_pick.py index 7a6d4c20..0cefec13 100644 --- a/subcmds/cherry_pick.py +++ b/subcmds/cherry_pick.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 re | 17 | import re |
17 | import sys | 18 | import sys |
18 | from command import Command | 19 | from command import Command |
@@ -46,13 +47,13 @@ change id will be added. | |||
46 | capture_stdout = True, | 47 | capture_stdout = True, |
47 | capture_stderr = True) | 48 | capture_stderr = True) |
48 | if p.Wait() != 0: | 49 | if p.Wait() != 0: |
49 | print >>sys.stderr, p.stderr | 50 | print(p.stderr, file=sys.stderr) |
50 | sys.exit(1) | 51 | sys.exit(1) |
51 | sha1 = p.stdout.strip() | 52 | sha1 = p.stdout.strip() |
52 | 53 | ||
53 | p = GitCommand(None, ['cat-file', 'commit', sha1], capture_stdout=True) | 54 | p = GitCommand(None, ['cat-file', 'commit', sha1], capture_stdout=True) |
54 | if p.Wait() != 0: | 55 | if p.Wait() != 0: |
55 | print >>sys.stderr, "error: Failed to retrieve old commit message" | 56 | print("error: Failed to retrieve old commit message", file=sys.stderr) |
56 | sys.exit(1) | 57 | sys.exit(1) |
57 | old_msg = self._StripHeader(p.stdout) | 58 | old_msg = self._StripHeader(p.stdout) |
58 | 59 | ||
@@ -62,8 +63,8 @@ change id will be added. | |||
62 | capture_stderr = True) | 63 | capture_stderr = True) |
63 | status = p.Wait() | 64 | status = p.Wait() |
64 | 65 | ||
65 | print >>sys.stdout, p.stdout | 66 | print(p.stdout, file=sys.stdout) |
66 | print >>sys.stderr, p.stderr | 67 | print(p.stderr, file=sys.stderr) |
67 | 68 | ||
68 | if status == 0: | 69 | if status == 0: |
69 | # The cherry-pick was applied correctly. We just need to edit the | 70 | # The cherry-pick was applied correctly. We just need to edit the |
@@ -76,16 +77,14 @@ change id will be added. | |||
76 | capture_stderr = True) | 77 | capture_stderr = True) |
77 | p.stdin.write(new_msg) | 78 | p.stdin.write(new_msg) |
78 | if p.Wait() != 0: | 79 | if p.Wait() != 0: |
79 | print >>sys.stderr, "error: Failed to update commit message" | 80 | print("error: Failed to update commit message", file=sys.stderr) |
80 | sys.exit(1) | 81 | sys.exit(1) |
81 | 82 | ||
82 | else: | 83 | else: |
83 | print >>sys.stderr, """\ | 84 | print('NOTE: When committing (please see above) and editing the commit' |
84 | NOTE: When committing (please see above) and editing the commit message, | 85 | 'message, please remove the old Change-Id-line and add:') |
85 | please remove the old Change-Id-line and add: | 86 | print(self._GetReference(sha1), file=stderr) |
86 | """ | 87 | print(file=stderr) |
87 | print >>sys.stderr, self._GetReference(sha1) | ||
88 | print >>sys.stderr | ||
89 | 88 | ||
90 | def _IsChangeId(self, line): | 89 | def _IsChangeId(self, line): |
91 | return CHANGE_ID_RE.match(line) | 90 | return CHANGE_ID_RE.match(line) |
diff --git a/subcmds/download.py b/subcmds/download.py index 0abe90d0..6aa54afa 100644 --- a/subcmds/download.py +++ b/subcmds/download.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 re | 17 | import re |
17 | import sys | 18 | import sys |
18 | 19 | ||
@@ -68,23 +69,23 @@ makes it available in your project's local working directory. | |||
68 | for project, change_id, ps_id in self._ParseChangeIds(args): | 69 | for project, change_id, ps_id in self._ParseChangeIds(args): |
69 | dl = project.DownloadPatchSet(change_id, ps_id) | 70 | dl = project.DownloadPatchSet(change_id, ps_id) |
70 | if not dl: | 71 | if not dl: |
71 | print >>sys.stderr, \ | 72 | print('[%s] change %d/%d not found' |
72 | '[%s] change %d/%d not found' \ | 73 | % (project.name, change_id, ps_id), |
73 | % (project.name, change_id, ps_id) | 74 | file=sys.stderr) |
74 | sys.exit(1) | 75 | sys.exit(1) |
75 | 76 | ||
76 | if not opt.revert and not dl.commits: | 77 | if not opt.revert and not dl.commits: |
77 | print >>sys.stderr, \ | 78 | print('[%s] change %d/%d has already been merged' |
78 | '[%s] change %d/%d has already been merged' \ | 79 | % (project.name, change_id, ps_id), |
79 | % (project.name, change_id, ps_id) | 80 | file=sys.stderr) |
80 | continue | 81 | continue |
81 | 82 | ||
82 | if len(dl.commits) > 1: | 83 | if len(dl.commits) > 1: |
83 | print >>sys.stderr, \ | 84 | print('[%s] %d/%d depends on %d unmerged changes:' \ |
84 | '[%s] %d/%d depends on %d unmerged changes:' \ | 85 | % (project.name, change_id, ps_id, len(dl.commits)), |
85 | % (project.name, change_id, ps_id, len(dl.commits)) | 86 | file=sys.stderr) |
86 | for c in dl.commits: | 87 | for c in dl.commits: |
87 | print >>sys.stderr, ' %s' % (c) | 88 | print(' %s' % (c), file=sys.stderr) |
88 | if opt.cherrypick: | 89 | if opt.cherrypick: |
89 | project._CherryPick(dl.commit) | 90 | project._CherryPick(dl.commit) |
90 | elif opt.revert: | 91 | elif opt.revert: |
diff --git a/subcmds/forall.py b/subcmds/forall.py index b633b7d4..49e725c2 100644 --- a/subcmds/forall.py +++ b/subcmds/forall.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 fcntl | 17 | import fcntl |
17 | import re | 18 | import re |
18 | import os | 19 | import os |
@@ -183,7 +184,7 @@ terminal and are not redirected. | |||
183 | if not os.path.exists(cwd): | 184 | if not os.path.exists(cwd): |
184 | if (opt.project_header and opt.verbose) \ | 185 | if (opt.project_header and opt.verbose) \ |
185 | or not opt.project_header: | 186 | or not opt.project_header: |
186 | print >>sys.stderr, 'skipping %s/' % project.relpath | 187 | print('skipping %s/' % project.relpath, file=sys.stderr) |
187 | continue | 188 | continue |
188 | 189 | ||
189 | if opt.project_header: | 190 | if opt.project_header: |
diff --git a/subcmds/grep.py b/subcmds/grep.py index b067629a..fa5f8765 100644 --- a/subcmds/grep.py +++ b/subcmds/grep.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 sys | 17 | import sys |
17 | from color import Coloring | 18 | from color import Coloring |
18 | from command import PagedCommand | 19 | from command import PagedCommand |
@@ -178,8 +179,7 @@ contain a line that matches both expressions: | |||
178 | have_rev = False | 179 | have_rev = False |
179 | if opt.revision: | 180 | if opt.revision: |
180 | if '--cached' in cmd_argv: | 181 | if '--cached' in cmd_argv: |
181 | print >>sys.stderr,\ | 182 | print('fatal: cannot combine --cached and --revision', file=sys.stderr) |
182 | 'fatal: cannot combine --cached and --revision' | ||
183 | sys.exit(1) | 183 | sys.exit(1) |
184 | have_rev = True | 184 | have_rev = True |
185 | cmd_argv.extend(opt.revision) | 185 | cmd_argv.extend(opt.revision) |
@@ -230,13 +230,13 @@ contain a line that matches both expressions: | |||
230 | out.nl() | 230 | out.nl() |
231 | else: | 231 | else: |
232 | for line in r: | 232 | for line in r: |
233 | print line | 233 | print(line) |
234 | 234 | ||
235 | if have_match: | 235 | if have_match: |
236 | sys.exit(0) | 236 | sys.exit(0) |
237 | elif have_rev and bad_rev: | 237 | elif have_rev and bad_rev: |
238 | for r in opt.revision: | 238 | for r in opt.revision: |
239 | print >>sys.stderr, "error: can't search revision %s" % r | 239 | print("error: can't search revision %s" % r, file=sys.stderr) |
240 | sys.exit(1) | 240 | sys.exit(1) |
241 | else: | 241 | else: |
242 | sys.exit(1) | 242 | sys.exit(1) |
diff --git a/subcmds/help.py b/subcmds/help.py index 375d04d2..57fb3cc2 100644 --- a/subcmds/help.py +++ b/subcmds/help.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 re | 17 | import re |
17 | import sys | 18 | import sys |
18 | from formatter import AbstractFormatter, DumbWriter | 19 | from formatter import AbstractFormatter, DumbWriter |
@@ -31,10 +32,8 @@ Displays detailed usage information about a command. | |||
31 | """ | 32 | """ |
32 | 33 | ||
33 | def _PrintAllCommands(self): | 34 | def _PrintAllCommands(self): |
34 | print 'usage: repo COMMAND [ARGS]' | 35 | print('usage: repo COMMAND [ARGS]') |
35 | print """ | 36 | print('The complete list of recognized repo commands are:') |
36 | The complete list of recognized repo commands are: | ||
37 | """ | ||
38 | commandNames = self.commands.keys() | 37 | commandNames = self.commands.keys() |
39 | commandNames.sort() | 38 | commandNames.sort() |
40 | 39 | ||
@@ -49,17 +48,14 @@ The complete list of recognized repo commands are: | |||
49 | summary = command.helpSummary.strip() | 48 | summary = command.helpSummary.strip() |
50 | except AttributeError: | 49 | except AttributeError: |
51 | summary = '' | 50 | summary = '' |
52 | print fmt % (name, summary) | 51 | print(fmt % (name, summary)) |
53 | print """ | 52 | print("See 'repo help <command>' for more information on a" |
54 | See 'repo help <command>' for more information on a specific command. | 53 | 'specific command.') |
55 | """ | ||
56 | 54 | ||
57 | def _PrintCommonCommands(self): | 55 | def _PrintCommonCommands(self): |
58 | print 'usage: repo COMMAND [ARGS]' | 56 | print('usage: repo COMMAND [ARGS]') |
59 | print """ | 57 | print('The most commonly used repo commands are:') |
60 | The most commonly used repo commands are: | 58 | commandNames = [name |
61 | """ | ||
62 | commandNames = [name | ||
63 | for name in self.commands.keys() | 59 | for name in self.commands.keys() |
64 | if self.commands[name].common] | 60 | if self.commands[name].common] |
65 | commandNames.sort() | 61 | commandNames.sort() |
@@ -75,11 +71,10 @@ The most commonly used repo commands are: | |||
75 | summary = command.helpSummary.strip() | 71 | summary = command.helpSummary.strip() |
76 | except AttributeError: | 72 | except AttributeError: |
77 | summary = '' | 73 | summary = '' |
78 | print fmt % (name, summary) | 74 | print(fmt % (name, summary)) |
79 | print """ | 75 | print( |
80 | See 'repo help <command>' for more information on a specific command. | 76 | "See 'repo help <command>' for more information on a specific command.\n" |
81 | See 'repo help --all' for a complete list of recognized commands. | 77 | "See 'repo help --all' for a complete list of recognized commands.") |
82 | """ | ||
83 | 78 | ||
84 | def _PrintCommandHelp(self, cmd): | 79 | def _PrintCommandHelp(self, cmd): |
85 | class _Out(Coloring): | 80 | class _Out(Coloring): |
@@ -162,7 +157,7 @@ See 'repo help --all' for a complete list of recognized commands. | |||
162 | try: | 157 | try: |
163 | cmd = self.commands[name] | 158 | cmd = self.commands[name] |
164 | except KeyError: | 159 | except KeyError: |
165 | print >>sys.stderr, "repo: '%s' is not a repo command." % name | 160 | print("repo: '%s' is not a repo command." % name, file=sys.stderr) |
166 | sys.exit(1) | 161 | sys.exit(1) |
167 | 162 | ||
168 | cmd.manifest = self.manifest | 163 | cmd.manifest = self.manifest |
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) |
diff --git a/subcmds/list.py b/subcmds/list.py index 6058a755..0d5c27f7 100644 --- a/subcmds/list.py +++ b/subcmds/list.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 re | 17 | import re |
17 | 18 | ||
18 | from command import Command, MirrorSafeCommand | 19 | from command import Command, MirrorSafeCommand |
@@ -64,7 +65,7 @@ This is similar to running: repo forall -c 'echo "$REPO_PATH : $REPO_PROJECT"'. | |||
64 | lines.append("%s : %s" % (_getpath(project), project.name)) | 65 | lines.append("%s : %s" % (_getpath(project), project.name)) |
65 | 66 | ||
66 | lines.sort() | 67 | lines.sort() |
67 | print '\n'.join(lines) | 68 | print('\n'.join(lines)) |
68 | 69 | ||
69 | def FindProjects(self, args): | 70 | def FindProjects(self, args): |
70 | result = [] | 71 | result = [] |
diff --git a/subcmds/manifest.py b/subcmds/manifest.py index 5592a37d..5ceeb12f 100644 --- a/subcmds/manifest.py +++ b/subcmds/manifest.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 sys | 18 | import sys |
18 | 19 | ||
@@ -69,7 +70,7 @@ in a Git repository for use during future 'repo init' invocations. | |||
69 | peg_rev_upstream = opt.peg_rev_upstream) | 70 | peg_rev_upstream = opt.peg_rev_upstream) |
70 | fd.close() | 71 | fd.close() |
71 | if opt.output_file != '-': | 72 | if opt.output_file != '-': |
72 | print >>sys.stderr, 'Saved manifest to %s' % opt.output_file | 73 | print('Saved manifest to %s' % opt.output_file, file=sys.stderr) |
73 | 74 | ||
74 | def Execute(self, opt, args): | 75 | def Execute(self, opt, args): |
75 | if args: | 76 | if args: |
@@ -79,6 +80,6 @@ in a Git repository for use during future 'repo init' invocations. | |||
79 | self._Output(opt) | 80 | self._Output(opt) |
80 | return | 81 | return |
81 | 82 | ||
82 | print >>sys.stderr, 'error: no operation to perform' | 83 | print('error: no operation to perform', file=sys.stderr) |
83 | print >>sys.stderr, 'error: see repo help manifest' | 84 | print('error: see repo help manifest', file=sys.stderr) |
84 | sys.exit(1) | 85 | sys.exit(1) |
diff --git a/subcmds/overview.py b/subcmds/overview.py index a509bd9a..9e6100b4 100644 --- a/subcmds/overview.py +++ b/subcmds/overview.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 | from color import Coloring | 17 | from color import Coloring |
17 | from command import PagedCommand | 18 | from command import PagedCommand |
18 | 19 | ||
@@ -70,11 +71,11 @@ are displayed. | |||
70 | 71 | ||
71 | commits = branch.commits | 72 | commits = branch.commits |
72 | date = branch.date | 73 | date = branch.date |
73 | print '%s %-33s (%2d commit%s, %s)' % ( | 74 | print('%s %-33s (%2d commit%s, %s)' % ( |
74 | branch.name == project.CurrentBranch and '*' or ' ', | 75 | branch.name == project.CurrentBranch and '*' or ' ', |
75 | branch.name, | 76 | branch.name, |
76 | len(commits), | 77 | len(commits), |
77 | len(commits) != 1 and 's' or ' ', | 78 | len(commits) != 1 and 's' or ' ', |
78 | date) | 79 | date)) |
79 | for commit in commits: | 80 | for commit in commits: |
80 | print '%-35s - %s' % ('', commit) | 81 | print('%-35s - %s' % ('', commit)) |
diff --git a/subcmds/prune.py b/subcmds/prune.py index c50a5507..39c571a4 100644 --- a/subcmds/prune.py +++ b/subcmds/prune.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 | from color import Coloring | 17 | from color import Coloring |
17 | from command import PagedCommand | 18 | from command import PagedCommand |
18 | 19 | ||
@@ -51,9 +52,9 @@ class Prune(PagedCommand): | |||
51 | 52 | ||
52 | commits = branch.commits | 53 | commits = branch.commits |
53 | date = branch.date | 54 | date = branch.date |
54 | print '%s %-33s (%2d commit%s, %s)' % ( | 55 | print('%s %-33s (%2d commit%s, %s)' % ( |
55 | branch.name == project.CurrentBranch and '*' or ' ', | 56 | branch.name == project.CurrentBranch and '*' or ' ', |
56 | branch.name, | 57 | branch.name, |
57 | len(commits), | 58 | len(commits), |
58 | len(commits) != 1 and 's' or ' ', | 59 | len(commits) != 1 and 's' or ' ', |
59 | date) | 60 | date)) |
diff --git a/subcmds/rebase.py b/subcmds/rebase.py index a8d58cdb..06cda22c 100644 --- a/subcmds/rebase.py +++ b/subcmds/rebase.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 sys | 17 | import sys |
17 | 18 | ||
18 | from command import Command | 19 | from command import Command |
@@ -59,14 +60,16 @@ branch but need to incorporate new upstream changes "underneath" them. | |||
59 | one_project = len(all_projects) == 1 | 60 | one_project = len(all_projects) == 1 |
60 | 61 | ||
61 | if opt.interactive and not one_project: | 62 | if opt.interactive and not one_project: |
62 | print >>sys.stderr, 'error: interactive rebase not supported with multiple projects' | 63 | print('error: interactive rebase not supported with multiple projects', |
64 | file=sys.stderr) | ||
63 | return -1 | 65 | return -1 |
64 | 66 | ||
65 | for project in all_projects: | 67 | for project in all_projects: |
66 | cb = project.CurrentBranch | 68 | cb = project.CurrentBranch |
67 | if not cb: | 69 | if not cb: |
68 | if one_project: | 70 | if one_project: |
69 | print >>sys.stderr, "error: project %s has a detatched HEAD" % project.relpath | 71 | print("error: project %s has a detatched HEAD" % project.relpath, |
72 | file=sys.stderr) | ||
70 | return -1 | 73 | return -1 |
71 | # ignore branches with detatched HEADs | 74 | # ignore branches with detatched HEADs |
72 | continue | 75 | continue |
@@ -74,7 +77,8 @@ branch but need to incorporate new upstream changes "underneath" them. | |||
74 | upbranch = project.GetBranch(cb) | 77 | upbranch = project.GetBranch(cb) |
75 | if not upbranch.LocalMerge: | 78 | if not upbranch.LocalMerge: |
76 | if one_project: | 79 | if one_project: |
77 | print >>sys.stderr, "error: project %s does not track any remote branches" % project.relpath | 80 | print("error: project %s does not track any remote branches" |
81 | % project.relpath, file=sys.stderr) | ||
78 | return -1 | 82 | return -1 |
79 | # ignore branches without remotes | 83 | # ignore branches without remotes |
80 | continue | 84 | continue |
@@ -101,8 +105,8 @@ branch but need to incorporate new upstream changes "underneath" them. | |||
101 | 105 | ||
102 | args.append(upbranch.LocalMerge) | 106 | args.append(upbranch.LocalMerge) |
103 | 107 | ||
104 | print >>sys.stderr, '# %s: rebasing %s -> %s' % \ | 108 | print('# %s: rebasing %s -> %s' |
105 | (project.relpath, cb, upbranch.LocalMerge) | 109 | % (project.relpath, cb, upbranch.LocalMerge), file=sys.stderr) |
106 | 110 | ||
107 | needs_stash = False | 111 | needs_stash = False |
108 | if opt.auto_stash: | 112 | if opt.auto_stash: |
diff --git a/subcmds/selfupdate.py b/subcmds/selfupdate.py index 46aa3a19..d12e08d0 100644 --- a/subcmds/selfupdate.py +++ b/subcmds/selfupdate.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 | from optparse import SUPPRESS_HELP | 17 | from optparse import SUPPRESS_HELP |
17 | import sys | 18 | import sys |
18 | 19 | ||
@@ -52,7 +53,7 @@ need to be performed by an end-user. | |||
52 | 53 | ||
53 | else: | 54 | else: |
54 | if not rp.Sync_NetworkHalf(): | 55 | if not rp.Sync_NetworkHalf(): |
55 | print >>sys.stderr, "error: can't update repo" | 56 | print("error: can't update repo", file=sys.stderr) |
56 | sys.exit(1) | 57 | sys.exit(1) |
57 | 58 | ||
58 | rp.bare_git.gc('--auto') | 59 | rp.bare_git.gc('--auto') |
diff --git a/subcmds/stage.py b/subcmds/stage.py index 1ff85880..ff15ee0c 100644 --- a/subcmds/stage.py +++ b/subcmds/stage.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 sys | 17 | import sys |
17 | 18 | ||
18 | from color import Coloring | 19 | from color import Coloring |
@@ -50,7 +51,7 @@ The '%prog' command stages files to prepare the next commit. | |||
50 | def _Interactive(self, opt, args): | 51 | def _Interactive(self, opt, args): |
51 | all_projects = filter(lambda x: x.IsDirty(), self.GetProjects(args)) | 52 | all_projects = filter(lambda x: x.IsDirty(), self.GetProjects(args)) |
52 | if not all_projects: | 53 | if not all_projects: |
53 | print >>sys.stderr,'no projects have uncommitted modifications' | 54 | print('no projects have uncommitted modifications', file=sys.stderr) |
54 | return | 55 | return |
55 | 56 | ||
56 | out = _ProjectList(self.manifest.manifestProject.config) | 57 | out = _ProjectList(self.manifest.manifestProject.config) |
@@ -101,7 +102,7 @@ The '%prog' command stages files to prepare the next commit. | |||
101 | if len(p) == 1: | 102 | if len(p) == 1: |
102 | _AddI(p[0]) | 103 | _AddI(p[0]) |
103 | continue | 104 | continue |
104 | print 'Bye.' | 105 | print('Bye.') |
105 | 106 | ||
106 | def _AddI(project): | 107 | def _AddI(project): |
107 | p = GitCommand(project, ['add', '--interactive'], bare=False) | 108 | p = GitCommand(project, ['add', '--interactive'], bare=False) |
diff --git a/subcmds/start.py b/subcmds/start.py index be645314..2d723fc2 100644 --- a/subcmds/start.py +++ b/subcmds/start.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 sys | 17 | import sys |
17 | from command import Command | 18 | from command import Command |
18 | from git_config import IsId | 19 | from git_config import IsId |
@@ -41,7 +42,7 @@ revision specified in the manifest. | |||
41 | 42 | ||
42 | nb = args[0] | 43 | nb = args[0] |
43 | if not git.check_ref_format('heads/%s' % nb): | 44 | if not git.check_ref_format('heads/%s' % nb): |
44 | print >>sys.stderr, "error: '%s' is not a valid name" % nb | 45 | print("error: '%s' is not a valid name" % nb, file=sys.stderr) |
45 | sys.exit(1) | 46 | sys.exit(1) |
46 | 47 | ||
47 | err = [] | 48 | err = [] |
@@ -49,7 +50,7 @@ revision specified in the manifest. | |||
49 | if not opt.all: | 50 | if not opt.all: |
50 | projects = args[1:] | 51 | projects = args[1:] |
51 | if len(projects) < 1: | 52 | if len(projects) < 1: |
52 | print >>sys.stderr, "error: at least one project must be specified" | 53 | print("error: at least one project must be specified", file=sys.stderr) |
53 | sys.exit(1) | 54 | sys.exit(1) |
54 | 55 | ||
55 | all_projects = self.GetProjects(projects) | 56 | all_projects = self.GetProjects(projects) |
@@ -67,7 +68,6 @@ revision specified in the manifest. | |||
67 | 68 | ||
68 | if err: | 69 | if err: |
69 | for p in err: | 70 | for p in err: |
70 | print >>sys.stderr,\ | 71 | print("error: %s/: cannot start %s" % (p.relpath, nb), |
71 | "error: %s/: cannot start %s" \ | 72 | file=sys.stderr) |
72 | % (p.relpath, nb) | ||
73 | sys.exit(1) | 73 | sys.exit(1) |
diff --git a/subcmds/status.py b/subcmds/status.py index 7611621e..40562274 100644 --- a/subcmds/status.py +++ b/subcmds/status.py | |||
@@ -129,4 +129,4 @@ the following meanings: | |||
129 | output.dump(sys.stdout) | 129 | output.dump(sys.stdout) |
130 | output.close() | 130 | output.close() |
131 | if len(all_projects) == counter.next(): | 131 | if len(all_projects) == counter.next(): |
132 | print 'nothing to commit (working directory clean)' | 132 | print('nothing to commit (working directory clean)') |
diff --git a/subcmds/sync.py b/subcmds/sync.py index d6389118..a64f2c45 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.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 netrc | 17 | import netrc |
17 | from optparse import SUPPRESS_HELP | 18 | from optparse import SUPPRESS_HELP |
18 | import os | 19 | import os |
@@ -234,9 +235,10 @@ later is required to fix a server side protocol bug. | |||
234 | did_lock = True | 235 | did_lock = True |
235 | 236 | ||
236 | if not success: | 237 | if not success: |
237 | print >>sys.stderr, 'error: Cannot fetch %s' % project.name | 238 | print('error: Cannot fetch %s' % project.name, file=sys.stderr) |
238 | if opt.force_broken: | 239 | if opt.force_broken: |
239 | print >>sys.stderr, 'warn: --force-broken, continuing to sync' | 240 | print('warn: --force-broken, continuing to sync', |
241 | file=sys.stderr) | ||
240 | else: | 242 | else: |
241 | raise _FetchError() | 243 | raise _FetchError() |
242 | 244 | ||
@@ -265,9 +267,9 @@ later is required to fix a server side protocol bug. | |||
265 | clone_bundle=not opt.no_clone_bundle): | 267 | clone_bundle=not opt.no_clone_bundle): |
266 | fetched.add(project.gitdir) | 268 | fetched.add(project.gitdir) |
267 | else: | 269 | else: |
268 | print >>sys.stderr, 'error: Cannot fetch %s' % project.name | 270 | print('error: Cannot fetch %s' % project.name, file=sys.stderr) |
269 | if opt.force_broken: | 271 | if opt.force_broken: |
270 | print >>sys.stderr, 'warn: --force-broken, continuing to sync' | 272 | print('warn: --force-broken, continuing to sync', file=sys.stderr) |
271 | else: | 273 | else: |
272 | sys.exit(1) | 274 | sys.exit(1) |
273 | else: | 275 | else: |
@@ -300,7 +302,7 @@ later is required to fix a server side protocol bug. | |||
300 | 302 | ||
301 | # If we saw an error, exit with code 1 so that other scripts can check. | 303 | # If we saw an error, exit with code 1 so that other scripts can check. |
302 | if err_event.isSet(): | 304 | if err_event.isSet(): |
303 | print >>sys.stderr, '\nerror: Exited sync due to fetch errors' | 305 | print('\nerror: Exited sync due to fetch errors', file=sys.stderr) |
304 | sys.exit(1) | 306 | sys.exit(1) |
305 | 307 | ||
306 | pm.end() | 308 | pm.end() |
@@ -353,7 +355,7 @@ later is required to fix a server side protocol bug. | |||
353 | t.join() | 355 | t.join() |
354 | 356 | ||
355 | if err_event.isSet(): | 357 | if err_event.isSet(): |
356 | print >>sys.stderr, '\nerror: Exited sync due to gc errors' | 358 | print('\nerror: Exited sync due to gc errors', file=sys.stderr) |
357 | sys.exit(1) | 359 | sys.exit(1) |
358 | 360 | ||
359 | def UpdateProjectList(self): | 361 | def UpdateProjectList(self): |
@@ -390,12 +392,14 @@ later is required to fix a server side protocol bug. | |||
390 | groups = None) | 392 | groups = None) |
391 | 393 | ||
392 | if project.IsDirty(): | 394 | if project.IsDirty(): |
393 | print >>sys.stderr, 'error: Cannot remove project "%s": \ | 395 | print('error: Cannot remove project "%s": uncommitted changes' |
394 | uncommitted changes are present' % project.relpath | 396 | 'are present' % project.relpath, file=sys.stderr) |
395 | print >>sys.stderr, ' commit changes, then run sync again' | 397 | print(' commit changes, then run sync again', |
398 | file=sys.stderr) | ||
396 | return -1 | 399 | return -1 |
397 | else: | 400 | else: |
398 | print >>sys.stderr, 'Deleting obsolete path %s' % project.worktree | 401 | print('Deleting obsolete path %s' % project.worktree, |
402 | file=sys.stderr) | ||
399 | shutil.rmtree(project.worktree) | 403 | shutil.rmtree(project.worktree) |
400 | # Try deleting parent subdirs if they are empty | 404 | # Try deleting parent subdirs if they are empty |
401 | project_dir = os.path.dirname(project.worktree) | 405 | project_dir = os.path.dirname(project.worktree) |
@@ -423,24 +427,24 @@ uncommitted changes are present' % project.relpath | |||
423 | self.jobs = min(self.jobs, (soft_limit - 5) / 3) | 427 | self.jobs = min(self.jobs, (soft_limit - 5) / 3) |
424 | 428 | ||
425 | if opt.network_only and opt.detach_head: | 429 | if opt.network_only and opt.detach_head: |
426 | print >>sys.stderr, 'error: cannot combine -n and -d' | 430 | print('error: cannot combine -n and -d', file=sys.stderr) |
427 | sys.exit(1) | 431 | sys.exit(1) |
428 | if opt.network_only and opt.local_only: | 432 | if opt.network_only and opt.local_only: |
429 | print >>sys.stderr, 'error: cannot combine -n and -l' | 433 | print('error: cannot combine -n and -l', file=sys.stderr) |
430 | sys.exit(1) | 434 | sys.exit(1) |
431 | if opt.manifest_name and opt.smart_sync: | 435 | if opt.manifest_name and opt.smart_sync: |
432 | print >>sys.stderr, 'error: cannot combine -m and -s' | 436 | print('error: cannot combine -m and -s', file=sys.stderr) |
433 | sys.exit(1) | 437 | sys.exit(1) |
434 | if opt.manifest_name and opt.smart_tag: | 438 | if opt.manifest_name and opt.smart_tag: |
435 | print >>sys.stderr, 'error: cannot combine -m and -t' | 439 | print('error: cannot combine -m and -t', file=sys.stderr) |
436 | sys.exit(1) | 440 | sys.exit(1) |
437 | if opt.manifest_server_username or opt.manifest_server_password: | 441 | if opt.manifest_server_username or opt.manifest_server_password: |
438 | if not (opt.smart_sync or opt.smart_tag): | 442 | if not (opt.smart_sync or opt.smart_tag): |
439 | print >>sys.stderr, 'error: -u and -p may only be combined with ' \ | 443 | print('error: -u and -p may only be combined with -s or -t', |
440 | '-s or -t' | 444 | file=sys.stderr) |
441 | sys.exit(1) | 445 | sys.exit(1) |
442 | if None in [opt.manifest_server_username, opt.manifest_server_password]: | 446 | if None in [opt.manifest_server_username, opt.manifest_server_password]: |
443 | print >>sys.stderr, 'error: both -u and -p must be given' | 447 | print('error: both -u and -p must be given', file=sys.stderr) |
444 | sys.exit(1) | 448 | sys.exit(1) |
445 | 449 | ||
446 | if opt.manifest_name: | 450 | if opt.manifest_name: |
@@ -448,8 +452,8 @@ uncommitted changes are present' % project.relpath | |||
448 | 452 | ||
449 | if opt.smart_sync or opt.smart_tag: | 453 | if opt.smart_sync or opt.smart_tag: |
450 | if not self.manifest.manifest_server: | 454 | if not self.manifest.manifest_server: |
451 | print >>sys.stderr, \ | 455 | print('error: cannot smart sync: no manifest server defined in' |
452 | 'error: cannot smart sync: no manifest server defined in manifest' | 456 | 'manifest', file=sys.stderr) |
453 | sys.exit(1) | 457 | sys.exit(1) |
454 | 458 | ||
455 | manifest_server = self.manifest.manifest_server | 459 | manifest_server = self.manifest.manifest_server |
@@ -464,7 +468,8 @@ uncommitted changes are present' % project.relpath | |||
464 | try: | 468 | try: |
465 | info = netrc.netrc() | 469 | info = netrc.netrc() |
466 | except IOError: | 470 | except IOError: |
467 | print >>sys.stderr, '.netrc file does not exist or could not be opened' | 471 | print('.netrc file does not exist or could not be opened', |
472 | file=sys.stderr) | ||
468 | else: | 473 | else: |
469 | try: | 474 | try: |
470 | parse_result = urlparse.urlparse(manifest_server) | 475 | parse_result = urlparse.urlparse(manifest_server) |
@@ -474,10 +479,10 @@ uncommitted changes are present' % project.relpath | |||
474 | except TypeError: | 479 | except TypeError: |
475 | # TypeError is raised when the given hostname is not present | 480 | # TypeError is raised when the given hostname is not present |
476 | # in the .netrc file. | 481 | # in the .netrc file. |
477 | print >>sys.stderr, 'No credentials found for %s in .netrc' % \ | 482 | print('No credentials found for %s in .netrc' |
478 | parse_result.hostname | 483 | % parse_result.hostname, file=sys.stderr) |
479 | except netrc.NetrcParseError as e: | 484 | except netrc.NetrcParseError as e: |
480 | print >>sys.stderr, 'Error parsing .netrc file: %s' % e | 485 | print('Error parsing .netrc file: %s' % e, file=sys.stderr) |
481 | 486 | ||
482 | if (username and password): | 487 | if (username and password): |
483 | manifest_server = manifest_server.replace('://', '://%s:%s@' % | 488 | manifest_server = manifest_server.replace('://', '://%s:%s@' % |
@@ -516,20 +521,21 @@ uncommitted changes are present' % project.relpath | |||
516 | finally: | 521 | finally: |
517 | f.close() | 522 | f.close() |
518 | except IOError: | 523 | except IOError: |
519 | print >>sys.stderr, 'error: cannot write manifest to %s' % \ | 524 | print('error: cannot write manifest to %s' % manifest_path, |
520 | manifest_path | 525 | file=sys.stderr) |
521 | sys.exit(1) | 526 | sys.exit(1) |
522 | self.manifest.Override(manifest_name) | 527 | self.manifest.Override(manifest_name) |
523 | else: | 528 | else: |
524 | print >>sys.stderr, 'error: %s' % manifest_str | 529 | print('error: %s' % manifest_str, file=sys.stderr) |
525 | sys.exit(1) | 530 | sys.exit(1) |
526 | except (socket.error, IOError, xmlrpclib.Fault) as e: | 531 | except (socket.error, IOError, xmlrpclib.Fault) as e: |
527 | print >>sys.stderr, 'error: cannot connect to manifest server %s:\n%s' % ( | 532 | print('error: cannot connect to manifest server %s:\n%s' |
528 | self.manifest.manifest_server, e) | 533 | % (self.manifest.manifest_server, e), file=sys.stderr) |
529 | sys.exit(1) | 534 | sys.exit(1) |
530 | except xmlrpclib.ProtocolError as e: | 535 | except xmlrpclib.ProtocolError as e: |
531 | print >>sys.stderr, 'error: cannot connect to manifest server %s:\n%d %s' % ( | 536 | print('error: cannot connect to manifest server %s:\n%d %s' |
532 | self.manifest.manifest_server, e.errcode, e.errmsg) | 537 | % (self.manifest.manifest_server, e.errcode, e.errmsg), |
538 | file=sys.stderr) | ||
533 | sys.exit(1) | 539 | sys.exit(1) |
534 | 540 | ||
535 | rp = self.manifest.repoProject | 541 | rp = self.manifest.repoProject |
@@ -585,14 +591,14 @@ uncommitted changes are present' % project.relpath | |||
585 | if project.worktree: | 591 | if project.worktree: |
586 | project.Sync_LocalHalf(syncbuf) | 592 | project.Sync_LocalHalf(syncbuf) |
587 | pm.end() | 593 | pm.end() |
588 | print >>sys.stderr | 594 | print(file=sys.stderr) |
589 | if not syncbuf.Finish(): | 595 | if not syncbuf.Finish(): |
590 | sys.exit(1) | 596 | sys.exit(1) |
591 | 597 | ||
592 | # If there's a notice that's supposed to print at the end of the sync, print | 598 | # If there's a notice that's supposed to print at the end of the sync, print |
593 | # it now... | 599 | # it now... |
594 | if self.manifest.notice: | 600 | if self.manifest.notice: |
595 | print self.manifest.notice | 601 | print(self.manifest.notice) |
596 | 602 | ||
597 | def _PostRepoUpgrade(manifest, quiet=False): | 603 | def _PostRepoUpgrade(manifest, quiet=False): |
598 | wrapper = WrapperModule() | 604 | wrapper = WrapperModule() |
@@ -604,27 +610,28 @@ def _PostRepoUpgrade(manifest, quiet=False): | |||
604 | 610 | ||
605 | def _PostRepoFetch(rp, no_repo_verify=False, verbose=False): | 611 | def _PostRepoFetch(rp, no_repo_verify=False, verbose=False): |
606 | if rp.HasChanges: | 612 | if rp.HasChanges: |
607 | print >>sys.stderr, 'info: A new version of repo is available' | 613 | print('info: A new version of repo is available', file=sys.stderr) |
608 | print >>sys.stderr, '' | 614 | print(file=sys.stderr) |
609 | if no_repo_verify or _VerifyTag(rp): | 615 | if no_repo_verify or _VerifyTag(rp): |
610 | syncbuf = SyncBuffer(rp.config) | 616 | syncbuf = SyncBuffer(rp.config) |
611 | rp.Sync_LocalHalf(syncbuf) | 617 | rp.Sync_LocalHalf(syncbuf) |
612 | if not syncbuf.Finish(): | 618 | if not syncbuf.Finish(): |
613 | sys.exit(1) | 619 | sys.exit(1) |
614 | print >>sys.stderr, 'info: Restarting repo with latest version' | 620 | print('info: Restarting repo with latest version', file=sys.stderr) |
615 | raise RepoChangedException(['--repo-upgraded']) | 621 | raise RepoChangedException(['--repo-upgraded']) |
616 | else: | 622 | else: |
617 | print >>sys.stderr, 'warning: Skipped upgrade to unverified version' | 623 | print('warning: Skipped upgrade to unverified version', file=sys.stderr) |
618 | else: | 624 | else: |
619 | if verbose: | 625 | if verbose: |
620 | print >>sys.stderr, 'repo version %s is current' % rp.work_git.describe(HEAD) | 626 | print('repo version %s is current' % rp.work_git.describe(HEAD), |
627 | file=sys.stderr) | ||
621 | 628 | ||
622 | def _VerifyTag(project): | 629 | def _VerifyTag(project): |
623 | gpg_dir = os.path.expanduser('~/.repoconfig/gnupg') | 630 | gpg_dir = os.path.expanduser('~/.repoconfig/gnupg') |
624 | if not os.path.exists(gpg_dir): | 631 | if not os.path.exists(gpg_dir): |
625 | print >>sys.stderr,\ | 632 | print('warning: GnuPG was not available during last "repo init"\n' |
626 | """warning: GnuPG was not available during last "repo init" | 633 | 'warning: Cannot automatically authenticate repo."""', |
627 | warning: Cannot automatically authenticate repo.""" | 634 | file=sys.stderr) |
628 | return True | 635 | return True |
629 | 636 | ||
630 | try: | 637 | try: |
@@ -638,10 +645,9 @@ warning: Cannot automatically authenticate repo.""" | |||
638 | if rev.startswith(R_HEADS): | 645 | if rev.startswith(R_HEADS): |
639 | rev = rev[len(R_HEADS):] | 646 | rev = rev[len(R_HEADS):] |
640 | 647 | ||
641 | print >>sys.stderr | 648 | print(file=sys.stderr) |
642 | print >>sys.stderr,\ | 649 | print("warning: project '%s' branch '%s' is not signed" |
643 | "warning: project '%s' branch '%s' is not signed" \ | 650 | % (project.name, rev), file=sys.stderr) |
644 | % (project.name, rev) | ||
645 | return False | 651 | return False |
646 | 652 | ||
647 | env = os.environ.copy() | 653 | env = os.environ.copy() |
@@ -660,10 +666,10 @@ warning: Cannot automatically authenticate repo.""" | |||
660 | proc.stderr.close() | 666 | proc.stderr.close() |
661 | 667 | ||
662 | if proc.wait() != 0: | 668 | if proc.wait() != 0: |
663 | print >>sys.stderr | 669 | print(file=sys.stderr) |
664 | print >>sys.stderr, out | 670 | print(out, file=sys.stderr) |
665 | print >>sys.stderr, err | 671 | print(err, file=sys.stderr) |
666 | print >>sys.stderr | 672 | print(file=sys.stderr) |
667 | return False | 673 | return False |
668 | return True | 674 | return True |
669 | 675 | ||
diff --git a/subcmds/upload.py b/subcmds/upload.py index 925652c2..a6ada337 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.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 copy | 17 | import copy |
17 | import re | 18 | import re |
18 | import sys | 19 | import sys |
@@ -26,16 +27,18 @@ UNUSUAL_COMMIT_THRESHOLD = 5 | |||
26 | 27 | ||
27 | def _ConfirmManyUploads(multiple_branches=False): | 28 | def _ConfirmManyUploads(multiple_branches=False): |
28 | if multiple_branches: | 29 | if multiple_branches: |
29 | print "ATTENTION: One or more branches has an unusually high number of commits." | 30 | print('ATTENTION: One or more branches has an unusually high number' |
31 | 'of commits.') | ||
30 | else: | 32 | else: |
31 | print "ATTENTION: You are uploading an unusually high number of commits." | 33 | print('ATTENTION: You are uploading an unusually high number of commits.') |
32 | print "YOU PROBABLY DO NOT MEAN TO DO THIS. (Did you rebase across branches?)" | 34 | print('YOU PROBABLY DO NOT MEAN TO DO THIS. (Did you rebase across' |
35 | 'branches?)') | ||
33 | answer = raw_input("If you are sure you intend to do this, type 'yes': ").strip() | 36 | answer = raw_input("If you are sure you intend to do this, type 'yes': ").strip() |
34 | return answer == "yes" | 37 | return answer == "yes" |
35 | 38 | ||
36 | def _die(fmt, *args): | 39 | def _die(fmt, *args): |
37 | msg = fmt % args | 40 | msg = fmt % args |
38 | print >>sys.stderr, 'error: %s' % msg | 41 | print('error: %s' % msg, file=sys.stderr) |
39 | sys.exit(1) | 42 | sys.exit(1) |
40 | 43 | ||
41 | def _SplitEmails(values): | 44 | def _SplitEmails(values): |
@@ -176,14 +179,14 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
176 | date = branch.date | 179 | date = branch.date |
177 | commit_list = branch.commits | 180 | commit_list = branch.commits |
178 | 181 | ||
179 | print 'Upload project %s/ to remote branch %s:' % (project.relpath, project.revisionExpr) | 182 | print('Upload project %s/ to remote branch %s:' % (project.relpath, project.revisionExpr)) |
180 | print ' branch %s (%2d commit%s, %s):' % ( | 183 | print(' branch %s (%2d commit%s, %s):' % ( |
181 | name, | 184 | name, |
182 | len(commit_list), | 185 | len(commit_list), |
183 | len(commit_list) != 1 and 's' or '', | 186 | len(commit_list) != 1 and 's' or '', |
184 | date) | 187 | date)) |
185 | for commit in commit_list: | 188 | for commit in commit_list: |
186 | print ' %s' % commit | 189 | print(' %s' % commit) |
187 | 190 | ||
188 | sys.stdout.write('to %s (y/N)? ' % remote.review) | 191 | sys.stdout.write('to %s (y/N)? ' % remote.review) |
189 | answer = sys.stdin.readline().strip().lower() | 192 | answer = sys.stdin.readline().strip().lower() |
@@ -317,7 +320,7 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
317 | sys.stdout.write('Uncommitted changes in ' + branch.project.name + ' (did you forget to amend?). Continue uploading? (y/N) ') | 320 | sys.stdout.write('Uncommitted changes in ' + branch.project.name + ' (did you forget to amend?). Continue uploading? (y/N) ') |
318 | a = sys.stdin.readline().strip().lower() | 321 | a = sys.stdin.readline().strip().lower() |
319 | if a not in ('y', 'yes', 't', 'true', 'on'): | 322 | if a not in ('y', 'yes', 't', 'true', 'on'): |
320 | print >>sys.stderr, "skipping upload" | 323 | print("skipping upload", file=sys.stderr) |
321 | branch.uploaded = False | 324 | branch.uploaded = False |
322 | branch.error = 'User aborted' | 325 | branch.error = 'User aborted' |
323 | continue | 326 | continue |
@@ -334,8 +337,8 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
334 | branch.uploaded = False | 337 | branch.uploaded = False |
335 | have_errors = True | 338 | have_errors = True |
336 | 339 | ||
337 | print >>sys.stderr, '' | 340 | print(file=sys.stderr) |
338 | print >>sys.stderr, '----------------------------------------------------------------------' | 341 | print('----------------------------------------------------------------------', file=sys.stderr) |
339 | 342 | ||
340 | if have_errors: | 343 | if have_errors: |
341 | for branch in todo: | 344 | for branch in todo: |
@@ -344,17 +347,19 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
344 | fmt = ' (%s)' | 347 | fmt = ' (%s)' |
345 | else: | 348 | else: |
346 | fmt = '\n (%s)' | 349 | fmt = '\n (%s)' |
347 | print >>sys.stderr, ('[FAILED] %-15s %-15s' + fmt) % ( | 350 | print(('[FAILED] %-15s %-15s' + fmt) % ( |
348 | branch.project.relpath + '/', \ | 351 | branch.project.relpath + '/', \ |
349 | branch.name, \ | 352 | branch.name, \ |
350 | str(branch.error)) | 353 | str(branch.error)), |
351 | print >>sys.stderr, '' | 354 | file=sys.stderr) |
355 | print() | ||
352 | 356 | ||
353 | for branch in todo: | 357 | for branch in todo: |
354 | if branch.uploaded: | 358 | if branch.uploaded: |
355 | print >>sys.stderr, '[OK ] %-15s %s' % ( | 359 | print('[OK ] %-15s %s' % ( |
356 | branch.project.relpath + '/', | 360 | branch.project.relpath + '/', |
357 | branch.name) | 361 | branch.name), |
362 | file=sys.stderr) | ||
358 | 363 | ||
359 | if have_errors: | 364 | if have_errors: |
360 | sys.exit(1) | 365 | sys.exit(1) |
@@ -385,7 +390,7 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
385 | try: | 390 | try: |
386 | hook.Run(opt.allow_all_hooks, project_list=pending_proj_names) | 391 | hook.Run(opt.allow_all_hooks, project_list=pending_proj_names) |
387 | except HookError as e: | 392 | except HookError as e: |
388 | print >>sys.stderr, "ERROR: %s" % str(e) | 393 | print("ERROR: %s" % str(e), file=sys.stderr) |
389 | return | 394 | return |
390 | 395 | ||
391 | if opt.reviewers: | 396 | if opt.reviewers: |
@@ -395,7 +400,7 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
395 | people = (reviewers,cc) | 400 | people = (reviewers,cc) |
396 | 401 | ||
397 | if not pending: | 402 | if not pending: |
398 | print >>sys.stdout, "no branches ready for upload" | 403 | print("no branches ready for upload", file=sys.stderr) |
399 | elif len(pending) == 1 and len(pending[0][1]) == 1: | 404 | elif len(pending) == 1 and len(pending[0][1]) == 1: |
400 | self._SingleBranch(opt, pending[0][1][0], people) | 405 | self._SingleBranch(opt, pending[0][1][0], people) |
401 | else: | 406 | else: |
diff --git a/subcmds/version.py b/subcmds/version.py index 243e3676..01b7fd8c 100644 --- a/subcmds/version.py +++ b/subcmds/version.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 sys | 17 | import sys |
17 | from command import Command, MirrorSafeCommand | 18 | from command import Command, MirrorSafeCommand |
18 | from git_command import git | 19 | from git_command import git |
@@ -32,12 +33,12 @@ class Version(Command, MirrorSafeCommand): | |||
32 | rp = self.manifest.repoProject | 33 | rp = self.manifest.repoProject |
33 | rem = rp.GetRemote(rp.remote.name) | 34 | rem = rp.GetRemote(rp.remote.name) |
34 | 35 | ||
35 | print 'repo version %s' % rp.work_git.describe(HEAD) | 36 | print('repo version %s' % rp.work_git.describe(HEAD)) |
36 | print ' (from %s)' % rem.url | 37 | print(' (from %s)' % rem.url) |
37 | 38 | ||
38 | if Version.wrapper_path is not None: | 39 | if Version.wrapper_path is not None: |
39 | print 'repo launcher version %s' % Version.wrapper_version | 40 | print('repo launcher version %s' % Version.wrapper_version) |
40 | print ' (from %s)' % Version.wrapper_path | 41 | print(' (from %s)' % Version.wrapper_path) |
41 | 42 | ||
42 | print git.version().strip() | 43 | print(git.version().strip()) |
43 | print 'Python %s' % sys.version | 44 | print('Python %s' % sys.version) |
@@ -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 sys | 17 | import sys |
17 | import os | 18 | import os |
18 | REPO_TRACE = 'REPO_TRACE' | 19 | REPO_TRACE = 'REPO_TRACE' |
@@ -31,4 +32,4 @@ def SetTrace(): | |||
31 | 32 | ||
32 | def Trace(fmt, *args): | 33 | def Trace(fmt, *args): |
33 | if IsTrace(): | 34 | if IsTrace(): |
34 | print >>sys.stderr, fmt % args | 35 | print(fmt % args, file=sys.stderr) |