(command.ShFunction
  name: gethgversion
  body: 
    (command.BraceGroup
      children: [
        (C {(make)} {(clean)})
        (command.AndOr
          ops: [Id.Op_DPipe]
          children: [(C {(make)} {(local)}) (C {(make)} {(local)} {(Id.Lit_VarLike 'PURE=') (--pure)})]
        )
        (command.ShAssignment
          pairs: [
            (assign_pair
              lhs: (sh_lhs_expr.Name name:HG)
              op: assign_op.Equal
              rhs: {(DQ ($ Id.VSub_DollarName '$PWD') (/hg))}
              spids: [26]
            )
          ]
        )
        (command.AndOr
          ops: [Id.Op_DPipe]
          children: [
            (command.Simple
              words: [{($ Id.VSub_DollarName '$HG')} {(version)}]
              redirects: [
                (redir.Redir
                  op: (Token id:Id.Redir_Great val:'>' span_id:38)
                  fd: -1
                  arg_word: {(/dev/null)}
                )
              ]
            )
            (command.BraceGroup
              children: [
                (command.Sentence
                  child: 
                    (C {(echo)} 
                      {(SQ (Token id:Id.Lit_Chars val:'abort: hg version failed!' span_id:49))}
                    )
                  terminator: (Token id:Id.Op_Semi val:';' span_id:51)
                )
                (command.Sentence
                  child: 
                    (command.ControlFlow
                      token: (Token id:Id.ControlFlow_Exit val:exit span_id:53)
                      arg_word: {(1)}
                    )
                  terminator: (Token id:Id.Op_Semi val:';' span_id:57)
                )
              ]
            )
          ]
        )
        (command.ShAssignment
          pairs: [
            (assign_pair
              lhs: (sh_lhs_expr.Name name:hgversion)
              op: assign_op.Equal
              rhs: 
                {
                  (command_sub
                    left_token: (Token id:Id.Left_Backtick val:'`' span_id:64)
                    command_list: 
                      (command.CommandList
                        children: [
                          (command.Pipeline
                            children: [
                              (C {($ Id.VSub_DollarName '$HG')} {(version)})
                              (C {(sed)} {(-ne)} 
                                {
                                  (SQ 
                                    (Token
                                      id: Id.Lit_Chars
                                      val: 's/.*(version \\(.*\\))$/\\1/p'
                                      span_id: 84
                                    )
                                  )
                                }
                              )
                            ]
                            negated: F
                          )
                        ]
                      )
                  )
                }
              spids: [63]
            )
          ]
        )
        (command.If
          arms: [
            (if_arm
              cond: [
                (command.Sentence
                  child: 
                    (command.Pipeline
                      children: [
                        (C {(echo)} {($ Id.VSub_DollarName '$hgversion')})
                        (command.Simple
                          words: [{(grep)} {(--)} {(SQ (Token id:Id.Lit_Chars val:- span_id:103))}]
                          redirects: [
                            (redir.Redir
                              op: (Token id:Id.Redir_Great val:'>' span_id:106)
                              fd: -1
                              arg_word: {(/dev/null)}
                            )
                            (redir.Redir
                              op: (Token id:Id.Redir_GreatAnd val:'2>&' span_id:110)
                              fd: 2
                              arg_word: {(1)}
                            )
                          ]
                        )
                      ]
                      negated: F
                    )
                  terminator: (Token id:Id.Op_Semi val:';' span_id:112)
                )
              ]
              action: [
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:version)
                      op: assign_op.Equal
                      rhs: 
                        {
                          (command_sub
                            left_token: (Token id:Id.Left_Backtick val:'`' span_id:122)
                            command_list: 
                              (command.CommandList
                                children: [
                                  (command.Pipeline
                                    children: [
                                      (C {(echo)} {($ Id.VSub_DollarName '$hgversion')})
                                      (C {(cut)} {(-d-)} {(-f1)})
                                    ]
                                    negated: F
                                  )
                                ]
                              )
                          )
                        }
                      spids: [121]
                    )
                  ]
                )
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:release)
                      op: assign_op.Equal
                      rhs: 
                        {
                          (command_sub
                            left_token: (Token id:Id.Left_Backtick val:'`' span_id:140)
                            command_list: 
                              (command.CommandList
                                children: [
                                  (command.Pipeline
                                    children: [
                                      (C {(echo)} {($ Id.VSub_DollarName '$hgversion')})
                                      (C {(cut)} {(-d-)} {(-f2)})
                                      (C {(sed)} {(-e)} 
                                        {(SQ (Token id:Id.Lit_Chars val:'s/+.*//' span_id:162))}
                                      )
                                    ]
                                    negated: F
                                  )
                                ]
                              )
                          )
                        }
                      spids: [139]
                    )
                  ]
                )
              ]
              spids: [90 114]
            )
          ]
          else_action: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:version)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (command_sub
                        left_token: (Token id:Id.Left_Backtick val:'`' span_id:175)
                        command_list: 
                          (command.CommandList
                            children: [
                              (command.Pipeline
                                children: [
                                  (C {(echo)} {($ Id.VSub_DollarName '$hgversion')})
                                  (C {(sed)} {(-e)} 
                                    {(SQ (Token id:Id.Lit_Chars val:'s/+.*//' span_id:189))}
                                  )
                                ]
                                negated: F
                              )
                            ]
                          )
                      )
                    }
                  spids: [174]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:release)
                  op: assign_op.Equal
                  rhs: {(SQ (Token id:Id.Lit_Chars val:0 span_id:196))}
                  spids: [194]
                )
              ]
            )
          ]
        )
      ]
    )
)