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_master = True
|
||||
|
||||
def _open_ssh(host, port=None):
|
||||
def _open_ssh(host, port):
|
||||
global _ssh_master
|
||||
|
||||
if port is None:
|
||||
port = 22
|
||||
|
||||
key = '%s:%s' % (host, port)
|
||||
if key in _ssh_cache:
|
||||
return True
|
||||
|
||||
if not _ssh_master \
|
||||
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
|
||||
#
|
||||
return False
|
||||
@ -388,7 +385,7 @@ def close_ssh():
|
||||
pass
|
||||
|
||||
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):
|
||||
m = URI_ALL.match(url)
|
||||
@ -397,6 +394,8 @@ def _preconnect(url):
|
||||
host = m.group(2)
|
||||
if ':' in host:
|
||||
host, port = host.split(':')
|
||||
else:
|
||||
port = 22
|
||||
if scheme in ('ssh', 'git+ssh', 'ssh+git'):
|
||||
return _open_ssh(host, port)
|
||||
return False
|
||||
@ -404,7 +403,7 @@ def _preconnect(url):
|
||||
m = URI_SCP.match(url)
|
||||
if m:
|
||||
host = m.group(1)
|
||||
return _open_ssh(host)
|
||||
return _open_ssh(host, 22)
|
||||
|
||||
|
||||
class Remote(object):
|
||||
|
13
project.py
13
project.py
@ -155,6 +155,19 @@ class ReviewableBranch(object):
|
||||
self.replace_changes,
|
||||
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):
|
||||
def __init__(self, config):
|
||||
|
@ -22,13 +22,18 @@ class Start(Command):
|
||||
common = True
|
||||
helpSummary = "Start a new branch for development"
|
||||
helpUsage = """
|
||||
%prog <newbranchname> [<project>...]
|
||||
%prog <newbranchname> [--all | <project>...]
|
||||
"""
|
||||
helpDescription = """
|
||||
'%prog' begins a new branch of development, starting from the
|
||||
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):
|
||||
if not args:
|
||||
self.Usage()
|
||||
@ -39,7 +44,14 @@ revision specified in the manifest.
|
||||
sys.exit(1)
|
||||
|
||||
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))
|
||||
for project in all:
|
||||
|
@ -194,6 +194,18 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
|
||||
_die("nothing uncommented for upload")
|
||||
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):
|
||||
branch = project.CurrentBranch
|
||||
if not branch:
|
||||
@ -206,8 +218,14 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
|
||||
|
||||
script = []
|
||||
script.append('# Replacing from branch %s' % branch.name)
|
||||
for commit in branch.commits:
|
||||
script.append('[ ] %s' % commit)
|
||||
|
||||
if len(branch.commits) == 1:
|
||||
change = self._FindGerritChange(branch)
|
||||
script.append('[%-6s] %s' % (change, branch.commits[0]))
|
||||
else:
|
||||
for commit in branch.commits:
|
||||
script.append('[ ] %s' % commit)
|
||||
|
||||
script.append('')
|
||||
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.')
|
||||
|
Reference in New Issue
Block a user