Niall Murphy <[email protected]> writes:

>> What about doing it in the other direction, that is, giving the
>> responsibility of inserting the "revision numbers" into your documents
>> to the build process, instead of darcs ?
>> The idea would be to use a Makefile that inserts in all your .tex
>> documents, a header based on the result of "darcs changes --last 1"
>> for instance. Would it solve the problem for you ?
>
> This has the same downside as my posthook script, namely: - that the
> source file only contains the correct patch number after a commit (if
> i want to check out the version with patches up to 135, but then open
> the file and see "Patch Num: 112" which upon compiling, gets
> corrected) and more irritatingly (dangerously?)

I tend to insert something like

    if darcs w -l 2&>-
    then printf " (edited)"
    fi

to denote that.  Here's a rst version I've used.  Note that it assumes
patches are chronologically ordered, which is emphatically NOT
guaranteed in a real repository.

    $(addsuffix .pdf,$(DOCUMENTS)): %.pdf: %.txt %.meta
            rst2pdf $<
    $(addsuffix .html,$(DOCUMENTS)): %.html: %.txt %.meta
            rst2html $< $@

    $(addsuffix .meta,$(DOCUMENTS)): %.meta: %.txt
    # Date of last patch to touch any direct dependency
            > $@ printf '.. |date| replace:: '
            darcs changes --xml --max=1 $^ | \
    >>$@ xmlstarlet sel -T -t -m /changelog/patch[1] -v @local_date -n
    # Number of patches that touch any direct dependency.
            >>$@ printf '.. |version| replace:: '
            darcs changes --count $^ | \
    >>$@ tail -1
    # Sorted list of authors of those patches.  Ignores .authorspellings.
            >>$@ printf '.. |authors| replace:: '
            darcs changes --xml $^ | \
    xmlstarlet sel -T -t -m /changelog/patch -v @author -n | \
    sed 's/ *<.*>//' | sort -u | \
    >>$@ paste -sd ,

I then have the foo.txt file ".. include: foo.meta".

In principle, multi-document sources should DTRT if you add something
like this (untested):

    foo.meta: bar.txt baz.txt

Or if your repo only contains one document, you can simply omit the $^s
and generate date/author list/versions for the entire repo.

It'd also be a good idea to include the start of the patch hash, e.g.

    darcs cha --max 1 --xml $^ |
    xmlstarlet sel -T -t -m /changelog/patch -v @hash |
    cut -c 22-27
    62b5c3

> While I understand that what I want to do is a bit against the theory
> of darcs, I really love the simplicity of darcs and would love to
> switch over.

See also http://bugs.darcs.net/issue1142

_______________________________________________
darcs-users mailing list
[email protected]
http://lists.osuosl.org/mailman/listinfo/darcs-users

Reply via email to