summaryrefslogtreecommitdiffstats
path: root/subcmds
diff options
context:
space:
mode:
authorConley Owens <cco3@android.com>2012-10-09 14:29:46 -0700
committerGerrit Code Review <noreply-gerritcodereview@google.com>2012-10-09 14:29:46 -0700
commit3a6cd4200e42fbb5a21b3fb8d3c9738c0320cc63 (patch)
tree68ae5094d6530453887fb35a73fd5fa55f55a034 /subcmds
parent25f17682ca4ecd8acc887462d4bebc7c429cf110 (diff)
parent8a68ff96057ec58e524a3e41a2d8dca7b5d016bc (diff)
downloadgit-repo-3a6cd4200e42fbb5a21b3fb8d3c9738c0320cc63.tar.gz
Merge "Coding style cleanup"
Diffstat (limited to 'subcmds')
-rw-r--r--subcmds/branches.py8
-rw-r--r--subcmds/forall.py7
-rw-r--r--subcmds/help.py6
-rw-r--r--subcmds/init.py8
-rw-r--r--subcmds/manifest.py6
-rw-r--r--subcmds/overview.py10
-rw-r--r--subcmds/prune.py10
-rw-r--r--subcmds/rebase.py6
-rw-r--r--subcmds/stage.py14
-rw-r--r--subcmds/start.py6
-rw-r--r--subcmds/status.py8
-rw-r--r--subcmds/sync.py13
-rw-r--r--subcmds/upload.py20
13 files changed, 58 insertions, 64 deletions
diff --git a/subcmds/branches.py b/subcmds/branches.py
index a4f8d360..81aa5b18 100644
--- a/subcmds/branches.py
+++ b/subcmds/branches.py
@@ -140,12 +140,12 @@ is shown, then the branch appears in all projects.
140 fmt = out.write 140 fmt = out.write
141 paths = [] 141 paths = []
142 if in_cnt < project_cnt - in_cnt: 142 if in_cnt < project_cnt - in_cnt:
143 type = 'in' 143 in_type = 'in'
144 for b in i.projects: 144 for b in i.projects:
145 paths.append(b.project.relpath) 145 paths.append(b.project.relpath)
146 else: 146 else:
147 fmt = out.notinproject 147 fmt = out.notinproject
148 type = 'not in' 148 in_type = 'not in'
149 have = set() 149 have = set()
150 for b in i.projects: 150 for b in i.projects:
151 have.add(b.project) 151 have.add(b.project)
@@ -153,11 +153,11 @@ is shown, then the branch appears in all projects.
153 if not p in have: 153 if not p in have:
154 paths.append(p.relpath) 154 paths.append(p.relpath)
155 155
156 s = ' %s %s' % (type, ', '.join(paths)) 156 s = ' %s %s' % (in_type, ', '.join(paths))
157 if width + 7 + len(s) < 80: 157 if width + 7 + len(s) < 80:
158 fmt(s) 158 fmt(s)
159 else: 159 else:
160 fmt(' %s:' % type) 160 fmt(' %s:' % in_type)
161 for p in paths: 161 for p in paths:
162 out.nl() 162 out.nl()
163 fmt(width*' ' + ' %s' % p) 163 fmt(width*' ' + ' %s' % p)
diff --git a/subcmds/forall.py b/subcmds/forall.py
index 9436f4e5..76a02688 100644
--- a/subcmds/forall.py
+++ b/subcmds/forall.py
@@ -208,7 +208,6 @@ terminal and are not redirected.
208 return self.fd.fileno() 208 return self.fd.fileno()
209 209
210 empty = True 210 empty = True
211 didout = False
212 errbuf = '' 211 errbuf = ''
213 212
214 p.stdin.close() 213 p.stdin.close()
@@ -220,7 +219,7 @@ terminal and are not redirected.
220 fcntl.fcntl(s.fd, fcntl.F_SETFL, flags | os.O_NONBLOCK) 219 fcntl.fcntl(s.fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
221 220
222 while s_in: 221 while s_in:
223 in_ready, out_ready, err_ready = select.select(s_in, [], []) 222 in_ready, _out_ready, _err_ready = select.select(s_in, [], [])
224 for s in in_ready: 223 for s in in_ready:
225 buf = s.fd.read(4096) 224 buf = s.fd.read(4096)
226 if not buf: 225 if not buf:
@@ -229,9 +228,7 @@ terminal and are not redirected.
229 continue 228 continue
230 229
231 if not opt.verbose: 230 if not opt.verbose:
232 if s.fd == p.stdout: 231 if s.fd != p.stdout:
233 didout = True
234 else:
235 errbuf += buf 232 errbuf += buf
236 continue 233 continue
237 234
diff --git a/subcmds/help.py b/subcmds/help.py
index 0df3c14b..375d04d2 100644
--- a/subcmds/help.py
+++ b/subcmds/help.py
@@ -120,8 +120,8 @@ See 'repo help --all' for a complete list of recognized commands.
120 m = asciidoc_hdr.match(para) 120 m = asciidoc_hdr.match(para)
121 if m: 121 if m:
122 title = m.group(1) 122 title = m.group(1)
123 type = m.group(2) 123 section_type = m.group(2)
124 if type[0] in ('=', '-'): 124 if section_type[0] in ('=', '-'):
125 p = self.heading 125 p = self.heading
126 else: 126 else:
127 def _p(fmt, *args): 127 def _p(fmt, *args):
@@ -131,7 +131,7 @@ See 'repo help --all' for a complete list of recognized commands.
131 131
132 p('%s', title) 132 p('%s', title)
133 self.nl() 133 self.nl()
134 p('%s', ''.ljust(len(title),type[0])) 134 p('%s', ''.ljust(len(title),section_type[0]))
135 self.nl() 135 self.nl()
136 continue 136 continue
137 137
diff --git a/subcmds/init.py b/subcmds/init.py
index 9a9317e4..007667e2 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -213,8 +213,6 @@ to update the working directory files.
213 sys.exit(1) 213 sys.exit(1)
214 214
215 def _Prompt(self, prompt, value): 215 def _Prompt(self, prompt, value):
216 mp = self.manifest.manifestProject
217
218 sys.stdout.write('%-10s [%s]: ' % (prompt, value)) 216 sys.stdout.write('%-10s [%s]: ' % (prompt, value))
219 a = sys.stdin.readline().strip() 217 a = sys.stdin.readline().strip()
220 if a == '': 218 if a == '':
@@ -332,9 +330,9 @@ to update the working directory files.
332 self._ConfigureDepth(opt) 330 self._ConfigureDepth(opt)
333 331
334 if self.manifest.IsMirror: 332 if self.manifest.IsMirror:
335 type = 'mirror ' 333 init_type = 'mirror '
336 else: 334 else:
337 type = '' 335 init_type = ''
338 336
339 print '' 337 print ''
340 print 'repo %sinitialized in %s' % (type, self.manifest.topdir) 338 print 'repo %sinitialized in %s' % (init_type, self.manifest.topdir)
diff --git a/subcmds/manifest.py b/subcmds/manifest.py
index 43887654..5592a37d 100644
--- a/subcmds/manifest.py
+++ b/subcmds/manifest.py
@@ -35,14 +35,14 @@ in a Git repository for use during future 'repo init' invocations.
35 35
36 @property 36 @property
37 def helpDescription(self): 37 def helpDescription(self):
38 help = self._helpDescription + '\n' 38 helptext = self._helpDescription + '\n'
39 r = os.path.dirname(__file__) 39 r = os.path.dirname(__file__)
40 r = os.path.dirname(r) 40 r = os.path.dirname(r)
41 fd = open(os.path.join(r, 'docs', 'manifest-format.txt')) 41 fd = open(os.path.join(r, 'docs', 'manifest-format.txt'))
42 for line in fd: 42 for line in fd:
43 help += line 43 helptext += line
44 fd.close() 44 fd.close()
45 return help 45 return helptext
46 46
47 def _Options(self, p): 47 def _Options(self, p):
48 p.add_option('-r', '--revision-as-HEAD', 48 p.add_option('-r', '--revision-as-HEAD',
diff --git a/subcmds/overview.py b/subcmds/overview.py
index 96fa93d8..a509bd9a 100644
--- a/subcmds/overview.py
+++ b/subcmds/overview.py
@@ -38,16 +38,16 @@ are displayed.
38 help="Consider only checked out branches") 38 help="Consider only checked out branches")
39 39
40 def Execute(self, opt, args): 40 def Execute(self, opt, args):
41 all = [] 41 all_branches = []
42 for project in self.GetProjects(args): 42 for project in self.GetProjects(args):
43 br = [project.GetUploadableBranch(x) 43 br = [project.GetUploadableBranch(x)
44 for x in project.GetBranches().keys()] 44 for x in project.GetBranches().keys()]
45 br = [x for x in br if x] 45 br = [x for x in br if x]
46 if opt.current_branch: 46 if opt.current_branch:
47 br = [x for x in br if x.name == project.CurrentBranch] 47 br = [x for x in br if x.name == project.CurrentBranch]
48 all.extend(br) 48 all_branches.extend(br)
49 49
50 if not all: 50 if not all_branches:
51 return 51 return
52 52
53 class Report(Coloring): 53 class Report(Coloring):
@@ -55,13 +55,13 @@ are displayed.
55 Coloring.__init__(self, config, 'status') 55 Coloring.__init__(self, config, 'status')
56 self.project = self.printer('header', attr='bold') 56 self.project = self.printer('header', attr='bold')
57 57
58 out = Report(all[0].project.config) 58 out = Report(all_branches[0].project.config)
59 out.project('Projects Overview') 59 out.project('Projects Overview')
60 out.nl() 60 out.nl()
61 61
62 project = None 62 project = None
63 63
64 for branch in all: 64 for branch in all_branches:
65 if project != branch.project: 65 if project != branch.project:
66 project = branch.project 66 project = branch.project
67 out.nl() 67 out.nl()
diff --git a/subcmds/prune.py b/subcmds/prune.py
index f412bd48..c50a5507 100644
--- a/subcmds/prune.py
+++ b/subcmds/prune.py
@@ -24,11 +24,11 @@ class Prune(PagedCommand):
24""" 24"""
25 25
26 def Execute(self, opt, args): 26 def Execute(self, opt, args):
27 all = [] 27 all_branches = []
28 for project in self.GetProjects(args): 28 for project in self.GetProjects(args):
29 all.extend(project.PruneHeads()) 29 all_branches.extend(project.PruneHeads())
30 30
31 if not all: 31 if not all_branches:
32 return 32 return
33 33
34 class Report(Coloring): 34 class Report(Coloring):
@@ -36,13 +36,13 @@ class Prune(PagedCommand):
36 Coloring.__init__(self, config, 'status') 36 Coloring.__init__(self, config, 'status')
37 self.project = self.printer('header', attr='bold') 37 self.project = self.printer('header', attr='bold')
38 38
39 out = Report(all[0].project.config) 39 out = Report(all_branches[0].project.config)
40 out.project('Pending Branches') 40 out.project('Pending Branches')
41 out.nl() 41 out.nl()
42 42
43 project = None 43 project = None
44 44
45 for branch in all: 45 for branch in all_branches:
46 if project != branch.project: 46 if project != branch.project:
47 project = branch.project 47 project = branch.project
48 out.nl() 48 out.nl()
diff --git a/subcmds/rebase.py b/subcmds/rebase.py
index 2c1752d7..a8d58cdb 100644
--- a/subcmds/rebase.py
+++ b/subcmds/rebase.py
@@ -55,14 +55,14 @@ branch but need to incorporate new upstream changes "underneath" them.
55 help='Stash local modifications before starting') 55 help='Stash local modifications before starting')
56 56
57 def Execute(self, opt, args): 57 def Execute(self, opt, args):
58 all = self.GetProjects(args) 58 all_projects = self.GetProjects(args)
59 one_project = len(all) == 1 59 one_project = len(all_projects) == 1
60 60
61 if opt.interactive and not one_project: 61 if opt.interactive and not one_project:
62 print >>sys.stderr, 'error: interactive rebase not supported with multiple projects' 62 print >>sys.stderr, 'error: interactive rebase not supported with multiple projects'
63 return -1 63 return -1
64 64
65 for project in all: 65 for project in all_projects:
66 cb = project.CurrentBranch 66 cb = project.CurrentBranch
67 if not cb: 67 if not cb:
68 if one_project: 68 if one_project:
diff --git a/subcmds/stage.py b/subcmds/stage.py
index 4c221dba..2ec48069 100644
--- a/subcmds/stage.py
+++ b/subcmds/stage.py
@@ -48,8 +48,8 @@ The '%prog' command stages files to prepare the next commit.
48 self.Usage() 48 self.Usage()
49 49
50 def _Interactive(self, opt, args): 50 def _Interactive(self, opt, args):
51 all = filter(lambda x: x.IsDirty(), self.GetProjects(args)) 51 all_projects = filter(lambda x: x.IsDirty(), self.GetProjects(args))
52 if not all: 52 if not all_projects:
53 print >>sys.stderr,'no projects have uncommitted modifications' 53 print >>sys.stderr,'no projects have uncommitted modifications'
54 return 54 return
55 55
@@ -58,8 +58,8 @@ The '%prog' command stages files to prepare the next commit.
58 out.header(' %s', 'project') 58 out.header(' %s', 'project')
59 out.nl() 59 out.nl()
60 60
61 for i in xrange(0, len(all)): 61 for i in xrange(0, len(all_projects)):
62 p = all[i] 62 p = all_projects[i]
63 out.write('%3d: %s', i + 1, p.relpath + '/') 63 out.write('%3d: %s', i + 1, p.relpath + '/')
64 out.nl() 64 out.nl()
65 out.nl() 65 out.nl()
@@ -93,11 +93,11 @@ The '%prog' command stages files to prepare the next commit.
93 if a_index is not None: 93 if a_index is not None:
94 if a_index == 0: 94 if a_index == 0:
95 break 95 break
96 if 0 < a_index and a_index <= len(all): 96 if 0 < a_index and a_index <= len(all_projects):
97 _AddI(all[a_index - 1]) 97 _AddI(all_projects[a_index - 1])
98 continue 98 continue
99 99
100 p = filter(lambda x: x.name == a or x.relpath == a, all) 100 p = filter(lambda x: x.name == a or x.relpath == a, all_projects)
101 if len(p) == 1: 101 if len(p) == 1:
102 _AddI(p[0]) 102 _AddI(p[0])
103 continue 103 continue
diff --git a/subcmds/start.py b/subcmds/start.py
index 00885076..be645314 100644
--- a/subcmds/start.py
+++ b/subcmds/start.py
@@ -52,10 +52,10 @@ revision specified in the manifest.
52 print >>sys.stderr, "error: at least one project must be specified" 52 print >>sys.stderr, "error: at least one project must be specified"
53 sys.exit(1) 53 sys.exit(1)
54 54
55 all = self.GetProjects(projects) 55 all_projects = self.GetProjects(projects)
56 56
57 pm = Progress('Starting %s' % nb, len(all)) 57 pm = Progress('Starting %s' % nb, len(all_projects))
58 for project in all: 58 for project in all_projects:
59 pm.update() 59 pm.update()
60 # If the current revision is a specific SHA1 then we can't push back 60 # If the current revision is a specific SHA1 then we can't push back
61 # to it so substitute the manifest default revision instead. 61 # to it so substitute the manifest default revision instead.
diff --git a/subcmds/status.py b/subcmds/status.py
index 75d68ebc..7611621e 100644
--- a/subcmds/status.py
+++ b/subcmds/status.py
@@ -98,18 +98,18 @@ the following meanings:
98 sem.release() 98 sem.release()
99 99
100 def Execute(self, opt, args): 100 def Execute(self, opt, args):
101 all = self.GetProjects(args) 101 all_projects = self.GetProjects(args)
102 counter = itertools.count() 102 counter = itertools.count()
103 103
104 if opt.jobs == 1: 104 if opt.jobs == 1:
105 for project in all: 105 for project in all_projects:
106 state = project.PrintWorkTreeStatus() 106 state = project.PrintWorkTreeStatus()
107 if state == 'CLEAN': 107 if state == 'CLEAN':
108 counter.next() 108 counter.next()
109 else: 109 else:
110 sem = _threading.Semaphore(opt.jobs) 110 sem = _threading.Semaphore(opt.jobs)
111 threads_and_output = [] 111 threads_and_output = []
112 for project in all: 112 for project in all_projects:
113 sem.acquire() 113 sem.acquire()
114 114
115 class BufList(StringIO.StringIO): 115 class BufList(StringIO.StringIO):
@@ -128,5 +128,5 @@ the following meanings:
128 t.join() 128 t.join()
129 output.dump(sys.stdout) 129 output.dump(sys.stdout)
130 output.close() 130 output.close()
131 if len(all) == 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 b84d169f..1b716351 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -316,8 +316,7 @@ later is required to fix a server side protocol bug.
316 if not path: 316 if not path:
317 continue 317 continue
318 if path not in new_project_paths: 318 if path not in new_project_paths:
319 """If the path has already been deleted, we don't need to do it 319 # If the path has already been deleted, we don't need to do it
320 """
321 if os.path.exists(self.manifest.topdir + '/' + path): 320 if os.path.exists(self.manifest.topdir + '/' + path):
322 project = Project( 321 project = Project(
323 manifest = self.manifest, 322 manifest = self.manifest,
@@ -495,16 +494,16 @@ uncommitted changes are present' % project.relpath
495 self.manifest._Unload() 494 self.manifest._Unload()
496 if opt.jobs is None: 495 if opt.jobs is None:
497 self.jobs = self.manifest.default.sync_j 496 self.jobs = self.manifest.default.sync_j
498 all = self.GetProjects(args, missing_ok=True) 497 all_projects = self.GetProjects(args, missing_ok=True)
499 498
500 if not opt.local_only: 499 if not opt.local_only:
501 to_fetch = [] 500 to_fetch = []
502 now = time.time() 501 now = time.time()
503 if (24 * 60 * 60) <= (now - rp.LastFetch): 502 if (24 * 60 * 60) <= (now - rp.LastFetch):
504 to_fetch.append(rp) 503 to_fetch.append(rp)
505 to_fetch.extend(all) 504 to_fetch.extend(all_projects)
506 505
507 fetched = self._Fetch(to_fetch, opt) 506 self._Fetch(to_fetch, opt)
508 _PostRepoFetch(rp, opt.no_repo_verify) 507 _PostRepoFetch(rp, opt.no_repo_verify)
509 if opt.network_only: 508 if opt.network_only:
510 # bail out now; the rest touches the working tree 509 # bail out now; the rest touches the working tree
@@ -519,8 +518,8 @@ uncommitted changes are present' % project.relpath
519 518
520 syncbuf = SyncBuffer(mp.config, 519 syncbuf = SyncBuffer(mp.config,
521 detach_head = opt.detach_head) 520 detach_head = opt.detach_head)
522 pm = Progress('Syncing work tree', len(all)) 521 pm = Progress('Syncing work tree', len(all_projects))
523 for project in all: 522 for project in all_projects:
524 pm.update() 523 pm.update()
525 if project.worktree: 524 if project.worktree:
526 project.Sync_LocalHalf(syncbuf) 525 project.Sync_LocalHalf(syncbuf)
diff --git a/subcmds/upload.py b/subcmds/upload.py
index c9312973..685e3420 100644
--- a/subcmds/upload.py
+++ b/subcmds/upload.py
@@ -40,8 +40,8 @@ def _die(fmt, *args):
40 40
41def _SplitEmails(values): 41def _SplitEmails(values):
42 result = [] 42 result = []
43 for str in values: 43 for value in values:
44 result.extend([s.strip() for s in str.split(',')]) 44 result.extend([s.strip() for s in value.split(',')])
45 return result 45 return result
46 46
47class Upload(InteractiveCommand): 47class Upload(InteractiveCommand):
@@ -174,15 +174,15 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
174 174
175 if answer is None: 175 if answer is None:
176 date = branch.date 176 date = branch.date
177 list = branch.commits 177 commit_list = branch.commits
178 178
179 print 'Upload project %s/ to remote branch %s:' % (project.relpath, project.revisionExpr) 179 print 'Upload project %s/ to remote branch %s:' % (project.relpath, project.revisionExpr)
180 print ' branch %s (%2d commit%s, %s):' % ( 180 print ' branch %s (%2d commit%s, %s):' % (
181 name, 181 name,
182 len(list), 182 len(commit_list),
183 len(list) != 1 and 's' or '', 183 len(commit_list) != 1 and 's' or '',
184 date) 184 date)
185 for commit in list: 185 for commit in commit_list:
186 print ' %s' % commit 186 print ' %s' % commit
187 187
188 sys.stdout.write('to %s (y/N)? ' % remote.review) 188 sys.stdout.write('to %s (y/N)? ' % remote.review)
@@ -212,17 +212,17 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
212 for branch in avail: 212 for branch in avail:
213 name = branch.name 213 name = branch.name
214 date = branch.date 214 date = branch.date
215 list = branch.commits 215 commit_list = branch.commits
216 216
217 if b: 217 if b:
218 script.append('#') 218 script.append('#')
219 script.append('# branch %s (%2d commit%s, %s) to remote branch %s:' % ( 219 script.append('# branch %s (%2d commit%s, %s) to remote branch %s:' % (
220 name, 220 name,
221 len(list), 221 len(commit_list),
222 len(list) != 1 and 's' or '', 222 len(commit_list) != 1 and 's' or '',
223 date, 223 date,
224 project.revisionExpr)) 224 project.revisionExpr))
225 for commit in list: 225 for commit in commit_list:
226 script.append('# %s' % commit) 226 script.append('# %s' % commit)
227 b[name] = branch 227 b[name] = branch
228 228