mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-06-30 20:17:08 +00:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
bc7ef67d9b | |||
2f968c943b | |||
2b5b4ac292 | |||
6f6cd77a50 | |||
896d5dffd3 |
@ -337,19 +337,16 @@ class RefSpec(object):
|
|||||||
_ssh_cache = {}
|
_ssh_cache = {}
|
||||||
_ssh_master = True
|
_ssh_master = True
|
||||||
|
|
||||||
def _open_ssh(host, port=None):
|
def _open_ssh(host, port):
|
||||||
global _ssh_master
|
global _ssh_master
|
||||||
|
|
||||||
if port is None:
|
|
||||||
port = 22
|
|
||||||
|
|
||||||
key = '%s:%s' % (host, port)
|
key = '%s:%s' % (host, port)
|
||||||
if key in _ssh_cache:
|
if key in _ssh_cache:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if not _ssh_master \
|
if not _ssh_master \
|
||||||
or 'GIT_SSH' in os.environ \
|
or 'GIT_SSH' in os.environ \
|
||||||
or sys.platform == 'win32':
|
or sys.platform in ('win32', 'cygwin'):
|
||||||
# failed earlier, or cygwin ssh can't do this
|
# failed earlier, or cygwin ssh can't do this
|
||||||
#
|
#
|
||||||
return False
|
return False
|
||||||
@ -388,7 +385,7 @@ def close_ssh():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
URI_SCP = re.compile(r'^([^@:]*@?[^:/]{1,}):')
|
URI_SCP = re.compile(r'^([^@:]*@?[^:/]{1,}):')
|
||||||
URI_ALL = re.compile(r'^([a-z][a-z+]*)://([^@/]*@?[^/])/')
|
URI_ALL = re.compile(r'^([a-z][a-z+]*)://([^@/]*@?[^/]*)/')
|
||||||
|
|
||||||
def _preconnect(url):
|
def _preconnect(url):
|
||||||
m = URI_ALL.match(url)
|
m = URI_ALL.match(url)
|
||||||
@ -397,6 +394,8 @@ def _preconnect(url):
|
|||||||
host = m.group(2)
|
host = m.group(2)
|
||||||
if ':' in host:
|
if ':' in host:
|
||||||
host, port = host.split(':')
|
host, port = host.split(':')
|
||||||
|
else:
|
||||||
|
port = 22
|
||||||
if scheme in ('ssh', 'git+ssh', 'ssh+git'):
|
if scheme in ('ssh', 'git+ssh', 'ssh+git'):
|
||||||
return _open_ssh(host, port)
|
return _open_ssh(host, port)
|
||||||
return False
|
return False
|
||||||
@ -404,7 +403,7 @@ def _preconnect(url):
|
|||||||
m = URI_SCP.match(url)
|
m = URI_SCP.match(url)
|
||||||
if m:
|
if m:
|
||||||
host = m.group(1)
|
host = m.group(1)
|
||||||
return _open_ssh(host)
|
return _open_ssh(host, 22)
|
||||||
|
|
||||||
|
|
||||||
class Remote(object):
|
class Remote(object):
|
||||||
|
13
project.py
13
project.py
@ -155,6 +155,19 @@ class ReviewableBranch(object):
|
|||||||
self.replace_changes,
|
self.replace_changes,
|
||||||
people)
|
people)
|
||||||
|
|
||||||
|
def GetPublishedRefs(self):
|
||||||
|
refs = {}
|
||||||
|
output = self.project.bare_git.ls_remote(
|
||||||
|
self.branch.remote.SshReviewUrl(self.project.UserEmail),
|
||||||
|
'refs/changes/*')
|
||||||
|
for line in output.split('\n'):
|
||||||
|
try:
|
||||||
|
(sha, ref) = line.split()
|
||||||
|
refs[sha] = ref
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return refs
|
||||||
|
|
||||||
class StatusColoring(Coloring):
|
class StatusColoring(Coloring):
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
|
@ -22,13 +22,18 @@ class Start(Command):
|
|||||||
common = True
|
common = True
|
||||||
helpSummary = "Start a new branch for development"
|
helpSummary = "Start a new branch for development"
|
||||||
helpUsage = """
|
helpUsage = """
|
||||||
%prog <newbranchname> [<project>...]
|
%prog <newbranchname> [--all | <project>...]
|
||||||
"""
|
"""
|
||||||
helpDescription = """
|
helpDescription = """
|
||||||
'%prog' begins a new branch of development, starting from the
|
'%prog' begins a new branch of development, starting from the
|
||||||
revision specified in the manifest.
|
revision specified in the manifest.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def _Options(self, p):
|
||||||
|
p.add_option('--all',
|
||||||
|
dest='all', action='store_true',
|
||||||
|
help='begin branch in all projects')
|
||||||
|
|
||||||
def Execute(self, opt, args):
|
def Execute(self, opt, args):
|
||||||
if not args:
|
if not args:
|
||||||
self.Usage()
|
self.Usage()
|
||||||
@ -39,7 +44,14 @@ revision specified in the manifest.
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
err = []
|
err = []
|
||||||
all = self.GetProjects(args[1:])
|
projects = []
|
||||||
|
if not opt.all:
|
||||||
|
projects = args[1:]
|
||||||
|
if len(projects) < 1:
|
||||||
|
print >>sys.stderr, "error: at least one project must be specified"
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
all = self.GetProjects(projects)
|
||||||
|
|
||||||
pm = Progress('Starting %s' % nb, len(all))
|
pm = Progress('Starting %s' % nb, len(all))
|
||||||
for project in all:
|
for project in all:
|
||||||
|
@ -194,6 +194,18 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
|
|||||||
_die("nothing uncommented for upload")
|
_die("nothing uncommented for upload")
|
||||||
self._UploadAndReport(todo, people)
|
self._UploadAndReport(todo, people)
|
||||||
|
|
||||||
|
def _FindGerritChange(self, branch):
|
||||||
|
last_pub = branch.project.WasPublished(branch.name)
|
||||||
|
if last_pub is None:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
refs = branch.GetPublishedRefs()
|
||||||
|
try:
|
||||||
|
# refs/changes/XYZ/N --> XYZ
|
||||||
|
return refs.get(last_pub).split('/')[-2]
|
||||||
|
except:
|
||||||
|
return ""
|
||||||
|
|
||||||
def _ReplaceBranch(self, project, people):
|
def _ReplaceBranch(self, project, people):
|
||||||
branch = project.CurrentBranch
|
branch = project.CurrentBranch
|
||||||
if not branch:
|
if not branch:
|
||||||
@ -206,8 +218,14 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
|
|||||||
|
|
||||||
script = []
|
script = []
|
||||||
script.append('# Replacing from branch %s' % branch.name)
|
script.append('# Replacing from branch %s' % branch.name)
|
||||||
|
|
||||||
|
if len(branch.commits) == 1:
|
||||||
|
change = self._FindGerritChange(branch)
|
||||||
|
script.append('[%-6s] %s' % (change, branch.commits[0]))
|
||||||
|
else:
|
||||||
for commit in branch.commits:
|
for commit in branch.commits:
|
||||||
script.append('[ ] %s' % commit)
|
script.append('[ ] %s' % commit)
|
||||||
|
|
||||||
script.append('')
|
script.append('')
|
||||||
script.append('# Insert change numbers in the brackets to add a new patch set.')
|
script.append('# Insert change numbers in the brackets to add a new patch set.')
|
||||||
script.append('# To create a new change record, leave the brackets empty.')
|
script.append('# To create a new change record, leave the brackets empty.')
|
||||||
|
Reference in New Issue
Block a user