Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1053)

Unified Diff: recipe_modules/step/api.py

Issue 2322093002: Track step nesting in StreamEngine (Reland). (Closed)
Patch Set: Might as well go deeper. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « recipe_modules/generator_script/example.expected/nested.json ('k') | recipe_modules/step/config.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_modules/step/api.py
diff --git a/recipe_modules/step/api.py b/recipe_modules/step/api.py
index b60124c1b1b4e04c08cee64985c9ca7fa15f4158..8154e2fc5888df63e0375da26e667b9f58589d90 100644
--- a/recipe_modules/step/api.py
+++ b/recipe_modules/step/api.py
@@ -13,6 +13,7 @@ class StepApi(recipe_api.RecipeApiPlain):
def __init__(self, **kwargs):
super(StepApi, self).__init__(**kwargs)
self._step_names = {}
+ self._seen_steps = set()
EXCEPTION = 'EXCEPTION'
FAILURE = 'FAILURE'
@@ -135,20 +136,30 @@ class StepApi(recipe_api.RecipeApiPlain):
# Obtain information from composite step parent.
compositor = recipe_api._STEP_CONTEXT
- name = compositor.get_with_context('name', name)
+
+ # Calculate our full step name. If a step already has that name, add an
+ # index to the end of it.
+ #
+ # Note that another step could exist with that index already added to it
+ # by the user. If this happens, we'll continue appending indexes until we
+ # have a unique step name.
+ while True:
+ full_name = compositor.get_with_context('name', name)
+ if full_name not in self._seen_steps:
+ break
+
+ step_count = self._step_names.setdefault(full_name, 1) + 1
+ self._step_names[full_name] = step_count
+ name = "%s (%d)" % (name, step_count)
+ self._seen_steps.add(full_name)
+
if 'cwd' not in kwargs:
kwargs['cwd'] = compositor.get('cwd')
kwargs['env'] = compositor.get_with_context('env', kwargs.get('env', {}))
kwargs['infra_step'] = compositor.get_with_context(
'infra_step', bool(infra_step))
kwargs['step_nest_level'] = compositor.get_with_context('nest_level', 0)
-
- # Disambiguate repeated names
- step_count = self._step_names.setdefault(name, 0) + 1
- self._step_names[name] = step_count
- if step_count > 1:
- name = "%s (%d)" % (name, step_count)
- kwargs['name'] = name
+ kwargs['name'] = full_name
schema = self.make_config()
schema.set_val(kwargs)
« no previous file with comments | « recipe_modules/generator_script/example.expected/nested.json ('k') | recipe_modules/step/config.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698