# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 101302 2013-01-07 23:27:10Z ryandesign@macports.org $

PortSystem          1.0
PortGroup           python 1.0
PortGroup           app 1.0

name                tortoisehg
version             2.6.2
categories          devel python
platforms           darwin
license             GPL-2+
maintainers         nomaintainer
supported_archs     noarch

description         A set of graphical tools for Mercurial

long_description    A set of graphical tools for the Mercurial distributed \
                    revision control system.

homepage            http://tortoisehg.bitbucket.org/
master_sites        http://bitbucket.org/tortoisehg/targz/downloads/

checksums           rmd160  be61874ca580507130c9c580ca3b182366da1148 \
                    sha256  f079488fea008bb4f73a5dbb9b80e523c87355d0b9ea34e38e78fbd5724dd609

python.default_version 27

depends_lib         port:mercurial \
                    port:py${python.version}-pyqt4 \
                    port:py${python.version}-qscintilla \
                    port:py${python.version}-iniparse

depends_build       port:py${python.version}-sphinx

post-extract {
    copy ${filespath}/config.py ${worksrcpath}/tortoisehg/util/
}

patchfiles          patch-setup.py.diff

post-patch {
    reinplace "s|{prefix}|${prefix}|" ${worksrcpath}/tortoisehg/util/config.py
    reinplace "s|{python.prefix}|${python.prefix}|" ${worksrcpath}/tortoisehg/util/config.py
}

python.link_binaries_suffix

post-destroot {
    system -W ${worksrcpath}/doc "make SPHINXBUILD=sphinx-build-${python.branch} html"
    copy ${worksrcpath}/doc/build/html ${destroot}${prefix}/share/doc/${name}/html

    xinstall -m 644 -W ${worksrcpath} COPYING.txt ${destroot}${prefix}/share/doc/${name}
}

app.name            TortoiseHg
app.executable      ${workpath}/${app.name}
app.icon            icons/thg_logo_92x50.png

platform macosx {
    post-extract {
        copy ${filespath}/${app.name}.in ${workpath}/${app.name}
    }
    post-patch {
        reinplace "s|@PREFIX@|${prefix}|g" ${workpath}/${app.name}
    }
}

livecheck.type      regex
livecheck.url       ${homepage}download/source.html
livecheck.regex     ${name}-(\[0-9.\]+)${extract.suffix}
