(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:hgDir)
          op: assign_op.Equal
          rhs: 
            {
              (command_sub
                left_token: <Id.Left_Backtick '`'>
                command_list: 
                  (command.CommandList
                    children: [(C {<dirname>} {($ Id.VSub_Number '$0')})]
                  )
              ) </..>
            }
          spids: [50]
        )
      ]
    )
    (command.Sentence
      child: 
        (command.If
          arms: [
            (if_arm
              cond: [
                (command.Sentence
                  child: 
                    (command.DBracket
                      expr: 
                        (bool_expr.LogicalAnd
                          left: (bool_expr.Unary op_id:Id.BoolUnary_x child:{</usr/bin/hg>})
                          right: 
                            (bool_expr.Unary
                              op_id: Id.BoolUnary_d
                              child: {($ Id.VSub_DollarName '$hgDir') </.hg>}
                            )
                        )
                    )
                  terminator: <Id.Op_Semi _>
                )
              ]
              action: [
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:rev)
                      op: assign_op.Equal
                      rhs: 
                        {
                          (command_sub
                            left_token: <Id.Left_Backtick '`'>
                            command_list: (command.CommandList children:[(C {<hg>} {<id>} {<-i>})])
                          )
                        }
                      spids: [82]
                    )
                  ]
                )
              ]
              spids: [60 79]
            )
            (if_arm
              cond: [
                (command.Sentence
                  child: 
                    (C {<Id.Lit_LBracket '['>} {<-f>} 
                      {($ Id.VSub_DollarName '$hgDir') </.hg_archival.txt>} {<Id.Lit_RBracket ']'>}
                    )
                  terminator: <Id.Op_Semi _>
                )
              ]
              action: [
                (command.Sentence
                  child: 
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:rev)
                          op: assign_op.Equal
                          rhs: 
                            {
                              (command_sub
                                left_token: <Id.Left_Backtick '`'>
                                command_list: 
                                  (command.CommandList
                                    children: [
                                      (command.Pipeline
                                        children: [
                                          (C {<grep>} {<node>} 
                                            {($ Id.VSub_DollarName '$hgDir') </.hg_archival.txt>}
                                          )
                                          (C {<cut>} {<-d> (SQ <' '>)} {<-f>} {<2>})
                                          (C {<head>} {<-c>} {<12>})
                                        ]
                                        negated: F
                                      )
                                    ]
                                  )
                              )
                            }
                          spids: [108]
                        )
                      ]
                    )
                  terminator: <Id.Op_Semi _>
                )
              ]
              spids: [93 105]
            )
          ]
          else_action: [
            (command.Sentence
              child: 
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:rev)
                      op: assign_op.Equal
                      rhs: (word.Empty)
                      spids: [143]
                    )
                  ]
                )
              terminator: <Id.Op_Semi _>
            )
          ]
        )
      terminator: <Id.Op_Semi _>
    )
    (C {<echo>} {(DQ ($ Id.VSub_DollarName '$rev'))})
  ]
)