mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-06-30 20:17:08 +00:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
7da73d6f3b | |||
f0d4c36701 | |||
2ec00b9272 | |||
2a3a81b51f | |||
7b4f43542a | |||
9fb29ce123 | |||
3a68bb4c7f | |||
cd1d7ff81e | |||
da88ff4411 |
@ -68,6 +68,30 @@ class _GitCall(object):
|
|||||||
return fun
|
return fun
|
||||||
git = _GitCall()
|
git = _GitCall()
|
||||||
|
|
||||||
|
_git_version = None
|
||||||
|
|
||||||
|
def git_require(min_version, fail=False):
|
||||||
|
global _git_version
|
||||||
|
|
||||||
|
if _git_version is None:
|
||||||
|
ver_str = git.version()
|
||||||
|
if ver_str.startswith('git version '):
|
||||||
|
_git_version = tuple(
|
||||||
|
map(lambda x: int(x),
|
||||||
|
ver_str[len('git version '):].strip().split('.')[0:3]
|
||||||
|
))
|
||||||
|
else:
|
||||||
|
print >>sys.stderr, 'fatal: "%s" unsupported' % ver_str
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if min_version <= _git_version:
|
||||||
|
return True
|
||||||
|
if fail:
|
||||||
|
need = '.'.join(map(lambda x: str(x), min_version))
|
||||||
|
print >>sys.stderr, 'fatal: git %s or later required' % need
|
||||||
|
sys.exit(1)
|
||||||
|
return False
|
||||||
|
|
||||||
class GitCommand(object):
|
class GitCommand(object):
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
project,
|
project,
|
||||||
|
@ -236,6 +236,9 @@ class GitConfig(object):
|
|||||||
return cPickle.load(fd)
|
return cPickle.load(fd)
|
||||||
finally:
|
finally:
|
||||||
fd.close()
|
fd.close()
|
||||||
|
except EOFError:
|
||||||
|
os.remove(self._pickle)
|
||||||
|
return None
|
||||||
except IOError:
|
except IOError:
|
||||||
os.remove(self._pickle)
|
os.remove(self._pickle)
|
||||||
return None
|
return None
|
||||||
@ -414,6 +417,7 @@ def _preconnect(url):
|
|||||||
host = m.group(1)
|
host = m.group(1)
|
||||||
return _open_ssh(host, 22)
|
return _open_ssh(host, 22)
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
class Remote(object):
|
class Remote(object):
|
||||||
"""Configuration options related to a remote.
|
"""Configuration options related to a remote.
|
||||||
|
@ -733,9 +733,7 @@ class Project(object):
|
|||||||
last_mine = commit_id
|
last_mine = commit_id
|
||||||
cnt_mine += 1
|
cnt_mine += 1
|
||||||
|
|
||||||
if not local_changes and not upstream_gain:
|
if not upstream_gain and cnt_mine == len(local_changes):
|
||||||
# Trivially no changes caused by the upstream.
|
|
||||||
#
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.IsDirty(consider_untracked=False):
|
if self.IsDirty(consider_untracked=False):
|
||||||
|
@ -61,6 +61,33 @@ class Branches(Command):
|
|||||||
%prog [<project>...]
|
%prog [<project>...]
|
||||||
|
|
||||||
Summarizes the currently available topic branches.
|
Summarizes the currently available topic branches.
|
||||||
|
|
||||||
|
Branch Display
|
||||||
|
--------------
|
||||||
|
|
||||||
|
The branch display output by this command is organized into four
|
||||||
|
columns of information; for example:
|
||||||
|
|
||||||
|
*P nocolor | in repo
|
||||||
|
repo2 |
|
||||||
|
|
||||||
|
The first column contains a * if the branch is the currently
|
||||||
|
checked out branch in any of the specified projects, or a blank
|
||||||
|
if no project has the branch checked out.
|
||||||
|
|
||||||
|
The second column contains either blank, p or P, depending upon
|
||||||
|
the upload status of the branch.
|
||||||
|
|
||||||
|
(blank): branch not yet published by repo upload
|
||||||
|
P: all commits were published by repo upload
|
||||||
|
p: only some commits were published by repo upload
|
||||||
|
|
||||||
|
The third column contains the branch name.
|
||||||
|
|
||||||
|
The fourth column (after the | separator) lists the projects that
|
||||||
|
the branch appears in, or does not appear in. If no project list
|
||||||
|
is shown, then the branch appears in all projects.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def Execute(self, opt, args):
|
def Execute(self, opt, args):
|
||||||
|
@ -17,7 +17,7 @@ import sys
|
|||||||
from optparse import SUPPRESS_HELP
|
from optparse import SUPPRESS_HELP
|
||||||
from color import Coloring
|
from color import Coloring
|
||||||
from command import PagedCommand
|
from command import PagedCommand
|
||||||
from git_command import GitCommand
|
from git_command import git_require, GitCommand
|
||||||
|
|
||||||
class GrepColoring(Coloring):
|
class GrepColoring(Coloring):
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
@ -158,7 +158,7 @@ contain a line that matches both expressions:
|
|||||||
out = GrepColoring(self.manifest.manifestProject.config)
|
out = GrepColoring(self.manifest.manifestProject.config)
|
||||||
|
|
||||||
cmd_argv = ['grep']
|
cmd_argv = ['grep']
|
||||||
if out.is_on:
|
if out.is_on and git_require((1,6,3)):
|
||||||
cmd_argv.append('--color')
|
cmd_argv.append('--color')
|
||||||
cmd_argv.extend(getattr(opt,'cmd_argv',[]))
|
cmd_argv.extend(getattr(opt,'cmd_argv',[]))
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ from color import Coloring
|
|||||||
from command import InteractiveCommand, MirrorSafeCommand
|
from command import InteractiveCommand, MirrorSafeCommand
|
||||||
from error import ManifestParseError
|
from error import ManifestParseError
|
||||||
from project import SyncBuffer
|
from project import SyncBuffer
|
||||||
from git_command import git, MIN_GIT_VERSION
|
from git_command import git_require, MIN_GIT_VERSION
|
||||||
|
|
||||||
class Init(InteractiveCommand, MirrorSafeCommand):
|
class Init(InteractiveCommand, MirrorSafeCommand):
|
||||||
common = True
|
common = True
|
||||||
@ -85,19 +85,6 @@ to update the working directory files.
|
|||||||
dest='no_repo_verify', action='store_true',
|
dest='no_repo_verify', action='store_true',
|
||||||
help='do not verify repo source code')
|
help='do not verify repo source code')
|
||||||
|
|
||||||
def _CheckGitVersion(self):
|
|
||||||
ver_str = git.version()
|
|
||||||
if not ver_str.startswith('git version '):
|
|
||||||
print >>sys.stderr, 'error: "%s" unsupported' % ver_str
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
ver_str = ver_str[len('git version '):].strip()
|
|
||||||
ver_act = tuple(map(lambda x: int(x), ver_str.split('.')[0:3]))
|
|
||||||
if ver_act < MIN_GIT_VERSION:
|
|
||||||
need = '.'.join(map(lambda x: str(x), MIN_GIT_VERSION))
|
|
||||||
print >>sys.stderr, 'fatal: git %s or later required' % need
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
def _SyncManifest(self, opt):
|
def _SyncManifest(self, opt):
|
||||||
m = self.manifest.manifestProject
|
m = self.manifest.manifestProject
|
||||||
is_new = not m.Exists
|
is_new = not m.Exists
|
||||||
@ -214,7 +201,7 @@ to update the working directory files.
|
|||||||
gc.SetString('color.ui', 'auto')
|
gc.SetString('color.ui', 'auto')
|
||||||
|
|
||||||
def Execute(self, opt, args):
|
def Execute(self, opt, args):
|
||||||
self._CheckGitVersion()
|
git_require(MIN_GIT_VERSION, fail=True)
|
||||||
self._SyncManifest(opt)
|
self._SyncManifest(opt)
|
||||||
self._LinkManifest(opt.manifest_name)
|
self._LinkManifest(opt.manifest_name)
|
||||||
|
|
||||||
|
@ -123,7 +123,8 @@ later is required to fix a server side protocol bug.
|
|||||||
def UpdateProjectList(self):
|
def UpdateProjectList(self):
|
||||||
new_project_paths = []
|
new_project_paths = []
|
||||||
for project in self.manifest.projects.values():
|
for project in self.manifest.projects.values():
|
||||||
new_project_paths.append(project.relpath)
|
if project.relpath:
|
||||||
|
new_project_paths.append(project.relpath)
|
||||||
file_name = 'project.list'
|
file_name = 'project.list'
|
||||||
file_path = os.path.join(self.manifest.repodir, file_name)
|
file_path = os.path.join(self.manifest.repodir, file_name)
|
||||||
old_project_paths = []
|
old_project_paths = []
|
||||||
@ -135,6 +136,8 @@ later is required to fix a server side protocol bug.
|
|||||||
finally:
|
finally:
|
||||||
fd.close()
|
fd.close()
|
||||||
for path in old_project_paths:
|
for path in old_project_paths:
|
||||||
|
if not path:
|
||||||
|
continue
|
||||||
if path not in new_project_paths:
|
if path not in new_project_paths:
|
||||||
project = Project(
|
project = Project(
|
||||||
manifest = self.manifest,
|
manifest = self.manifest,
|
||||||
@ -163,9 +166,11 @@ uncommitted changes are present' % project.relpath
|
|||||||
break
|
break
|
||||||
dir = os.path.dirname(dir)
|
dir = os.path.dirname(dir)
|
||||||
|
|
||||||
|
new_project_paths.sort()
|
||||||
fd = open(file_path, 'w')
|
fd = open(file_path, 'w')
|
||||||
try:
|
try:
|
||||||
fd.write('\n'.join(new_project_paths))
|
fd.write('\n'.join(new_project_paths))
|
||||||
|
fd.write('\n')
|
||||||
finally:
|
finally:
|
||||||
fd.close()
|
fd.close()
|
||||||
return 0
|
return 0
|
||||||
@ -217,6 +222,10 @@ uncommitted changes are present' % project.relpath
|
|||||||
missing.append(project)
|
missing.append(project)
|
||||||
self._Fetch(missing)
|
self._Fetch(missing)
|
||||||
|
|
||||||
|
if self.manifest.IsMirror:
|
||||||
|
# bail out now, we have no working tree
|
||||||
|
return
|
||||||
|
|
||||||
if self.UpdateProjectList():
|
if self.UpdateProjectList():
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user