summaryrefslogtreecommitdiffstats
path: root/subcmds
diff options
context:
space:
mode:
authorSarah Owens <sarato@inkylabs.com>2012-11-01 22:59:27 -0700
committerSarah Owens <sarato@inkylabs.com>2012-11-13 17:33:56 -0800
commitcecd1d864fc3cf02cf50d367111e0d0e173c5dc6 (patch)
treeb4f660400560dce21cd7a00ffe5a5d74b54bcb81 /subcmds
parentfc241240d828d7e8302dc0876608a9d27ae1cbc7 (diff)
downloadgit-repo-cecd1d864fc3cf02cf50d367111e0d0e173c5dc6.tar.gz
Change print statements to work in python3
This is part of a series of changes to introduce Python3 support. Change-Id: I373be5de7141aa127d7debdbce1df39148dbec32
Diffstat (limited to 'subcmds')
-rw-r--r--subcmds/abandon.py15
-rw-r--r--subcmds/branches.py3
-rw-r--r--subcmds/checkout.py8
-rw-r--r--subcmds/cherry_pick.py21
-rw-r--r--subcmds/download.py21
-rw-r--r--subcmds/forall.py3
-rw-r--r--subcmds/grep.py8
-rw-r--r--subcmds/help.py33
-rw-r--r--subcmds/init.py52
-rw-r--r--subcmds/list.py3
-rw-r--r--subcmds/manifest.py7
-rw-r--r--subcmds/overview.py7
-rw-r--r--subcmds/prune.py5
-rw-r--r--subcmds/rebase.py14
-rw-r--r--subcmds/selfupdate.py3
-rw-r--r--subcmds/stage.py5
-rw-r--r--subcmds/start.py10
-rw-r--r--subcmds/status.py2
-rw-r--r--subcmds/sync.py102
-rw-r--r--subcmds/upload.py41
-rw-r--r--subcmds/version.py13
21 files changed, 200 insertions, 176 deletions
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
16from __future__ import print_function
16import sys 17import sys
17from command import Command 18from command import Command
18from git_command import git 19from 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
16from __future__ import print_function
16import sys 17import sys
17from color import Coloring 18from color import Coloring
18from command import Command 19from 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
16from __future__ import print_function
16import sys 17import sys
17from command import Command 18from command import Command
18from progress import Progress 19from 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
16from __future__ import print_function
16import re 17import re
17import sys 18import sys
18from command import Command 19from 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'
84NOTE: When committing (please see above) and editing the commit message, 85 'message, please remove the old Change-Id-line and add:')
85please 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
16from __future__ import print_function
16import re 17import re
17import sys 18import 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
16from __future__ import print_function
16import fcntl 17import fcntl
17import re 18import re
18import os 19import 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
16from __future__ import print_function
16import sys 17import sys
17from color import Coloring 18from color import Coloring
18from command import PagedCommand 19from 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
16from __future__ import print_function
16import re 17import re
17import sys 18import sys
18from formatter import AbstractFormatter, DumbWriter 19from 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:')
36The 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"
54See '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:')
60The 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(
80See 'repo help <command>' for more information on a specific command. 76"See 'repo help <command>' for more information on a specific command.\n"
81See '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
16from __future__ import print_function
16import os 17import os
17import platform 18import platform
18import re 19import 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
16from __future__ import print_function
16import re 17import re
17 18
18from command import Command, MirrorSafeCommand 19from 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
16from __future__ import print_function
16import os 17import os
17import sys 18import 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
16from __future__ import print_function
16from color import Coloring 17from color import Coloring
17from command import PagedCommand 18from 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
16from __future__ import print_function
16from color import Coloring 17from color import Coloring
17from command import PagedCommand 18from 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
16from __future__ import print_function
16import sys 17import sys
17 18
18from command import Command 19from 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
16from __future__ import print_function
16from optparse import SUPPRESS_HELP 17from optparse import SUPPRESS_HELP
17import sys 18import 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
16from __future__ import print_function
16import sys 17import sys
17 18
18from color import Coloring 19from 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
106def _AddI(project): 107def _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
16from __future__ import print_function
16import sys 17import sys
17from command import Command 18from command import Command
18from git_config import IsId 19from 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
16from __future__ import print_function
16import netrc 17import netrc
17from optparse import SUPPRESS_HELP 18from optparse import SUPPRESS_HELP
18import os 19import 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'
394uncommitted 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
597def _PostRepoUpgrade(manifest, quiet=False): 603def _PostRepoUpgrade(manifest, quiet=False):
598 wrapper = WrapperModule() 604 wrapper = WrapperModule()
@@ -604,27 +610,28 @@ def _PostRepoUpgrade(manifest, quiet=False):
604 610
605def _PostRepoFetch(rp, no_repo_verify=False, verbose=False): 611def _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
622def _VerifyTag(project): 629def _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."""',
627warning: 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
16from __future__ import print_function
16import copy 17import copy
17import re 18import re
18import sys 19import sys
@@ -26,16 +27,18 @@ UNUSUAL_COMMIT_THRESHOLD = 5
26 27
27def _ConfirmManyUploads(multiple_branches=False): 28def _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
36def _die(fmt, *args): 39def _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
41def _SplitEmails(values): 44def _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
16from __future__ import print_function
16import sys 17import sys
17from command import Command, MirrorSafeCommand 18from command import Command, MirrorSafeCommand
18from git_command import git 19from 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)