Merge "repo-pull: Handle project-not-found error"
This commit is contained in:
@@ -119,13 +119,11 @@ class ChangeList(object):
|
|||||||
"""A ChangeList to be checked out."""
|
"""A ChangeList to be checked out."""
|
||||||
# pylint: disable=too-few-public-methods,too-many-instance-attributes
|
# pylint: disable=too-few-public-methods,too-many-instance-attributes
|
||||||
|
|
||||||
def __init__(self, project, project_dir, fetch, commit_sha1, commit,
|
def __init__(self, project, fetch, commit_sha1, commit, change_list):
|
||||||
change_list):
|
|
||||||
"""Initialize a ChangeList instance."""
|
"""Initialize a ChangeList instance."""
|
||||||
# pylint: disable=too-many-arguments
|
# pylint: disable=too-many-arguments
|
||||||
|
|
||||||
self.project = project
|
self.project = project
|
||||||
self.project_dir = project_dir
|
|
||||||
self.number = change_list['_number']
|
self.number = change_list['_number']
|
||||||
|
|
||||||
self.fetch = fetch
|
self.fetch = fetch
|
||||||
@@ -183,7 +181,7 @@ def build_project_name_dir_dict(manifest_path):
|
|||||||
return project_dirs
|
return project_dirs
|
||||||
|
|
||||||
|
|
||||||
def group_and_sort_change_lists(change_lists, project_dirs):
|
def group_and_sort_change_lists(change_lists):
|
||||||
"""Build a dict that maps projects to a list of topologically sorted change
|
"""Build a dict that maps projects to a list of topologically sorted change
|
||||||
lists."""
|
lists."""
|
||||||
|
|
||||||
@@ -199,7 +197,6 @@ def group_and_sort_change_lists(change_lists, project_dirs):
|
|||||||
raise ValueError('bad revision')
|
raise ValueError('bad revision')
|
||||||
|
|
||||||
project = change_list['project']
|
project = change_list['project']
|
||||||
project_dir = project_dirs[project]
|
|
||||||
|
|
||||||
project_changes = projects[project]
|
project_changes = projects[project]
|
||||||
if commit_sha1 in project_changes:
|
if commit_sha1 in project_changes:
|
||||||
@@ -207,7 +204,7 @@ def group_and_sort_change_lists(change_lists, project_dirs):
|
|||||||
commit_sha1, project))
|
commit_sha1, project))
|
||||||
|
|
||||||
project_changes[commit_sha1] = ChangeList(
|
project_changes[commit_sha1] = ChangeList(
|
||||||
project, project_dir, fetch, commit_sha1, commit, change_list)
|
project, fetch, commit_sha1, commit, change_list)
|
||||||
|
|
||||||
# Sort all change lists in a project in post ordering.
|
# Sort all change lists in a project in post ordering.
|
||||||
def _sort_project_change_lists(changes):
|
def _sort_project_change_lists(changes):
|
||||||
@@ -300,12 +297,13 @@ def _main_bash(args):
|
|||||||
project_dirs = build_project_name_dir_dict(manifest_path)
|
project_dirs = build_project_name_dir_dict(manifest_path)
|
||||||
|
|
||||||
change_lists = _get_change_lists_from_args(args)
|
change_lists = _get_change_lists_from_args(args)
|
||||||
change_list_groups = group_and_sort_change_lists(change_lists, project_dirs)
|
change_list_groups = group_and_sort_change_lists(change_lists)
|
||||||
|
|
||||||
for changes in change_list_groups:
|
for changes in change_list_groups:
|
||||||
for change in changes:
|
for change in changes:
|
||||||
|
project_dir = project_dirs.get(change.project, change.project)
|
||||||
cmds = []
|
cmds = []
|
||||||
cmds.append(['pushd', change.project_dir])
|
cmds.append(['pushd', project_dir])
|
||||||
cmds.extend(build_pull_commands(
|
cmds.extend(build_pull_commands(
|
||||||
change, branch_name, args.merge, args.pick))
|
change, branch_name, args.merge, args.pick))
|
||||||
cmds.append(['popd'])
|
cmds.append(['popd'])
|
||||||
@@ -319,9 +317,16 @@ def _do_pull_change_lists_for_project(task):
|
|||||||
branch_name = task_opts['branch_name']
|
branch_name = task_opts['branch_name']
|
||||||
merge_opt = task_opts['merge_opt']
|
merge_opt = task_opts['merge_opt']
|
||||||
pick_opt = task_opts['pick_opt']
|
pick_opt = task_opts['pick_opt']
|
||||||
|
project_dirs = task_opts['project_dirs']
|
||||||
|
|
||||||
for i, change in enumerate(changes):
|
for i, change in enumerate(changes):
|
||||||
cwd = change.project_dir
|
try:
|
||||||
|
cwd = project_dirs[change.project]
|
||||||
|
except KeyError:
|
||||||
|
err_msg = 'error: project "{}" cannot be found in manifest.xml\n'
|
||||||
|
err_msg = err_msg.format(change.project).encode('utf-8')
|
||||||
|
return (change, changes[i + 1:], [], err_msg)
|
||||||
|
|
||||||
print(change.commit_sha1[0:10], i + 1, cwd)
|
print(change.commit_sha1[0:10], i + 1, cwd)
|
||||||
cmds = build_pull_commands(change, branch_name, merge_opt, pick_opt)
|
cmds = build_pull_commands(change, branch_name, merge_opt, pick_opt)
|
||||||
for cmd in cmds:
|
for cmd in cmds:
|
||||||
@@ -360,13 +365,14 @@ def _main_pull(args):
|
|||||||
|
|
||||||
# Collect change lists
|
# Collect change lists
|
||||||
change_lists = _get_change_lists_from_args(args)
|
change_lists = _get_change_lists_from_args(args)
|
||||||
change_list_groups = group_and_sort_change_lists(change_lists, project_dirs)
|
change_list_groups = group_and_sort_change_lists(change_lists)
|
||||||
|
|
||||||
# Build the options list for tasks
|
# Build the options list for tasks
|
||||||
task_opts = {
|
task_opts = {
|
||||||
'branch_name': branch_name,
|
'branch_name': branch_name,
|
||||||
'merge_opt': args.merge,
|
'merge_opt': args.merge,
|
||||||
'pick_opt': args.pick,
|
'pick_opt': args.pick,
|
||||||
|
'project_dirs': project_dirs,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run the commands to pull the change lists
|
# Run the commands to pull the change lists
|
||||||
|
|||||||
Reference in New Issue
Block a user