mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-06-26 20:17:52 +00:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
498a0e8a79 | |||
bc7ef67d9b | |||
2f968c943b | |||
2b5b4ac292 | |||
6f6cd77a50 |
@ -346,7 +346,7 @@ def _open_ssh(host, port):
|
||||
|
||||
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
|
||||
@ -385,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)
|
||||
|
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):
|
||||
|
@ -63,11 +63,6 @@ class Branches(Command):
|
||||
Summarizes the currently available topic branches.
|
||||
"""
|
||||
|
||||
def _Options(self, p):
|
||||
p.add_option('-a', '--all',
|
||||
dest='all', action='store_true',
|
||||
help='show all branches, not just the majority')
|
||||
|
||||
def Execute(self, opt, args):
|
||||
projects = self.GetProjects(args)
|
||||
out = BranchColoring(self.manifest.manifestProject.config)
|
||||
@ -84,18 +79,6 @@ Summarizes the currently available topic branches.
|
||||
names = all.keys()
|
||||
names.sort()
|
||||
|
||||
if not opt.all and not args:
|
||||
# No -a and no specific projects listed; try to filter the
|
||||
# results down to only the majority of projects.
|
||||
#
|
||||
n = []
|
||||
for name in names:
|
||||
i = all[name]
|
||||
if i.IsCurrent \
|
||||
or 80 <= (100 * len(i.projects)) / project_cnt:
|
||||
n.append(name)
|
||||
names = n
|
||||
|
||||
if not names:
|
||||
print >>sys.stderr, ' (no branches)'
|
||||
return
|
||||
@ -126,7 +109,7 @@ Summarizes the currently available topic branches.
|
||||
hdr('%c%c %-*s' % (current, published, width, name))
|
||||
out.write(' |')
|
||||
|
||||
if in_cnt < project_cnt and (in_cnt == 1 or opt.all):
|
||||
if in_cnt < project_cnt and (in_cnt == 1):
|
||||
fmt = out.write
|
||||
paths = []
|
||||
if in_cnt < project_cnt - in_cnt:
|
||||
|
@ -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