diff options
Diffstat (limited to 'subcmds/diff.py')
-rw-r--r-- | subcmds/diff.py | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/subcmds/diff.py b/subcmds/diff.py index d9d72b40..7bb0cbbd 100644 --- a/subcmds/diff.py +++ b/subcmds/diff.py | |||
@@ -40,7 +40,8 @@ to the Unix 'patch' command. | |||
40 | help="paths are relative to the repository root", | 40 | help="paths are relative to the repository root", |
41 | ) | 41 | ) |
42 | 42 | ||
43 | def _ExecuteOne(self, absolute, local, project): | 43 | @classmethod |
44 | def _ExecuteOne(cls, absolute, local, project_idx): | ||
44 | """Obtains the diff for a specific project. | 45 | """Obtains the diff for a specific project. |
45 | 46 | ||
46 | Args: | 47 | Args: |
@@ -48,12 +49,13 @@ to the Unix 'patch' command. | |||
48 | local: a boolean, if True, the path is relative to the local | 49 | local: a boolean, if True, the path is relative to the local |
49 | (sub)manifest. If false, the path is relative to the outermost | 50 | (sub)manifest. If false, the path is relative to the outermost |
50 | manifest. | 51 | manifest. |
51 | project: Project to get status of. | 52 | project_idx: Project index to get status of. |
52 | 53 | ||
53 | Returns: | 54 | Returns: |
54 | The status of the project. | 55 | The status of the project. |
55 | """ | 56 | """ |
56 | buf = io.StringIO() | 57 | buf = io.StringIO() |
58 | project = cls.get_parallel_context()["projects"][project_idx] | ||
57 | ret = project.PrintWorkTreeDiff(absolute, output_redir=buf, local=local) | 59 | ret = project.PrintWorkTreeDiff(absolute, output_redir=buf, local=local) |
58 | return (ret, buf.getvalue()) | 60 | return (ret, buf.getvalue()) |
59 | 61 | ||
@@ -71,12 +73,15 @@ to the Unix 'patch' command. | |||
71 | ret = 1 | 73 | ret = 1 |
72 | return ret | 74 | return ret |
73 | 75 | ||
74 | return self.ExecuteInParallel( | 76 | with self.ParallelContext(): |
75 | opt.jobs, | 77 | self.get_parallel_context()["projects"] = all_projects |
76 | functools.partial( | 78 | return self.ExecuteInParallel( |
77 | self._ExecuteOne, opt.absolute, opt.this_manifest_only | 79 | opt.jobs, |
78 | ), | 80 | functools.partial( |
79 | all_projects, | 81 | self._ExecuteOne, opt.absolute, opt.this_manifest_only |
80 | callback=_ProcessResults, | 82 | ), |
81 | ordered=True, | 83 | range(len(all_projects)), |
82 | ) | 84 | callback=_ProcessResults, |
85 | ordered=True, | ||
86 | chunksize=1, | ||
87 | ) | ||