Merge "Coding style cleanup"

This commit is contained in:
Conley Owens
2012-10-09 14:29:46 -07:00
committed by Gerrit Code Review
22 changed files with 167 additions and 172 deletions

View File

@ -140,12 +140,12 @@ is shown, then the branch appears in all projects.
fmt = out.write
paths = []
if in_cnt < project_cnt - in_cnt:
type = 'in'
in_type = 'in'
for b in i.projects:
paths.append(b.project.relpath)
else:
fmt = out.notinproject
type = 'not in'
in_type = 'not in'
have = set()
for b in i.projects:
have.add(b.project)
@ -153,11 +153,11 @@ is shown, then the branch appears in all projects.
if not p in have:
paths.append(p.relpath)
s = ' %s %s' % (type, ', '.join(paths))
s = ' %s %s' % (in_type, ', '.join(paths))
if width + 7 + len(s) < 80:
fmt(s)
else:
fmt(' %s:' % type)
fmt(' %s:' % in_type)
for p in paths:
out.nl()
fmt(width*' ' + ' %s' % p)

View File

@ -208,7 +208,6 @@ terminal and are not redirected.
return self.fd.fileno()
empty = True
didout = False
errbuf = ''
p.stdin.close()
@ -220,7 +219,7 @@ terminal and are not redirected.
fcntl.fcntl(s.fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
while s_in:
in_ready, out_ready, err_ready = select.select(s_in, [], [])
in_ready, _out_ready, _err_ready = select.select(s_in, [], [])
for s in in_ready:
buf = s.fd.read(4096)
if not buf:
@ -229,9 +228,7 @@ terminal and are not redirected.
continue
if not opt.verbose:
if s.fd == p.stdout:
didout = True
else:
if s.fd != p.stdout:
errbuf += buf
continue

View File

@ -120,8 +120,8 @@ See 'repo help --all' for a complete list of recognized commands.
m = asciidoc_hdr.match(para)
if m:
title = m.group(1)
type = m.group(2)
if type[0] in ('=', '-'):
section_type = m.group(2)
if section_type[0] in ('=', '-'):
p = self.heading
else:
def _p(fmt, *args):
@ -131,7 +131,7 @@ See 'repo help --all' for a complete list of recognized commands.
p('%s', title)
self.nl()
p('%s', ''.ljust(len(title),type[0]))
p('%s', ''.ljust(len(title),section_type[0]))
self.nl()
continue

View File

@ -213,8 +213,6 @@ to update the working directory files.
sys.exit(1)
def _Prompt(self, prompt, value):
mp = self.manifest.manifestProject
sys.stdout.write('%-10s [%s]: ' % (prompt, value))
a = sys.stdin.readline().strip()
if a == '':
@ -332,9 +330,9 @@ to update the working directory files.
self._ConfigureDepth(opt)
if self.manifest.IsMirror:
type = 'mirror '
init_type = 'mirror '
else:
type = ''
init_type = ''
print ''
print 'repo %sinitialized in %s' % (type, self.manifest.topdir)
print 'repo %sinitialized in %s' % (init_type, self.manifest.topdir)

View File

@ -35,14 +35,14 @@ in a Git repository for use during future 'repo init' invocations.
@property
def helpDescription(self):
help = self._helpDescription + '\n'
helptext = self._helpDescription + '\n'
r = os.path.dirname(__file__)
r = os.path.dirname(r)
fd = open(os.path.join(r, 'docs', 'manifest-format.txt'))
for line in fd:
help += line
helptext += line
fd.close()
return help
return helptext
def _Options(self, p):
p.add_option('-r', '--revision-as-HEAD',

View File

@ -38,16 +38,16 @@ are displayed.
help="Consider only checked out branches")
def Execute(self, opt, args):
all = []
all_branches = []
for project in self.GetProjects(args):
br = [project.GetUploadableBranch(x)
for x in project.GetBranches().keys()]
br = [x for x in br if x]
if opt.current_branch:
br = [x for x in br if x.name == project.CurrentBranch]
all.extend(br)
all_branches.extend(br)
if not all:
if not all_branches:
return
class Report(Coloring):
@ -55,13 +55,13 @@ are displayed.
Coloring.__init__(self, config, 'status')
self.project = self.printer('header', attr='bold')
out = Report(all[0].project.config)
out = Report(all_branches[0].project.config)
out.project('Projects Overview')
out.nl()
project = None
for branch in all:
for branch in all_branches:
if project != branch.project:
project = branch.project
out.nl()

View File

@ -24,11 +24,11 @@ class Prune(PagedCommand):
"""
def Execute(self, opt, args):
all = []
all_branches = []
for project in self.GetProjects(args):
all.extend(project.PruneHeads())
all_branches.extend(project.PruneHeads())
if not all:
if not all_branches:
return
class Report(Coloring):
@ -36,13 +36,13 @@ class Prune(PagedCommand):
Coloring.__init__(self, config, 'status')
self.project = self.printer('header', attr='bold')
out = Report(all[0].project.config)
out = Report(all_branches[0].project.config)
out.project('Pending Branches')
out.nl()
project = None
for branch in all:
for branch in all_branches:
if project != branch.project:
project = branch.project
out.nl()

View File

@ -55,14 +55,14 @@ branch but need to incorporate new upstream changes "underneath" them.
help='Stash local modifications before starting')
def Execute(self, opt, args):
all = self.GetProjects(args)
one_project = len(all) == 1
all_projects = self.GetProjects(args)
one_project = len(all_projects) == 1
if opt.interactive and not one_project:
print >>sys.stderr, 'error: interactive rebase not supported with multiple projects'
return -1
for project in all:
for project in all_projects:
cb = project.CurrentBranch
if not cb:
if one_project:

View File

@ -48,8 +48,8 @@ The '%prog' command stages files to prepare the next commit.
self.Usage()
def _Interactive(self, opt, args):
all = filter(lambda x: x.IsDirty(), self.GetProjects(args))
if not all:
all_projects = filter(lambda x: x.IsDirty(), self.GetProjects(args))
if not all_projects:
print >>sys.stderr,'no projects have uncommitted modifications'
return
@ -58,8 +58,8 @@ The '%prog' command stages files to prepare the next commit.
out.header(' %s', 'project')
out.nl()
for i in xrange(0, len(all)):
p = all[i]
for i in xrange(0, len(all_projects)):
p = all_projects[i]
out.write('%3d: %s', i + 1, p.relpath + '/')
out.nl()
out.nl()
@ -93,11 +93,11 @@ The '%prog' command stages files to prepare the next commit.
if a_index is not None:
if a_index == 0:
break
if 0 < a_index and a_index <= len(all):
_AddI(all[a_index - 1])
if 0 < a_index and a_index <= len(all_projects):
_AddI(all_projects[a_index - 1])
continue
p = filter(lambda x: x.name == a or x.relpath == a, all)
p = filter(lambda x: x.name == a or x.relpath == a, all_projects)
if len(p) == 1:
_AddI(p[0])
continue

View File

@ -52,10 +52,10 @@ revision specified in the manifest.
print >>sys.stderr, "error: at least one project must be specified"
sys.exit(1)
all = self.GetProjects(projects)
all_projects = self.GetProjects(projects)
pm = Progress('Starting %s' % nb, len(all))
for project in all:
pm = Progress('Starting %s' % nb, len(all_projects))
for project in all_projects:
pm.update()
# If the current revision is a specific SHA1 then we can't push back
# to it so substitute the manifest default revision instead.

View File

@ -98,18 +98,18 @@ the following meanings:
sem.release()
def Execute(self, opt, args):
all = self.GetProjects(args)
all_projects = self.GetProjects(args)
counter = itertools.count()
if opt.jobs == 1:
for project in all:
for project in all_projects:
state = project.PrintWorkTreeStatus()
if state == 'CLEAN':
counter.next()
else:
sem = _threading.Semaphore(opt.jobs)
threads_and_output = []
for project in all:
for project in all_projects:
sem.acquire()
class BufList(StringIO.StringIO):
@ -128,5 +128,5 @@ the following meanings:
t.join()
output.dump(sys.stdout)
output.close()
if len(all) == counter.next():
if len(all_projects) == counter.next():
print 'nothing to commit (working directory clean)'

View File

@ -316,8 +316,7 @@ later is required to fix a server side protocol bug.
if not path:
continue
if path not in new_project_paths:
"""If the path has already been deleted, we don't need to do it
"""
# If the path has already been deleted, we don't need to do it
if os.path.exists(self.manifest.topdir + '/' + path):
project = Project(
manifest = self.manifest,
@ -495,16 +494,16 @@ uncommitted changes are present' % project.relpath
self.manifest._Unload()
if opt.jobs is None:
self.jobs = self.manifest.default.sync_j
all = self.GetProjects(args, missing_ok=True)
all_projects = self.GetProjects(args, missing_ok=True)
if not opt.local_only:
to_fetch = []
now = time.time()
if (24 * 60 * 60) <= (now - rp.LastFetch):
to_fetch.append(rp)
to_fetch.extend(all)
to_fetch.extend(all_projects)
fetched = self._Fetch(to_fetch, opt)
self._Fetch(to_fetch, opt)
_PostRepoFetch(rp, opt.no_repo_verify)
if opt.network_only:
# bail out now; the rest touches the working tree
@ -519,8 +518,8 @@ uncommitted changes are present' % project.relpath
syncbuf = SyncBuffer(mp.config,
detach_head = opt.detach_head)
pm = Progress('Syncing work tree', len(all))
for project in all:
pm = Progress('Syncing work tree', len(all_projects))
for project in all_projects:
pm.update()
if project.worktree:
project.Sync_LocalHalf(syncbuf)

View File

@ -40,8 +40,8 @@ def _die(fmt, *args):
def _SplitEmails(values):
result = []
for str in values:
result.extend([s.strip() for s in str.split(',')])
for value in values:
result.extend([s.strip() for s in value.split(',')])
return result
class Upload(InteractiveCommand):
@ -174,15 +174,15 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
if answer is None:
date = branch.date
list = branch.commits
commit_list = branch.commits
print 'Upload project %s/ to remote branch %s:' % (project.relpath, project.revisionExpr)
print ' branch %s (%2d commit%s, %s):' % (
name,
len(list),
len(list) != 1 and 's' or '',
len(commit_list),
len(commit_list) != 1 and 's' or '',
date)
for commit in list:
for commit in commit_list:
print ' %s' % commit
sys.stdout.write('to %s (y/N)? ' % remote.review)
@ -212,17 +212,17 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
for branch in avail:
name = branch.name
date = branch.date
list = branch.commits
commit_list = branch.commits
if b:
script.append('#')
script.append('# branch %s (%2d commit%s, %s) to remote branch %s:' % (
name,
len(list),
len(list) != 1 and 's' or '',
len(commit_list),
len(commit_list) != 1 and 's' or '',
date,
project.revisionExpr))
for commit in list:
for commit in commit_list:
script.append('# %s' % commit)
b[name] = branch