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"
|
RESET = "\033[m"
|
||||||
|
|
||||||
def is_color(s): return s in COLORS
|
def is_color(s):
|
||||||
def is_attr(s): return s in ATTRS
|
return s in COLORS
|
||||||
|
|
||||||
|
def is_attr(s):
|
||||||
|
return s in ATTRS
|
||||||
|
|
||||||
def _Color(fg = None, bg = None, attr = None):
|
def _Color(fg = None, bg = None, attr = None):
|
||||||
fg = COLORS[fg]
|
fg = COLORS[fg]
|
||||||
@ -80,8 +83,8 @@ def _Color(fg = None, bg = None, attr = None):
|
|||||||
|
|
||||||
|
|
||||||
class Coloring(object):
|
class Coloring(object):
|
||||||
def __init__(self, config, type):
|
def __init__(self, config, section_type):
|
||||||
self._section = 'color.%s' % type
|
self._section = 'color.%s' % section_type
|
||||||
self._config = config
|
self._config = config
|
||||||
self._out = sys.stdout
|
self._out = sys.stdout
|
||||||
|
|
||||||
@ -126,8 +129,8 @@ class Coloring(object):
|
|||||||
if self._on:
|
if self._on:
|
||||||
c = self._parse(opt, fg, bg, attr)
|
c = self._parse(opt, fg, bg, attr)
|
||||||
def f(fmt, *args):
|
def f(fmt, *args):
|
||||||
str = fmt % args
|
output = fmt % args
|
||||||
return ''.join([c, str, RESET])
|
return ''.join([c, output, RESET])
|
||||||
return f
|
return f
|
||||||
else:
|
else:
|
||||||
def f(fmt, *args):
|
def f(fmt, *args):
|
||||||
@ -151,8 +154,10 @@ class Coloring(object):
|
|||||||
have_fg = False
|
have_fg = False
|
||||||
for a in v.split(' '):
|
for a in v.split(' '):
|
||||||
if is_color(a):
|
if is_color(a):
|
||||||
if have_fg: bg = a
|
if have_fg:
|
||||||
else: fg = a
|
bg = a
|
||||||
|
else:
|
||||||
|
fg = a
|
||||||
elif is_attr(a):
|
elif is_attr(a):
|
||||||
attr = a
|
attr = a
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class Command(object):
|
|||||||
def GetProjects(self, args, missing_ok=False):
|
def GetProjects(self, args, missing_ok=False):
|
||||||
"""A list of projects that match the arguments.
|
"""A list of projects that match the arguments.
|
||||||
"""
|
"""
|
||||||
all = self.manifest.projects
|
all_projects = self.manifest.projects
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
mp = self.manifest.manifestProject
|
mp = self.manifest.manifestProject
|
||||||
@ -74,7 +74,7 @@ class Command(object):
|
|||||||
groups = [x for x in re.split('[,\s]+', groups) if x]
|
groups = [x for x in re.split('[,\s]+', groups) if x]
|
||||||
|
|
||||||
if not args:
|
if not args:
|
||||||
for project in all.values():
|
for project in all_projects.values():
|
||||||
if ((missing_ok or project.Exists) and
|
if ((missing_ok or project.Exists) and
|
||||||
project.MatchesGroups(groups)):
|
project.MatchesGroups(groups)):
|
||||||
result.append(project)
|
result.append(project)
|
||||||
@ -82,14 +82,14 @@ class Command(object):
|
|||||||
by_path = None
|
by_path = None
|
||||||
|
|
||||||
for arg in args:
|
for arg in args:
|
||||||
project = all.get(arg)
|
project = all_projects.get(arg)
|
||||||
|
|
||||||
if not project:
|
if not project:
|
||||||
path = os.path.abspath(arg).replace('\\', '/')
|
path = os.path.abspath(arg).replace('\\', '/')
|
||||||
|
|
||||||
if not by_path:
|
if not by_path:
|
||||||
by_path = dict()
|
by_path = dict()
|
||||||
for p in all.values():
|
for p in all_projects.values():
|
||||||
by_path[p.worktree] = p
|
by_path[p.worktree] = p
|
||||||
|
|
||||||
if os.path.exists(path):
|
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
|
repo or manifest repositories. In this special case we must
|
||||||
use exec to re-execute repo with the new code and manifest.
|
use exec to re-execute repo with the new code and manifest.
|
||||||
"""
|
"""
|
||||||
def __init__(self, extra_args=[]):
|
def __init__(self, extra_args=None):
|
||||||
self.extra_args = extra_args
|
self.extra_args = extra_args or []
|
||||||
|
|
||||||
class HookError(Exception):
|
class HookError(Exception):
|
||||||
"""Thrown if a 'repo-hook' could not be run.
|
"""Thrown if a 'repo-hook' could not be run.
|
||||||
|
@ -56,16 +56,16 @@ class GitConfig(object):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def ForUser(cls):
|
def ForUser(cls):
|
||||||
if cls._ForUser is None:
|
if cls._ForUser is None:
|
||||||
cls._ForUser = cls(file = os.path.expanduser('~/.gitconfig'))
|
cls._ForUser = cls(configfile = os.path.expanduser('~/.gitconfig'))
|
||||||
return cls._ForUser
|
return cls._ForUser
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def ForRepository(cls, gitdir, defaults=None):
|
def ForRepository(cls, gitdir, defaults=None):
|
||||||
return cls(file = os.path.join(gitdir, 'config'),
|
return cls(configfile = os.path.join(gitdir, 'config'),
|
||||||
defaults = defaults)
|
defaults = defaults)
|
||||||
|
|
||||||
def __init__(self, file, defaults=None, pickleFile=None):
|
def __init__(self, configfile, defaults=None, pickleFile=None):
|
||||||
self.file = file
|
self.file = configfile
|
||||||
self.defaults = defaults
|
self.defaults = defaults
|
||||||
self._cache_dict = None
|
self._cache_dict = None
|
||||||
self._section_dict = None
|
self._section_dict = None
|
||||||
@ -104,20 +104,20 @@ class GitConfig(object):
|
|||||||
return False
|
return False
|
||||||
return None
|
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.
|
"""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
|
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:
|
try:
|
||||||
v = self._cache[_key(name)]
|
v = self._cache[_key(name)]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
if self.defaults:
|
if self.defaults:
|
||||||
return self.defaults.GetString(name, all = all)
|
return self.defaults.GetString(name, all_keys = all_keys)
|
||||||
v = []
|
v = []
|
||||||
|
|
||||||
if not all:
|
if not all_keys:
|
||||||
if v:
|
if v:
|
||||||
return v[0]
|
return v[0]
|
||||||
return None
|
return None
|
||||||
@ -125,7 +125,7 @@ class GitConfig(object):
|
|||||||
r = []
|
r = []
|
||||||
r.extend(v)
|
r.extend(v)
|
||||||
if self.defaults:
|
if self.defaults:
|
||||||
r.extend(self.defaults.GetString(name, all = True))
|
r.extend(self.defaults.GetString(name, all_keys = True))
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def SetString(self, name, value):
|
def SetString(self, name, value):
|
||||||
@ -526,7 +526,7 @@ class Remote(object):
|
|||||||
self.review = self._Get('review')
|
self.review = self._Get('review')
|
||||||
self.projectname = self._Get('projectname')
|
self.projectname = self._Get('projectname')
|
||||||
self.fetch = map(lambda x: RefSpec.FromString(x),
|
self.fetch = map(lambda x: RefSpec.FromString(x),
|
||||||
self._Get('fetch', all=True))
|
self._Get('fetch', all_keys=True))
|
||||||
self._review_url = None
|
self._review_url = None
|
||||||
|
|
||||||
def _InsteadOf(self):
|
def _InsteadOf(self):
|
||||||
@ -537,7 +537,7 @@ class Remote(object):
|
|||||||
|
|
||||||
for url in urlList:
|
for url in urlList:
|
||||||
key = "url." + url + ".insteadOf"
|
key = "url." + url + ".insteadOf"
|
||||||
insteadOfList = globCfg.GetString(key, all=True)
|
insteadOfList = globCfg.GetString(key, all_keys=True)
|
||||||
|
|
||||||
for insteadOf in insteadOfList:
|
for insteadOf in insteadOfList:
|
||||||
if self.url.startswith(insteadOf) \
|
if self.url.startswith(insteadOf) \
|
||||||
@ -651,9 +651,9 @@ class Remote(object):
|
|||||||
key = 'remote.%s.%s' % (self.name, key)
|
key = 'remote.%s.%s' % (self.name, key)
|
||||||
return self._config.SetString(key, value)
|
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)
|
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):
|
class Branch(object):
|
||||||
@ -703,6 +703,6 @@ class Branch(object):
|
|||||||
key = 'branch.%s.%s' % (self.name, key)
|
key = 'branch.%s.%s' % (self.name, key)
|
||||||
return self._config.SetString(key, value)
|
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)
|
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]
|
line = line[:-1]
|
||||||
p = line.split(' ')
|
p = line.split(' ')
|
||||||
id = p[0]
|
ref_id = p[0]
|
||||||
name = p[1]
|
name = p[1]
|
||||||
|
|
||||||
self._phyref[name] = id
|
self._phyref[name] = ref_id
|
||||||
finally:
|
finally:
|
||||||
fd.close()
|
fd.close()
|
||||||
self._mtime['packed-refs'] = mtime
|
self._mtime['packed-refs'] = mtime
|
||||||
@ -144,18 +144,18 @@ class GitRefs(object):
|
|||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
mtime = os.path.getmtime(path)
|
mtime = os.path.getmtime(path)
|
||||||
id = fd.readline()
|
ref_id = fd.readline()
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
finally:
|
finally:
|
||||||
fd.close()
|
fd.close()
|
||||||
|
|
||||||
if not id:
|
if not ref_id:
|
||||||
return
|
return
|
||||||
id = id[:-1]
|
ref_id = ref_id[:-1]
|
||||||
|
|
||||||
if id.startswith('ref: '):
|
if ref_id.startswith('ref: '):
|
||||||
self._symref[name] = id[5:]
|
self._symref[name] = ref_id[5:]
|
||||||
else:
|
else:
|
||||||
self._phyref[name] = id
|
self._phyref[name] = ref_id
|
||||||
self._mtime[name] = mtime
|
self._mtime[name] = mtime
|
||||||
|
2
main.py
2
main.py
@ -88,7 +88,7 @@ class _Repo(object):
|
|||||||
glob = argv
|
glob = argv
|
||||||
name = 'help'
|
name = 'help'
|
||||||
argv = []
|
argv = []
|
||||||
gopts, gargs = global_options.parse_args(glob)
|
gopts, _gargs = global_options.parse_args(glob)
|
||||||
|
|
||||||
if gopts.trace:
|
if gopts.trace:
|
||||||
SetTrace()
|
SetTrace()
|
||||||
|
@ -113,7 +113,7 @@ class XmlManifest(object):
|
|||||||
if os.path.exists(self.manifestFile):
|
if os.path.exists(self.manifestFile):
|
||||||
os.remove(self.manifestFile)
|
os.remove(self.manifestFile)
|
||||||
os.symlink('manifests/%s' % name, self.manifestFile)
|
os.symlink('manifests/%s' % name, self.manifestFile)
|
||||||
except OSError, e:
|
except OSError:
|
||||||
raise ManifestParseError('cannot link manifest %s' % name)
|
raise ManifestParseError('cannot link manifest %s' % name)
|
||||||
|
|
||||||
def _RemoteToXml(self, r, doc, root):
|
def _RemoteToXml(self, r, doc, root):
|
||||||
@ -589,7 +589,6 @@ class XmlManifest(object):
|
|||||||
groups.extend(set(default_groups).difference(groups))
|
groups.extend(set(default_groups).difference(groups))
|
||||||
|
|
||||||
if self.IsMirror:
|
if self.IsMirror:
|
||||||
relpath = None
|
|
||||||
worktree = None
|
worktree = None
|
||||||
gitdir = os.path.join(self.topdir, '%s.git' % name)
|
gitdir = os.path.join(self.topdir, '%s.git' % name)
|
||||||
else:
|
else:
|
||||||
|
4
pager.py
4
pager.py
@ -74,11 +74,11 @@ def _BecomePager(pager):
|
|||||||
# ready works around a long-standing bug in popularly
|
# ready works around a long-standing bug in popularly
|
||||||
# available versions of 'less', a better 'more'.
|
# 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'
|
os.environ['LESS'] = 'FRSX'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.execvp(pager, [pager])
|
os.execvp(pager, [pager])
|
||||||
except OSError, e:
|
except OSError:
|
||||||
os.execv('/bin/sh', ['sh', '-c', pager])
|
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
|
HookError: Raised if the user doesn't approve and abort_if_user_denies
|
||||||
was passed to the consturctor.
|
was passed to the consturctor.
|
||||||
"""
|
"""
|
||||||
hooks_dir = self._hooks_project.worktree
|
|
||||||
hooks_config = self._hooks_project.config
|
hooks_config = self._hooks_project.config
|
||||||
git_approval_key = 'repo.hooks.%s.approvedhash' % self._hook_type
|
git_approval_key = 'repo.hooks.%s.approvedhash' % self._hook_type
|
||||||
|
|
||||||
@ -608,25 +607,24 @@ class Project(object):
|
|||||||
"""Get all existing local branches.
|
"""Get all existing local branches.
|
||||||
"""
|
"""
|
||||||
current = self.CurrentBranch
|
current = self.CurrentBranch
|
||||||
all = self._allrefs
|
all_refs = self._allrefs
|
||||||
heads = {}
|
heads = {}
|
||||||
pubd = {}
|
|
||||||
|
|
||||||
for name, id in all.iteritems():
|
for name, ref_id in all_refs.iteritems():
|
||||||
if name.startswith(R_HEADS):
|
if name.startswith(R_HEADS):
|
||||||
name = name[len(R_HEADS):]
|
name = name[len(R_HEADS):]
|
||||||
b = self.GetBranch(name)
|
b = self.GetBranch(name)
|
||||||
b.current = name == current
|
b.current = name == current
|
||||||
b.published = None
|
b.published = None
|
||||||
b.revision = id
|
b.revision = ref_id
|
||||||
heads[name] = b
|
heads[name] = b
|
||||||
|
|
||||||
for name, id in all.iteritems():
|
for name, ref_id in all_refs.iteritems():
|
||||||
if name.startswith(R_PUB):
|
if name.startswith(R_PUB):
|
||||||
name = name[len(R_PUB):]
|
name = name[len(R_PUB):]
|
||||||
b = heads.get(name)
|
b = heads.get(name)
|
||||||
if b:
|
if b:
|
||||||
b.published = id
|
b.published = ref_id
|
||||||
|
|
||||||
return heads
|
return heads
|
||||||
|
|
||||||
@ -785,40 +783,40 @@ class Project(object):
|
|||||||
|
|
||||||
## Publish / Upload ##
|
## Publish / Upload ##
|
||||||
|
|
||||||
def WasPublished(self, branch, all=None):
|
def WasPublished(self, branch, all_refs=None):
|
||||||
"""Was the branch published (uploaded) for code review?
|
"""Was the branch published (uploaded) for code review?
|
||||||
If so, returns the SHA-1 hash of the last published
|
If so, returns the SHA-1 hash of the last published
|
||||||
state for the branch.
|
state for the branch.
|
||||||
"""
|
"""
|
||||||
key = R_PUB + branch
|
key = R_PUB + branch
|
||||||
if all is None:
|
if all_refs is None:
|
||||||
try:
|
try:
|
||||||
return self.bare_git.rev_parse(key)
|
return self.bare_git.rev_parse(key)
|
||||||
except GitError:
|
except GitError:
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
return all[key]
|
return all_refs[key]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def CleanPublishedCache(self, all=None):
|
def CleanPublishedCache(self, all_refs=None):
|
||||||
"""Prunes any stale published refs.
|
"""Prunes any stale published refs.
|
||||||
"""
|
"""
|
||||||
if all is None:
|
if all_refs is None:
|
||||||
all = self._allrefs
|
all_refs = self._allrefs
|
||||||
heads = set()
|
heads = set()
|
||||||
canrm = {}
|
canrm = {}
|
||||||
for name, id in all.iteritems():
|
for name, ref_id in all_refs.iteritems():
|
||||||
if name.startswith(R_HEADS):
|
if name.startswith(R_HEADS):
|
||||||
heads.add(name)
|
heads.add(name)
|
||||||
elif name.startswith(R_PUB):
|
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):]
|
n = name[len(R_PUB):]
|
||||||
if R_HEADS + n not in heads:
|
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):
|
def GetUploadableBranches(self, selected_branch=None):
|
||||||
"""List any branches which can be uploaded for review.
|
"""List any branches which can be uploaded for review.
|
||||||
@ -826,15 +824,15 @@ class Project(object):
|
|||||||
heads = {}
|
heads = {}
|
||||||
pubed = {}
|
pubed = {}
|
||||||
|
|
||||||
for name, id in self._allrefs.iteritems():
|
for name, ref_id in self._allrefs.iteritems():
|
||||||
if name.startswith(R_HEADS):
|
if name.startswith(R_HEADS):
|
||||||
heads[name[len(R_HEADS):]] = id
|
heads[name[len(R_HEADS):]] = ref_id
|
||||||
elif name.startswith(R_PUB):
|
elif name.startswith(R_PUB):
|
||||||
pubed[name[len(R_PUB):]] = id
|
pubed[name[len(R_PUB):]] = ref_id
|
||||||
|
|
||||||
ready = []
|
ready = []
|
||||||
for branch, id in heads.iteritems():
|
for branch, ref_id in heads.iteritems():
|
||||||
if branch in pubed and pubed[branch] == id:
|
if branch in pubed and pubed[branch] == ref_id:
|
||||||
continue
|
continue
|
||||||
if selected_branch and branch != selected_branch:
|
if selected_branch and branch != selected_branch:
|
||||||
continue
|
continue
|
||||||
@ -978,18 +976,18 @@ class Project(object):
|
|||||||
self._InitHooks()
|
self._InitHooks()
|
||||||
|
|
||||||
def _CopyFiles(self):
|
def _CopyFiles(self):
|
||||||
for file in self.copyfiles:
|
for copyfile in self.copyfiles:
|
||||||
file._Copy()
|
copyfile._Copy()
|
||||||
|
|
||||||
def GetRevisionId(self, all=None):
|
def GetRevisionId(self, all_refs=None):
|
||||||
if self.revisionId:
|
if self.revisionId:
|
||||||
return self.revisionId
|
return self.revisionId
|
||||||
|
|
||||||
rem = self.GetRemote(self.remote.name)
|
rem = self.GetRemote(self.remote.name)
|
||||||
rev = rem.ToLocal(self.revisionExpr)
|
rev = rem.ToLocal(self.revisionExpr)
|
||||||
|
|
||||||
if all is not None and rev in all:
|
if all_refs is not None and rev in all_refs:
|
||||||
return all[rev]
|
return all_refs[rev]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return self.bare_git.rev_parse('--verify', '%s^0' % rev)
|
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.
|
"""Perform only the local IO portion of the sync process.
|
||||||
Network access is not required.
|
Network access is not required.
|
||||||
"""
|
"""
|
||||||
all = self.bare_ref.all
|
all_refs = self.bare_ref.all
|
||||||
self.CleanPublishedCache(all)
|
self.CleanPublishedCache(all_refs)
|
||||||
revid = self.GetRevisionId(all)
|
revid = self.GetRevisionId(all_refs)
|
||||||
|
|
||||||
self._InitWorkTree()
|
self._InitWorkTree()
|
||||||
head = self.work_git.GetHead()
|
head = self.work_git.GetHead()
|
||||||
if head.startswith(R_HEADS):
|
if head.startswith(R_HEADS):
|
||||||
branch = head[len(R_HEADS):]
|
branch = head[len(R_HEADS):]
|
||||||
try:
|
try:
|
||||||
head = all[head]
|
head = all_refs[head]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
head = None
|
head = None
|
||||||
else:
|
else:
|
||||||
@ -1067,7 +1065,7 @@ class Project(object):
|
|||||||
return
|
return
|
||||||
|
|
||||||
upstream_gain = self._revlist(not_rev(HEAD), revid)
|
upstream_gain = self._revlist(not_rev(HEAD), revid)
|
||||||
pub = self.WasPublished(branch.name, all)
|
pub = self.WasPublished(branch.name, all_refs)
|
||||||
if pub:
|
if pub:
|
||||||
not_merged = self._revlist(not_rev(revid), pub)
|
not_merged = self._revlist(not_rev(revid), pub)
|
||||||
if not_merged:
|
if not_merged:
|
||||||
@ -1190,8 +1188,8 @@ class Project(object):
|
|||||||
if head == (R_HEADS + name):
|
if head == (R_HEADS + name):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
all = self.bare_ref.all
|
all_refs = self.bare_ref.all
|
||||||
if (R_HEADS + name) in all:
|
if (R_HEADS + name) in all_refs:
|
||||||
return GitCommand(self,
|
return GitCommand(self,
|
||||||
['checkout', name, '--'],
|
['checkout', name, '--'],
|
||||||
capture_stdout = True,
|
capture_stdout = True,
|
||||||
@ -1200,11 +1198,11 @@ class Project(object):
|
|||||||
branch = self.GetBranch(name)
|
branch = self.GetBranch(name)
|
||||||
branch.remote = self.GetRemote(self.remote.name)
|
branch.remote = self.GetRemote(self.remote.name)
|
||||||
branch.merge = self.revisionExpr
|
branch.merge = self.revisionExpr
|
||||||
revid = self.GetRevisionId(all)
|
revid = self.GetRevisionId(all_refs)
|
||||||
|
|
||||||
if head.startswith(R_HEADS):
|
if head.startswith(R_HEADS):
|
||||||
try:
|
try:
|
||||||
head = all[head]
|
head = all_refs[head]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
head = None
|
head = None
|
||||||
|
|
||||||
@ -1245,9 +1243,9 @@ class Project(object):
|
|||||||
#
|
#
|
||||||
return True
|
return True
|
||||||
|
|
||||||
all = self.bare_ref.all
|
all_refs = self.bare_ref.all
|
||||||
try:
|
try:
|
||||||
revid = all[rev]
|
revid = all_refs[rev]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# Branch does not exist in this project
|
# Branch does not exist in this project
|
||||||
#
|
#
|
||||||
@ -1255,7 +1253,7 @@ class Project(object):
|
|||||||
|
|
||||||
if head.startswith(R_HEADS):
|
if head.startswith(R_HEADS):
|
||||||
try:
|
try:
|
||||||
head = all[head]
|
head = all_refs[head]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
head = None
|
head = None
|
||||||
|
|
||||||
@ -1283,8 +1281,8 @@ class Project(object):
|
|||||||
didn't exist.
|
didn't exist.
|
||||||
"""
|
"""
|
||||||
rev = R_HEADS + name
|
rev = R_HEADS + name
|
||||||
all = self.bare_ref.all
|
all_refs = self.bare_ref.all
|
||||||
if rev not in all:
|
if rev not in all_refs:
|
||||||
# Doesn't exist
|
# Doesn't exist
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -1293,9 +1291,9 @@ class Project(object):
|
|||||||
# We can't destroy the branch while we are sitting
|
# We can't destroy the branch while we are sitting
|
||||||
# on it. Switch to a detached HEAD.
|
# 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:
|
if head == revid:
|
||||||
_lwrite(os.path.join(self.worktree, '.git', HEAD),
|
_lwrite(os.path.join(self.worktree, '.git', HEAD),
|
||||||
'%s\n' % revid)
|
'%s\n' % revid)
|
||||||
@ -1412,33 +1410,33 @@ class Project(object):
|
|||||||
packed_refs = os.path.join(self.gitdir, 'packed-refs')
|
packed_refs = os.path.join(self.gitdir, 'packed-refs')
|
||||||
remote = self.GetRemote(name)
|
remote = self.GetRemote(name)
|
||||||
|
|
||||||
all = self.bare_ref.all
|
all_refs = self.bare_ref.all
|
||||||
ids = set(all.values())
|
ids = set(all_refs.values())
|
||||||
tmp = set()
|
tmp = set()
|
||||||
|
|
||||||
for r, id in GitRefs(ref_dir).all.iteritems():
|
for r, ref_id in GitRefs(ref_dir).all.iteritems():
|
||||||
if r not in all:
|
if r not in all_refs:
|
||||||
if r.startswith(R_TAGS) or remote.WritesTo(r):
|
if r.startswith(R_TAGS) or remote.WritesTo(r):
|
||||||
all[r] = id
|
all_refs[r] = ref_id
|
||||||
ids.add(id)
|
ids.add(ref_id)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if id in ids:
|
if ref_id in ids:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
r = 'refs/_alt/%s' % id
|
r = 'refs/_alt/%s' % ref_id
|
||||||
all[r] = id
|
all_refs[r] = ref_id
|
||||||
ids.add(id)
|
ids.add(ref_id)
|
||||||
tmp.add(r)
|
tmp.add(r)
|
||||||
|
|
||||||
ref_names = list(all.keys())
|
ref_names = list(all_refs.keys())
|
||||||
ref_names.sort()
|
ref_names.sort()
|
||||||
|
|
||||||
tmp_packed = ''
|
tmp_packed = ''
|
||||||
old_packed = ''
|
old_packed = ''
|
||||||
|
|
||||||
for r in ref_names:
|
for r in ref_names:
|
||||||
line = '%s %s\n' % (all[r], r)
|
line = '%s %s\n' % (all_refs[r], r)
|
||||||
tmp_packed += line
|
tmp_packed += line
|
||||||
if r not in tmp:
|
if r not in tmp:
|
||||||
old_packed += line
|
old_packed += line
|
||||||
@ -1477,7 +1475,7 @@ class Project(object):
|
|||||||
cmd.append((u'+refs/heads/%s:' % branch) + remote.ToLocal('refs/heads/%s' % branch))
|
cmd.append((u'+refs/heads/%s:' % branch) + remote.ToLocal('refs/heads/%s' % branch))
|
||||||
|
|
||||||
ok = False
|
ok = False
|
||||||
for i in range(2):
|
for _i in range(2):
|
||||||
ret = GitCommand(self, cmd, bare=True, ssh_proxy=ssh_proxy).Wait()
|
ret = GitCommand(self, cmd, bare=True, ssh_proxy=ssh_proxy).Wait()
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
ok = True
|
ok = True
|
||||||
@ -2034,7 +2032,7 @@ class _Later(object):
|
|||||||
self.action()
|
self.action()
|
||||||
out.nl()
|
out.nl()
|
||||||
return True
|
return True
|
||||||
except GitError, e:
|
except GitError:
|
||||||
out.nl()
|
out.nl()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -2104,7 +2102,6 @@ class MetaProject(Project):
|
|||||||
"""A special project housed under .repo.
|
"""A special project housed under .repo.
|
||||||
"""
|
"""
|
||||||
def __init__(self, manifest, name, gitdir, worktree):
|
def __init__(self, manifest, name, gitdir, worktree):
|
||||||
repodir = manifest.repodir
|
|
||||||
Project.__init__(self,
|
Project.__init__(self,
|
||||||
manifest = manifest,
|
manifest = manifest,
|
||||||
name = name,
|
name = name,
|
||||||
@ -2156,12 +2153,12 @@ class MetaProject(Project):
|
|||||||
if not self.remote or not self.revisionExpr:
|
if not self.remote or not self.revisionExpr:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
all = self.bare_ref.all
|
all_refs = self.bare_ref.all
|
||||||
revid = self.GetRevisionId(all)
|
revid = self.GetRevisionId(all_refs)
|
||||||
head = self.work_git.GetHead()
|
head = self.work_git.GetHead()
|
||||||
if head.startswith(R_HEADS):
|
if head.startswith(R_HEADS):
|
||||||
try:
|
try:
|
||||||
head = all[head]
|
head = all_refs[head]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
head = None
|
head = None
|
||||||
|
|
||||||
|
@ -140,12 +140,12 @@ is shown, then the branch appears in all projects.
|
|||||||
fmt = out.write
|
fmt = out.write
|
||||||
paths = []
|
paths = []
|
||||||
if in_cnt < project_cnt - in_cnt:
|
if in_cnt < project_cnt - in_cnt:
|
||||||
type = 'in'
|
in_type = 'in'
|
||||||
for b in i.projects:
|
for b in i.projects:
|
||||||
paths.append(b.project.relpath)
|
paths.append(b.project.relpath)
|
||||||
else:
|
else:
|
||||||
fmt = out.notinproject
|
fmt = out.notinproject
|
||||||
type = 'not in'
|
in_type = 'not in'
|
||||||
have = set()
|
have = set()
|
||||||
for b in i.projects:
|
for b in i.projects:
|
||||||
have.add(b.project)
|
have.add(b.project)
|
||||||
@ -153,11 +153,11 @@ is shown, then the branch appears in all projects.
|
|||||||
if not p in have:
|
if not p in have:
|
||||||
paths.append(p.relpath)
|
paths.append(p.relpath)
|
||||||
|
|
||||||
s = ' %s %s' % (type, ', '.join(paths))
|
s = ' %s %s' % (in_type, ', '.join(paths))
|
||||||
if width + 7 + len(s) < 80:
|
if width + 7 + len(s) < 80:
|
||||||
fmt(s)
|
fmt(s)
|
||||||
else:
|
else:
|
||||||
fmt(' %s:' % type)
|
fmt(' %s:' % in_type)
|
||||||
for p in paths:
|
for p in paths:
|
||||||
out.nl()
|
out.nl()
|
||||||
fmt(width*' ' + ' %s' % p)
|
fmt(width*' ' + ' %s' % p)
|
||||||
|
@ -208,7 +208,6 @@ terminal and are not redirected.
|
|||||||
return self.fd.fileno()
|
return self.fd.fileno()
|
||||||
|
|
||||||
empty = True
|
empty = True
|
||||||
didout = False
|
|
||||||
errbuf = ''
|
errbuf = ''
|
||||||
|
|
||||||
p.stdin.close()
|
p.stdin.close()
|
||||||
@ -220,7 +219,7 @@ terminal and are not redirected.
|
|||||||
fcntl.fcntl(s.fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
|
fcntl.fcntl(s.fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
|
||||||
|
|
||||||
while s_in:
|
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:
|
for s in in_ready:
|
||||||
buf = s.fd.read(4096)
|
buf = s.fd.read(4096)
|
||||||
if not buf:
|
if not buf:
|
||||||
@ -229,9 +228,7 @@ terminal and are not redirected.
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if not opt.verbose:
|
if not opt.verbose:
|
||||||
if s.fd == p.stdout:
|
if s.fd != p.stdout:
|
||||||
didout = True
|
|
||||||
else:
|
|
||||||
errbuf += buf
|
errbuf += buf
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -120,8 +120,8 @@ See 'repo help --all' for a complete list of recognized commands.
|
|||||||
m = asciidoc_hdr.match(para)
|
m = asciidoc_hdr.match(para)
|
||||||
if m:
|
if m:
|
||||||
title = m.group(1)
|
title = m.group(1)
|
||||||
type = m.group(2)
|
section_type = m.group(2)
|
||||||
if type[0] in ('=', '-'):
|
if section_type[0] in ('=', '-'):
|
||||||
p = self.heading
|
p = self.heading
|
||||||
else:
|
else:
|
||||||
def _p(fmt, *args):
|
def _p(fmt, *args):
|
||||||
@ -131,7 +131,7 @@ See 'repo help --all' for a complete list of recognized commands.
|
|||||||
|
|
||||||
p('%s', title)
|
p('%s', title)
|
||||||
self.nl()
|
self.nl()
|
||||||
p('%s', ''.ljust(len(title),type[0]))
|
p('%s', ''.ljust(len(title),section_type[0]))
|
||||||
self.nl()
|
self.nl()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -213,8 +213,6 @@ to update the working directory files.
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def _Prompt(self, prompt, value):
|
def _Prompt(self, prompt, value):
|
||||||
mp = self.manifest.manifestProject
|
|
||||||
|
|
||||||
sys.stdout.write('%-10s [%s]: ' % (prompt, value))
|
sys.stdout.write('%-10s [%s]: ' % (prompt, value))
|
||||||
a = sys.stdin.readline().strip()
|
a = sys.stdin.readline().strip()
|
||||||
if a == '':
|
if a == '':
|
||||||
@ -328,9 +326,9 @@ to update the working directory files.
|
|||||||
self._ConfigureDepth(opt)
|
self._ConfigureDepth(opt)
|
||||||
|
|
||||||
if self.manifest.IsMirror:
|
if self.manifest.IsMirror:
|
||||||
type = 'mirror '
|
init_type = 'mirror '
|
||||||
else:
|
else:
|
||||||
type = ''
|
init_type = ''
|
||||||
|
|
||||||
print ''
|
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
|
@property
|
||||||
def helpDescription(self):
|
def helpDescription(self):
|
||||||
help = self._helpDescription + '\n'
|
helptext = self._helpDescription + '\n'
|
||||||
r = os.path.dirname(__file__)
|
r = os.path.dirname(__file__)
|
||||||
r = os.path.dirname(r)
|
r = os.path.dirname(r)
|
||||||
fd = open(os.path.join(r, 'docs', 'manifest-format.txt'))
|
fd = open(os.path.join(r, 'docs', 'manifest-format.txt'))
|
||||||
for line in fd:
|
for line in fd:
|
||||||
help += line
|
helptext += line
|
||||||
fd.close()
|
fd.close()
|
||||||
return help
|
return helptext
|
||||||
|
|
||||||
def _Options(self, p):
|
def _Options(self, p):
|
||||||
p.add_option('-r', '--revision-as-HEAD',
|
p.add_option('-r', '--revision-as-HEAD',
|
||||||
|
@ -38,16 +38,16 @@ are displayed.
|
|||||||
help="Consider only checked out branches")
|
help="Consider only checked out branches")
|
||||||
|
|
||||||
def Execute(self, opt, args):
|
def Execute(self, opt, args):
|
||||||
all = []
|
all_branches = []
|
||||||
for project in self.GetProjects(args):
|
for project in self.GetProjects(args):
|
||||||
br = [project.GetUploadableBranch(x)
|
br = [project.GetUploadableBranch(x)
|
||||||
for x in project.GetBranches().keys()]
|
for x in project.GetBranches().keys()]
|
||||||
br = [x for x in br if x]
|
br = [x for x in br if x]
|
||||||
if opt.current_branch:
|
if opt.current_branch:
|
||||||
br = [x for x in br if x.name == project.CurrentBranch]
|
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
|
return
|
||||||
|
|
||||||
class Report(Coloring):
|
class Report(Coloring):
|
||||||
@ -55,13 +55,13 @@ are displayed.
|
|||||||
Coloring.__init__(self, config, 'status')
|
Coloring.__init__(self, config, 'status')
|
||||||
self.project = self.printer('header', attr='bold')
|
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.project('Projects Overview')
|
||||||
out.nl()
|
out.nl()
|
||||||
|
|
||||||
project = None
|
project = None
|
||||||
|
|
||||||
for branch in all:
|
for branch in all_branches:
|
||||||
if project != branch.project:
|
if project != branch.project:
|
||||||
project = branch.project
|
project = branch.project
|
||||||
out.nl()
|
out.nl()
|
||||||
|
@ -24,11 +24,11 @@ class Prune(PagedCommand):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def Execute(self, opt, args):
|
def Execute(self, opt, args):
|
||||||
all = []
|
all_branches = []
|
||||||
for project in self.GetProjects(args):
|
for project in self.GetProjects(args):
|
||||||
all.extend(project.PruneHeads())
|
all_branches.extend(project.PruneHeads())
|
||||||
|
|
||||||
if not all:
|
if not all_branches:
|
||||||
return
|
return
|
||||||
|
|
||||||
class Report(Coloring):
|
class Report(Coloring):
|
||||||
@ -36,13 +36,13 @@ class Prune(PagedCommand):
|
|||||||
Coloring.__init__(self, config, 'status')
|
Coloring.__init__(self, config, 'status')
|
||||||
self.project = self.printer('header', attr='bold')
|
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.project('Pending Branches')
|
||||||
out.nl()
|
out.nl()
|
||||||
|
|
||||||
project = None
|
project = None
|
||||||
|
|
||||||
for branch in all:
|
for branch in all_branches:
|
||||||
if project != branch.project:
|
if project != branch.project:
|
||||||
project = branch.project
|
project = branch.project
|
||||||
out.nl()
|
out.nl()
|
||||||
|
@ -55,14 +55,14 @@ branch but need to incorporate new upstream changes "underneath" them.
|
|||||||
help='Stash local modifications before starting')
|
help='Stash local modifications before starting')
|
||||||
|
|
||||||
def Execute(self, opt, args):
|
def Execute(self, opt, args):
|
||||||
all = self.GetProjects(args)
|
all_projects = self.GetProjects(args)
|
||||||
one_project = len(all) == 1
|
one_project = len(all_projects) == 1
|
||||||
|
|
||||||
if opt.interactive and not one_project:
|
if opt.interactive and not one_project:
|
||||||
print >>sys.stderr, 'error: interactive rebase not supported with multiple projects'
|
print >>sys.stderr, 'error: interactive rebase not supported with multiple projects'
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
for project in all:
|
for project in all_projects:
|
||||||
cb = project.CurrentBranch
|
cb = project.CurrentBranch
|
||||||
if not cb:
|
if not cb:
|
||||||
if one_project:
|
if one_project:
|
||||||
|
@ -48,8 +48,8 @@ The '%prog' command stages files to prepare the next commit.
|
|||||||
self.Usage()
|
self.Usage()
|
||||||
|
|
||||||
def _Interactive(self, opt, args):
|
def _Interactive(self, opt, args):
|
||||||
all = filter(lambda x: x.IsDirty(), self.GetProjects(args))
|
all_projects = filter(lambda x: x.IsDirty(), self.GetProjects(args))
|
||||||
if not all:
|
if not all_projects:
|
||||||
print >>sys.stderr,'no projects have uncommitted modifications'
|
print >>sys.stderr,'no projects have uncommitted modifications'
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -58,8 +58,8 @@ The '%prog' command stages files to prepare the next commit.
|
|||||||
out.header(' %s', 'project')
|
out.header(' %s', 'project')
|
||||||
out.nl()
|
out.nl()
|
||||||
|
|
||||||
for i in xrange(0, len(all)):
|
for i in xrange(0, len(all_projects)):
|
||||||
p = all[i]
|
p = all_projects[i]
|
||||||
out.write('%3d: %s', i + 1, p.relpath + '/')
|
out.write('%3d: %s', i + 1, p.relpath + '/')
|
||||||
out.nl()
|
out.nl()
|
||||||
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 is not None:
|
||||||
if a_index == 0:
|
if a_index == 0:
|
||||||
break
|
break
|
||||||
if 0 < a_index and a_index <= len(all):
|
if 0 < a_index and a_index <= len(all_projects):
|
||||||
_AddI(all[a_index - 1])
|
_AddI(all_projects[a_index - 1])
|
||||||
continue
|
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:
|
if len(p) == 1:
|
||||||
_AddI(p[0])
|
_AddI(p[0])
|
||||||
continue
|
continue
|
||||||
|
@ -52,10 +52,10 @@ revision specified in the manifest.
|
|||||||
print >>sys.stderr, "error: at least one project must be specified"
|
print >>sys.stderr, "error: at least one project must be specified"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
all = self.GetProjects(projects)
|
all_projects = self.GetProjects(projects)
|
||||||
|
|
||||||
pm = Progress('Starting %s' % nb, len(all))
|
pm = Progress('Starting %s' % nb, len(all_projects))
|
||||||
for project in all:
|
for project in all_projects:
|
||||||
pm.update()
|
pm.update()
|
||||||
# If the current revision is a specific SHA1 then we can't push back
|
# If the current revision is a specific SHA1 then we can't push back
|
||||||
# to it so substitute the manifest default revision instead.
|
# to it so substitute the manifest default revision instead.
|
||||||
|
@ -98,18 +98,18 @@ the following meanings:
|
|||||||
sem.release()
|
sem.release()
|
||||||
|
|
||||||
def Execute(self, opt, args):
|
def Execute(self, opt, args):
|
||||||
all = self.GetProjects(args)
|
all_projects = self.GetProjects(args)
|
||||||
counter = itertools.count()
|
counter = itertools.count()
|
||||||
|
|
||||||
if opt.jobs == 1:
|
if opt.jobs == 1:
|
||||||
for project in all:
|
for project in all_projects:
|
||||||
state = project.PrintWorkTreeStatus()
|
state = project.PrintWorkTreeStatus()
|
||||||
if state == 'CLEAN':
|
if state == 'CLEAN':
|
||||||
counter.next()
|
counter.next()
|
||||||
else:
|
else:
|
||||||
sem = _threading.Semaphore(opt.jobs)
|
sem = _threading.Semaphore(opt.jobs)
|
||||||
threads_and_output = []
|
threads_and_output = []
|
||||||
for project in all:
|
for project in all_projects:
|
||||||
sem.acquire()
|
sem.acquire()
|
||||||
|
|
||||||
class BufList(StringIO.StringIO):
|
class BufList(StringIO.StringIO):
|
||||||
@ -128,5 +128,5 @@ the following meanings:
|
|||||||
t.join()
|
t.join()
|
||||||
output.dump(sys.stdout)
|
output.dump(sys.stdout)
|
||||||
output.close()
|
output.close()
|
||||||
if len(all) == counter.next():
|
if len(all_projects) == counter.next():
|
||||||
print 'nothing to commit (working directory clean)'
|
print 'nothing to commit (working directory clean)'
|
||||||
|
@ -316,8 +316,7 @@ later is required to fix a server side protocol bug.
|
|||||||
if not path:
|
if not path:
|
||||||
continue
|
continue
|
||||||
if path not in new_project_paths:
|
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):
|
if os.path.exists(self.manifest.topdir + '/' + path):
|
||||||
project = Project(
|
project = Project(
|
||||||
manifest = self.manifest,
|
manifest = self.manifest,
|
||||||
@ -495,16 +494,16 @@ uncommitted changes are present' % project.relpath
|
|||||||
self.manifest._Unload()
|
self.manifest._Unload()
|
||||||
if opt.jobs is None:
|
if opt.jobs is None:
|
||||||
self.jobs = self.manifest.default.sync_j
|
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:
|
if not opt.local_only:
|
||||||
to_fetch = []
|
to_fetch = []
|
||||||
now = time.time()
|
now = time.time()
|
||||||
if (24 * 60 * 60) <= (now - rp.LastFetch):
|
if (24 * 60 * 60) <= (now - rp.LastFetch):
|
||||||
to_fetch.append(rp)
|
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)
|
_PostRepoFetch(rp, opt.no_repo_verify)
|
||||||
if opt.network_only:
|
if opt.network_only:
|
||||||
# bail out now; the rest touches the working tree
|
# bail out now; the rest touches the working tree
|
||||||
@ -519,8 +518,8 @@ uncommitted changes are present' % project.relpath
|
|||||||
|
|
||||||
syncbuf = SyncBuffer(mp.config,
|
syncbuf = SyncBuffer(mp.config,
|
||||||
detach_head = opt.detach_head)
|
detach_head = opt.detach_head)
|
||||||
pm = Progress('Syncing work tree', len(all))
|
pm = Progress('Syncing work tree', len(all_projects))
|
||||||
for project in all:
|
for project in all_projects:
|
||||||
pm.update()
|
pm.update()
|
||||||
if project.worktree:
|
if project.worktree:
|
||||||
project.Sync_LocalHalf(syncbuf)
|
project.Sync_LocalHalf(syncbuf)
|
||||||
|
@ -40,8 +40,8 @@ def _die(fmt, *args):
|
|||||||
|
|
||||||
def _SplitEmails(values):
|
def _SplitEmails(values):
|
||||||
result = []
|
result = []
|
||||||
for str in values:
|
for value in values:
|
||||||
result.extend([s.strip() for s in str.split(',')])
|
result.extend([s.strip() for s in value.split(',')])
|
||||||
return result
|
return result
|
||||||
|
|
||||||
class Upload(InteractiveCommand):
|
class Upload(InteractiveCommand):
|
||||||
@ -174,15 +174,15 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
|
|||||||
|
|
||||||
if answer is None:
|
if answer is None:
|
||||||
date = branch.date
|
date = branch.date
|
||||||
list = branch.commits
|
commit_list = branch.commits
|
||||||
|
|
||||||
print 'Upload project %s/ to remote branch %s:' % (project.relpath, project.revisionExpr)
|
print 'Upload project %s/ to remote branch %s:' % (project.relpath, project.revisionExpr)
|
||||||
print ' branch %s (%2d commit%s, %s):' % (
|
print ' branch %s (%2d commit%s, %s):' % (
|
||||||
name,
|
name,
|
||||||
len(list),
|
len(commit_list),
|
||||||
len(list) != 1 and 's' or '',
|
len(commit_list) != 1 and 's' or '',
|
||||||
date)
|
date)
|
||||||
for commit in list:
|
for commit in commit_list:
|
||||||
print ' %s' % commit
|
print ' %s' % commit
|
||||||
|
|
||||||
sys.stdout.write('to %s (y/N)? ' % remote.review)
|
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:
|
for branch in avail:
|
||||||
name = branch.name
|
name = branch.name
|
||||||
date = branch.date
|
date = branch.date
|
||||||
list = branch.commits
|
commit_list = branch.commits
|
||||||
|
|
||||||
if b:
|
if b:
|
||||||
script.append('#')
|
script.append('#')
|
||||||
script.append('# branch %s (%2d commit%s, %s) to remote branch %s:' % (
|
script.append('# branch %s (%2d commit%s, %s) to remote branch %s:' % (
|
||||||
name,
|
name,
|
||||||
len(list),
|
len(commit_list),
|
||||||
len(list) != 1 and 's' or '',
|
len(commit_list) != 1 and 's' or '',
|
||||||
date,
|
date,
|
||||||
project.revisionExpr))
|
project.revisionExpr))
|
||||||
for commit in list:
|
for commit in commit_list:
|
||||||
script.append('# %s' % commit)
|
script.append('# %s' % commit)
|
||||||
b[name] = branch
|
b[name] = branch
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user