distributable:
  url: https://www.mercurial-scm.org/release/mercurial-{{version.raw}}.tar.gz
  strip-components: 1
versions:
  url: https://www.mercurial-scm.org/release
  match: /mercurial-\d+\.\d+(\.\d+)?\.tar\.gz/
  strip:
    - /^mercurial-/
    - /\.tar\.gz/
dependencies:
  python.org: ~3.11
build:
  dependencies:
    gnu.org/make: '*'
  script:
    - make install-bin PREFIX={{prefix}}
    - make -C contrib/chg install PREFIX={{prefix}} HGPATH={{prefix}}/bin/hg HG={{prefix}}/bin/hg
    - run: cat $PROP >hgrc
      prop: |
        [pager]
        pager = less -FRX
      working-directory: ${{prefix}}/etc/mercurial
    - run: |
        mkdir -p {{prefix}}/share/man/man{1,5}
        install hg.1 {{prefix}}/share/man/man1/
        install hgignore.5 hgrc.5 {{prefix}}/share/man/man5/
      working-directory: doc
    - run: |
        sed -i.bak '1s|.*|#!/usr/bin/env python3|' hg
        rm hg.bak
      working-directory: ${{prefix}}/bin
  env:
    HGPYTHON3: 1
provides:
  - bin/hg
  - bin/chg
test:
  script:
    - hg init
    - hg --version | grep {{version.marketing}}
