New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prelude and epilogue to dep. graph walks #6784

Merged
merged 1 commit into from Nov 19, 2018

Conversation

Projects
None yet
2 participants
@blorente
Contributor

blorente commented Nov 16, 2018

Problem

It would be nice to execute code before and after children are visited in graph traversals. The context of this change is the implementation of Dependency Banning (#6541), and the propagation of constraints through the dependency graph.

Solution

Add optional prelude and epilogue function parameters to the dep. graph walk functions, that get executed right before visiting children. This should not incur any API or performance changes for existing code.

Result

Calls like these are now possible:

a = self.make_target('a')
b = self.make_target('b', dependencies=[a])
names = []
self.build_graph.walk_transitive_dependency_graph(
    [b.address],
    work=lambda x: names.append(x.name),
    postorder=postorder,
    prelude=lambda x: names.append(x.name + "-pre"),
     epilogue=lambda x: names.append(x.name + "-epi"),
)
assertEqual(names, ['b', 'b-pre', 'a', 'a-pre', 'a-epi', 'b-epi'])

Blocks: #6541

@blorente blorente referenced this pull request Nov 16, 2018

Open

[WIP] Implement dependency banning #6541

4 of 5 tasks complete
@blorente

This comment has been minimized.

Contributor

blorente commented Nov 17, 2018

I'm going to go ahead and ping @dotordogh and @illicitonion on this one, since it's green, ready for review and it's blocking another thing.

@illicitonion

Looks great :) Thanks!

@illicitonion illicitonion merged commit 0176dc2 into pantsbuild:master Nov 19, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment