mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
Coding style cleanup
Fix the following issues reported by pylint: C0321: More than one statement on a single line W0622: Redefining built-in 'name' W0612: Unused variable 'name' W0613: Unused argument 'name' W0102: Dangerous default value 'value' as argument W0105: String statement has no effect Also fixed a few cases of inconsistent indentation. Change-Id: Ie0db839e7c57d576cff12d8c055fe87030d00744
This commit is contained in:
parent
e3b1c45aeb
commit
8a68ff9605
21
color.py
21
color.py
@ -38,8 +38,11 @@ ATTRS = {None :-1,
|
||||
|
||||
RESET = "\033[m"
|
||||
|
||||
def is_color(s): return s in COLORS
|
||||
def is_attr(s): return s in ATTRS
|
||||
def is_color(s):
|
||||
return s in COLORS
|
||||
|
||||
def is_attr(s):
|
||||
return s in ATTRS
|
||||
|
||||
def _Color(fg = None, bg = None, attr = None):
|
||||
fg = COLORS[fg]
|
||||
@ -80,8 +83,8 @@ def _Color(fg = None, bg = None, attr = None):
|
||||
|
||||
|
||||
class Coloring(object):
|
||||
def __init__(self, config, type):
|
||||
self._section = 'color.%s' % type
|
||||
def __init__(self, config, section_type):
|
||||
self._section = 'color.%s' % section_type
|
||||
self._config = config
|
||||
self._out = sys.stdout
|
||||
|
||||
@ -126,8 +129,8 @@ class Coloring(object):
|
||||
if self._on:
|
||||
c = self._parse(opt, fg, bg, attr)
|
||||
def f(fmt, *args):
|
||||
str = fmt % args
|
||||
return ''.join([c, str, RESET])
|
||||
output = fmt % args
|
||||
return ''.join([c, output, RESET])
|
||||
return f
|
||||
else:
|
||||
def f(fmt, *args):
|
||||
@ -151,8 +154,10 @@ class Coloring(object):
|
||||
have_fg = False
|
||||
for a in v.split(' '):
|
||||
if is_color(a):
|
||||
if have_fg: bg = a
|
||||
else: fg = a
|
||||
if have_fg:
|
||||
bg = a
|
||||
else:
|
||||
fg = a
|
||||
elif is_attr(a):
|
||||
attr = a
|
||||
|
||||
|
@ -63,7 +63,7 @@ class Command(object):
|
||||
def GetProjects(self, args, missing_ok=False):
|
||||
"""A list of projects that match the arguments.
|
||||
"""
|
||||
all = self.manifest.projects
|
||||
all_projects = self.manifest.projects
|
||||
result = []
|
||||
|
||||
mp = self.manifest.manifestProject
|
||||
@ -74,7 +74,7 @@ class Command(object):
|
||||
groups = [x for x in re.split('[,\s]+', groups) if x]
|
||||
|
||||
if not args:
|
||||
for project in all.values():
|
||||
for project in all_projects.values():
|
||||
if ((missing_ok or project.Exists) and
|
||||
project.MatchesGroups(groups)):
|
||||
result.append(project)
|
||||
@ -82,14 +82,14 @@ class Command(object):
|
||||
by_path = None
|
||||
|
||||
for arg in args:
|
||||
project = all.get(arg)
|
||||
project = all_projects.get(arg)
|
||||
|
||||
if not project:
|
||||
path = os.path.abspath(arg).replace('\\', '/')
|
||||
|
||||
if not by_path:
|
||||
by_path = dict()
|
||||
for p in all.values():
|
||||
for p in all_projects.values():
|
||||
by_path[p.worktree] = p
|
||||
|
||||
if os.path.exists(path):
|
||||
|
4
error.py
4
error.py
@ -85,8 +85,8 @@ class RepoChangedException(Exception):
|
||||
repo or manifest repositories. In this special case we must
|
||||
use exec to re-execute repo with the new code and manifest.
|
||||
"""
|
||||
def __init__(self, extra_args=[]):
|
||||
self.extra_args = extra_args
|
||||
def __init__(self, extra_args=None):
|
||||
self.extra_args = extra_args or []
|
||||
|
||||
class HookError(Exception):
|
||||
"""Thrown if a 'repo-hook' could not be run.
|
||||
|
@ -56,16 +56,16 @@ class GitConfig(object):
|
||||
@classmethod
|
||||
def ForUser(cls):
|
||||
if cls._ForUser is None:
|
||||
cls._ForUser = cls(file = os.path.expanduser('~/.gitconfig'))
|
||||
cls._ForUser = cls(configfile = os.path.expanduser('~/.gitconfig'))
|
||||
return cls._ForUser
|
||||
|
||||
@classmethod
|
||||
def ForRepository(cls, gitdir, defaults=None):
|
||||
return cls(file = os.path.join(gitdir, 'config'),
|
||||
return cls(configfile = os.path.join(gitdir, 'config'),
|
||||
defaults = defaults)
|
||||
|
||||
def __init__(self, file, defaults=None, pickleFile=None):
|
||||
self.file = file
|
||||
def __init__(self, configfile, defaults=None, pickleFile=None):
|
||||
self.file = configfile
|
||||
self.defaults = defaults
|
||||
self._cache_dict = None
|
||||
self._section_dict = None
|
||||
@ -104,20 +104,20 @@ class GitConfig(object):
|
||||
return False
|
||||
return None
|
||||
|
||||
def GetString(self, name, all=False):
|
||||
def GetString(self, name, all_keys=False):
|
||||
"""Get the first value for a key, or None if it is not defined.
|
||||
|
||||
This configuration file is used first, if the key is not
|
||||
defined or all = True then the defaults are also searched.
|
||||
defined or all_keys = True then the defaults are also searched.
|
||||
"""
|
||||
try:
|
||||
v = self._cache[_key(name)]
|
||||
except KeyError:
|
||||
if self.defaults:
|
||||
return self.defaults.GetString(name, all = all)
|
||||
return self.defaults.GetString(name, all_keys = all_keys)
|
||||
v = []
|
||||
|
||||
if not all:
|
||||
if not all_keys:
|
||||
if v:
|
||||
return v[0]
|
||||
return None
|
||||
@ -125,7 +125,7 @@ class GitConfig(object):
|
||||
r = []
|
||||
r.extend(v)
|
||||
if self.defaults:
|
||||
r.extend(self.defaults.GetString(name, all = True))
|
||||
r.extend(self.defaults.GetString(name, all_keys = True))
|
||||
return r
|
||||
|
||||
def SetString(self, name, value):
|
||||
@ -526,7 +526,7 @@ class Remote(object):
|
||||
self.review = self._Get('review')
|
||||
self.projectname = self._Get('projectname')
|
||||
self.fetch = map(lambda x: RefSpec.FromString(x),
|
||||
self._Get('fetch', all=True))
|
||||
self._Get('fetch', all_keys=True))
|
||||
self._review_url = None
|
||||
|
||||
def _InsteadOf(self):
|
||||
@ -537,7 +537,7 @@ class Remote(object):
|
||||
|
||||
for url in urlList:
|
||||
key = "url." + url + ".insteadOf"
|
||||
insteadOfList = globCfg.GetString(key, all=True)
|
||||
insteadOfList = globCfg.GetString(key, all_keys=True)
|
||||
|
||||
for insteadOf in insteadOfList:
|
||||
if self.url.startswith(insteadOf) \
|
||||
@ -567,7 +567,7 @@ class Remote(object):
|
||||
if u.endswith('/ssh_info'):
|
||||
u = u[:len(u) - len('/ssh_info')]
|
||||
if not u.endswith('/'):
|
||||
u += '/'
|
||||
u += '/'
|
||||
http_url = u
|
||||
|
||||
if u in REVIEW_CACHE:
|
||||
@ -651,9 +651,9 @@ class Remote(object):
|
||||
key = 'remote.%s.%s' % (self.name, key)
|
||||
return self._config.SetString(key, value)
|
||||
|
||||
def _Get(self, key, all=False):
|
||||
def _Get(self, key, all_keys=False):
|
||||
key = 'remote.%s.%s' % (self.name, key)
|
||||
return self._config.GetString(key, all = all)
|
||||
return self._config.GetString(key, all_keys = all_keys)
|
||||
|
||||
|
||||
class Branch(object):
|
||||
@ -703,6 +703,6 @@ class Branch(object):
|
||||
key = 'branch.%s.%s' % (self.name, key)
|
||||
return self._config.SetString(key, value)
|
||||
|
||||
def _Get(self, key, all=False):
|
||||
def _Get(self, key, all_keys=False):
|
||||
key = 'branch.%s.%s' % (self.name, key)
|
||||
return self._config.GetString(key, all = all)
|
||||
return self._config.GetString(key, all_keys = all_keys)
|
||||
|
16
git_refs.py
16
git_refs.py
@ -115,10 +115,10 @@ class GitRefs(object):
|
||||
|
||||
line = line[:-1]
|
||||
p = line.split(' ')
|
||||
id = p[0]
|
||||
ref_id = p[0]
|
||||
name = p[1]
|
||||
|
||||
self._phyref[name] = id
|
||||
self._phyref[name] = ref_id
|
||||
finally:
|
||||
fd.close()
|
||||
self._mtime['packed-refs'] = mtime
|
||||
@ -144,18 +144,18 @@ class GitRefs(object):
|
||||
try:
|
||||
try:
|
||||
mtime = os.path.getmtime(path)
|
||||
id = fd.readline()
|
||||
ref_id = fd.readline()
|
||||
except:
|
||||
return
|
||||
finally:
|
||||
fd.close()
|
||||
|
||||
if not id:
|
||||
if not ref_id:
|
||||
return
|
||||
id = id[:-1]
|
||||
ref_id = ref_id[:-1]
|
||||
|
||||
if id.startswith('ref: '):
|
||||
self._symref[name] = id[5:]
|
||||
if ref_id.startswith('ref: '):
|
||||
self._symref[name] = ref_id[5:]
|
||||
else:
|
||||
self._phyref[name] = id
|
||||
self._phyref[name] = ref_id
|
||||
self._mtime[name] = mtime
|
||||
|
10
main.py
10
main.py
@ -88,7 +88,7 @@ class _Repo(object):
|
||||
glob = argv
|
||||
name = 'help'
|
||||
argv = []
|
||||
gopts, gargs = global_options.parse_args(glob)
|
||||
gopts, _gargs = global_options.parse_args(glob)
|
||||
|
||||
if gopts.trace:
|
||||
SetTrace()
|
||||
@ -182,8 +182,8 @@ def _CheckWrapperVersion(ver, repo_path):
|
||||
repo_path = '~/bin/repo'
|
||||
|
||||
if not ver:
|
||||
print >>sys.stderr, 'no --wrapper-version argument'
|
||||
sys.exit(1)
|
||||
print >>sys.stderr, 'no --wrapper-version argument'
|
||||
sys.exit(1)
|
||||
|
||||
exp = _CurrentWrapperVersion()
|
||||
ver = tuple(map(lambda x: int(x), ver.split('.')))
|
||||
@ -211,8 +211,8 @@ def _CheckWrapperVersion(ver, repo_path):
|
||||
|
||||
def _CheckRepoDir(dir):
|
||||
if not dir:
|
||||
print >>sys.stderr, 'no --repo-dir argument'
|
||||
sys.exit(1)
|
||||
print >>sys.stderr, 'no --repo-dir argument'
|
||||
sys.exit(1)
|
||||
|
||||
def _PruneOptions(argv, opt):
|
||||
i = 0
|
||||
|
@ -113,7 +113,7 @@ class XmlManifest(object):
|
||||
if os.path.exists(self.manifestFile):
|
||||
os.remove(self.manifestFile)
|
||||
os.symlink('manifests/%s' % name, self.manifestFile)
|
||||
except OSError, e:
|
||||
except OSError:
|
||||
raise ManifestParseError('cannot link manifest %s' % name)
|
||||
|
||||
def _RemoteToXml(self, r, doc, root):
|
||||
@ -589,7 +589,6 @@ class XmlManifest(object):
|
||||
groups.extend(set(default_groups).difference(groups))
|
||||
|
||||
if self.IsMirror:
|
||||
relpath = None
|
||||
worktree = None
|
||||
gitdir = os.path.join(self.topdir, '%s.git' % name)
|
||||
else:
|
||||
|
4
pager.py
4
pager.py
@ -74,11 +74,11 @@ def _BecomePager(pager):
|
||||
# ready works around a long-standing bug in popularly
|
||||
# available versions of 'less', a better 'more'.
|
||||
#
|
||||
a, b, c = select.select([0], [], [0])
|
||||
_a, _b, _c = select.select([0], [], [0])
|
||||
|
||||
os.environ['LESS'] = 'FRSX'
|
||||
|
||||
try:
|
||||
os.execvp(pager, [pager])
|
||||
except OSError, e:
|
||||
except OSError:
|
||||
os.execv('/bin/sh', ['sh', '-c', pager])
|
||||
|
119
project.py
119
project.py
@ -328,7 +328,6 @@ class RepoHook(object):
|
||||
HookError: Raised if the user doesn't approve and abort_if_user_denies
|
||||
was passed to the consturctor.
|
||||
"""
|
||||
hooks_dir = self._hooks_project.worktree
|
||||
hooks_config = self._hooks_project.config
|
||||
git_approval_key = 'repo.hooks.%s.approvedhash' % self._hook_type
|
||||
|
||||
@ -608,25 +607,24 @@ class Project(object):
|
||||
"""Get all existing local branches.
|
||||
"""
|
||||
current = self.CurrentBranch
|
||||
all = self._allrefs
|
||||
all_refs = self._allrefs
|
||||
heads = {}
|
||||
pubd = {}
|
||||
|
||||
for name, id in all.iteritems():
|
||||
for name, ref_id in all_refs.iteritems():
|
||||
if name.startswith(R_HEADS):
|
||||
name = name[len(R_HEADS):]
|
||||
b = self.GetBranch(name)
|
||||
b.current = name == current
|
||||
b.published = None
|
||||
b.revision = id
|
||||
b.revision = ref_id
|
||||
heads[name] = b
|
||||
|
||||
for name, id in all.iteritems():
|
||||
for name, ref_id in all_refs.iteritems():
|
||||
if name.startswith(R_PUB):
|
||||
name = name[len(R_PUB):]
|
||||
b = heads.get(name)
|
||||
if b:
|
||||
b.published = id
|
||||
b.published = ref_id
|
||||
|
||||
return heads
|
||||
|
||||
@ -785,40 +783,40 @@ class Project(object):
|
||||
|
||||
## Publish / Upload ##
|
||||
|
||||
def WasPublished(self, branch, all=None):
|
||||
def WasPublished(self, branch, all_refs=None):
|
||||
"""Was the branch published (uploaded) for code review?
|
||||
If so, returns the SHA-1 hash of the last published
|
||||
state for the branch.
|
||||
"""
|
||||
key = R_PUB + branch
|
||||
if all is None:
|
||||
if all_refs is None:
|
||||
try:
|
||||
return self.bare_git.rev_parse(key)
|
||||
except GitError:
|
||||
return None
|
||||
else:
|
||||
try:
|
||||
return all[key]
|
||||
return all_refs[key]
|
||||
except KeyError:
|
||||
return None
|
||||
|
||||
def CleanPublishedCache(self, all=None):
|
||||
def CleanPublishedCache(self, all_refs=None):
|
||||
"""Prunes any stale published refs.
|
||||
"""
|
||||
if all is None:
|
||||
all = self._allrefs
|
||||
if all_refs is None:
|
||||
all_refs = self._allrefs
|
||||
heads = set()
|
||||
canrm = {}
|
||||
for name, id in all.iteritems():
|
||||
for name, ref_id in all_refs.iteritems():
|
||||
if name.startswith(R_HEADS):
|
||||
heads.add(name)
|
||||
elif name.startswith(R_PUB):
|
||||
canrm[name] = id
|
||||
canrm[name] = ref_id
|
||||
|
||||
for name, id in canrm.iteritems():
|
||||
for name, ref_id in canrm.iteritems():
|
||||
n = name[len(R_PUB):]
|
||||
if R_HEADS + n not in heads:
|
||||
self.bare_git.DeleteRef(name, id)
|
||||
self.bare_git.DeleteRef(name, ref_id)
|
||||
|
||||
def GetUploadableBranches(self, selected_branch=None):
|
||||
"""List any branches which can be uploaded for review.
|
||||
@ -826,15 +824,15 @@ class Project(object):
|
||||
heads = {}
|
||||
pubed = {}
|
||||
|
||||
for name, id in self._allrefs.iteritems():
|
||||
for name, ref_id in self._allrefs.iteritems():
|
||||
if name.startswith(R_HEADS):
|
||||
heads[name[len(R_HEADS):]] = id
|
||||
heads[name[len(R_HEADS):]] = ref_id
|
||||
elif name.startswith(R_PUB):
|
||||
pubed[name[len(R_PUB):]] = id
|
||||
pubed[name[len(R_PUB):]] = ref_id
|
||||
|
||||
ready = []
|
||||
for branch, id in heads.iteritems():
|
||||
if branch in pubed and pubed[branch] == id:
|
||||
for branch, ref_id in heads.iteritems():
|
||||
if branch in pubed and pubed[branch] == ref_id:
|
||||
continue
|
||||
if selected_branch and branch != selected_branch:
|
||||
continue
|
||||
@ -978,18 +976,18 @@ class Project(object):
|
||||
self._InitHooks()
|
||||
|
||||
def _CopyFiles(self):
|
||||
for file in self.copyfiles:
|
||||
file._Copy()
|
||||
for copyfile in self.copyfiles:
|
||||
copyfile._Copy()
|
||||
|
||||
def GetRevisionId(self, all=None):
|
||||
def GetRevisionId(self, all_refs=None):
|
||||
if self.revisionId:
|
||||
return self.revisionId
|
||||
|
||||
rem = self.GetRemote(self.remote.name)
|
||||
rev = rem.ToLocal(self.revisionExpr)
|
||||
|
||||
if all is not None and rev in all:
|
||||
return all[rev]
|
||||
if all_refs is not None and rev in all_refs:
|
||||
return all_refs[rev]
|
||||
|
||||
try:
|
||||
return self.bare_git.rev_parse('--verify', '%s^0' % rev)
|
||||
@ -1002,16 +1000,16 @@ class Project(object):
|
||||
"""Perform only the local IO portion of the sync process.
|
||||
Network access is not required.
|
||||
"""
|
||||
all = self.bare_ref.all
|
||||
self.CleanPublishedCache(all)
|
||||
revid = self.GetRevisionId(all)
|
||||
all_refs = self.bare_ref.all
|
||||
self.CleanPublishedCache(all_refs)
|
||||
revid = self.GetRevisionId(all_refs)
|
||||
|
||||
self._InitWorkTree()
|
||||
head = self.work_git.GetHead()
|
||||
if head.startswith(R_HEADS):
|
||||
branch = head[len(R_HEADS):]
|
||||
try:
|
||||
head = all[head]
|
||||
head = all_refs[head]
|
||||
except KeyError:
|
||||
head = None
|
||||
else:
|
||||
@ -1067,7 +1065,7 @@ class Project(object):
|
||||
return
|
||||
|
||||
upstream_gain = self._revlist(not_rev(HEAD), revid)
|
||||
pub = self.WasPublished(branch.name, all)
|
||||
pub = self.WasPublished(branch.name, all_refs)
|
||||
if pub:
|
||||
not_merged = self._revlist(not_rev(revid), pub)
|
||||
if not_merged:
|
||||
@ -1190,8 +1188,8 @@ class Project(object):
|
||||
if head == (R_HEADS + name):
|
||||
return True
|
||||
|
||||
all = self.bare_ref.all
|
||||
if (R_HEADS + name) in all:
|
||||
all_refs = self.bare_ref.all
|
||||
if (R_HEADS + name) in all_refs:
|
||||
return GitCommand(self,
|
||||
['checkout', name, '--'],
|
||||
capture_stdout = True,
|
||||
@ -1200,11 +1198,11 @@ class Project(object):
|
||||
branch = self.GetBranch(name)
|
||||
branch.remote = self.GetRemote(self.remote.name)
|
||||
branch.merge = self.revisionExpr
|
||||
revid = self.GetRevisionId(all)
|
||||
revid = self.GetRevisionId(all_refs)
|
||||
|
||||
if head.startswith(R_HEADS):
|
||||
try:
|
||||
head = all[head]
|
||||
head = all_refs[head]
|
||||
except KeyError:
|
||||
head = None
|
||||
|
||||
@ -1245,9 +1243,9 @@ class Project(object):
|
||||
#
|
||||
return True
|
||||
|
||||
all = self.bare_ref.all
|
||||
all_refs = self.bare_ref.all
|
||||
try:
|
||||
revid = all[rev]
|
||||
revid = all_refs[rev]
|
||||
except KeyError:
|
||||
# Branch does not exist in this project
|
||||
#
|
||||
@ -1255,7 +1253,7 @@ class Project(object):
|
||||
|
||||
if head.startswith(R_HEADS):
|
||||
try:
|
||||
head = all[head]
|
||||
head = all_refs[head]
|
||||
except KeyError:
|
||||
head = None
|
||||
|
||||
@ -1283,8 +1281,8 @@ class Project(object):
|
||||
didn't exist.
|
||||
"""
|
||||
rev = R_HEADS + name
|
||||
all = self.bare_ref.all
|
||||
if rev not in all:
|
||||
all_refs = self.bare_ref.all
|
||||
if rev not in all_refs:
|
||||
# Doesn't exist
|
||||
return None
|
||||
|
||||
@ -1293,9 +1291,9 @@ class Project(object):
|
||||
# We can't destroy the branch while we are sitting
|
||||
# on it. Switch to a detached HEAD.
|
||||
#
|
||||
head = all[head]
|
||||
head = all_refs[head]
|
||||
|
||||
revid = self.GetRevisionId(all)
|
||||
revid = self.GetRevisionId(all_refs)
|
||||
if head == revid:
|
||||
_lwrite(os.path.join(self.worktree, '.git', HEAD),
|
||||
'%s\n' % revid)
|
||||
@ -1412,33 +1410,33 @@ class Project(object):
|
||||
packed_refs = os.path.join(self.gitdir, 'packed-refs')
|
||||
remote = self.GetRemote(name)
|
||||
|
||||
all = self.bare_ref.all
|
||||
ids = set(all.values())
|
||||
all_refs = self.bare_ref.all
|
||||
ids = set(all_refs.values())
|
||||
tmp = set()
|
||||
|
||||
for r, id in GitRefs(ref_dir).all.iteritems():
|
||||
if r not in all:
|
||||
for r, ref_id in GitRefs(ref_dir).all.iteritems():
|
||||
if r not in all_refs:
|
||||
if r.startswith(R_TAGS) or remote.WritesTo(r):
|
||||
all[r] = id
|
||||
ids.add(id)
|
||||
all_refs[r] = ref_id
|
||||
ids.add(ref_id)
|
||||
continue
|
||||
|
||||
if id in ids:
|
||||
if ref_id in ids:
|
||||
continue
|
||||
|
||||
r = 'refs/_alt/%s' % id
|
||||
all[r] = id
|
||||
ids.add(id)
|
||||
r = 'refs/_alt/%s' % ref_id
|
||||
all_refs[r] = ref_id
|
||||
ids.add(ref_id)
|
||||
tmp.add(r)
|
||||
|
||||
ref_names = list(all.keys())
|
||||
ref_names = list(all_refs.keys())
|
||||
ref_names.sort()
|
||||
|
||||
tmp_packed = ''
|
||||
old_packed = ''
|
||||
|
||||
for r in ref_names:
|
||||
line = '%s %s\n' % (all[r], r)
|
||||
line = '%s %s\n' % (all_refs[r], r)
|
||||
tmp_packed += line
|
||||
if r not in tmp:
|
||||
old_packed += line
|
||||
@ -1477,7 +1475,7 @@ class Project(object):
|
||||
cmd.append((u'+refs/heads/%s:' % branch) + remote.ToLocal('refs/heads/%s' % branch))
|
||||
|
||||
ok = False
|
||||
for i in range(2):
|
||||
for _i in range(2):
|
||||
ret = GitCommand(self, cmd, bare=True, ssh_proxy=ssh_proxy).Wait()
|
||||
if ret == 0:
|
||||
ok = True
|
||||
@ -2034,7 +2032,7 @@ class _Later(object):
|
||||
self.action()
|
||||
out.nl()
|
||||
return True
|
||||
except GitError, e:
|
||||
except GitError:
|
||||
out.nl()
|
||||
return False
|
||||
|
||||
@ -2104,7 +2102,6 @@ class MetaProject(Project):
|
||||
"""A special project housed under .repo.
|
||||
"""
|
||||
def __init__(self, manifest, name, gitdir, worktree):
|
||||
repodir = manifest.repodir
|
||||
Project.__init__(self,
|
||||
manifest = manifest,
|
||||
name = name,
|
||||
@ -2156,12 +2153,12 @@ class MetaProject(Project):
|
||||
if not self.remote or not self.revisionExpr:
|
||||
return False
|
||||
|
||||
all = self.bare_ref.all
|
||||
revid = self.GetRevisionId(all)
|
||||
all_refs = self.bare_ref.all
|
||||
revid = self.GetRevisionId(all_refs)
|
||||
head = self.work_git.GetHead()
|
||||
if head.startswith(R_HEADS):
|
||||
try:
|
||||
head = all[head]
|
||||
head = all_refs[head]
|
||||
except KeyError:
|
||||
head = None
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 == '':
|
||||
@ -328,9 +326,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)
|
||||
|
@ -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',
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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)'
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user