The traversal order used is preorder, not inorder; support postorder traversal

Review Request #1177 — Created Oct. 17, 2014 and submitted

dturner-tw
pants
c9b6b8d...
pants-reviews
ity, jsirois, lahosken, patricklaw

1. The term "inorder traversal" does not make sense outside of the context of binary trees. Instead, use the term "preorder", which is actually what is done.

2. Also allow for postorder traversal (and test that it works).

Postorder stuff is needed for https://rbcommons.com/s/twitter/r/1179/

./pants goal test tests/python/pants_test/graph:graph

LA
  1. 
      
  2. src/python/pants/base/build_graph.py (Diff revision 1)
     
     

    mmmaybe delete this and let the first line say it?

  3. src/python/pants/base/build_graph.py (Diff revision 1)
     
     

    FWIW, I had to look up "post-order" (and "in-order") on teh internets. IDK if I'm typical, tho. If you hear from other folks sayin that's typical, you might toss in a "(leaves before trunks)" merciful parenthetical remark or something

  4. goofy indent scares the crap out of me in Python before I remember the parens.

  5. 
      
DT
ZU
  1. I am the one who added the inorder terminology, thanks for fixing it.

    The reason I added it is because the ordering is important for operations like constructing classpaths. I don't think adding an option for postorder is a problem, but if you change the order for certain operations then things could break.

    1. Yes, ordering is important for something I was interested in, which is why I looked into it.

  2. 
      
PA
  1. lgtm. What was the motivation for this?

    1. For https://rbcommons.com/s/twitter/r/1179/ in the (unlikely) case of multiple commands, I want to make sure to run them in postorder so that if A depends on B, B's command runs before A's.

  2. 
      
IT
  1. Ship It!

  2. 
      
DT
Review request changed

Status: Closed (submitted)

Loading...