[darcs-devel] [issue1484] --number and --index that counted from the beginning

Trent W. Buck bugs at darcs.net
Fri Jun 11 03:19:06 UTC 2010


Trent W. Buck <trentbuck at gmail.com> added the comment:

Zooko mentioned this ticket in IRC, so for posterity I'm posting on it
the relevant kludges that I quickly concocted in response.

Zooko wrote:
> So the problem is: given a version number emitted by Tahoe when you
> run "Tahoe --version", how do you recreate the source code that was
> used to build this version of Tahoe, or at least tell which patches
> went into it, or at least which of the official versions from your
> official repository it was, if it was one of those?

Assuming you know what repository it was, you might say (where
Version: 0.6.0+3 and the repo is http://example.net/foo)

    darcs get http://example.net/foo --tag 0.6.0
    darcs pull --repo foo <<<yyyd

In readline (e.g. bash), you can enter 123 y's with M-1 M-2 M-3 y.

Zooko also wrote (in IRC):
> The issue that is irritating me right at the moment is that I can't
> say: DARCS! What was the 1000th patch added to this repo!

I can (ab)use XSLT for this, see the following transcript.

Considering the following test repository:

    $ darcs init
    $ for i in {1..8}; do date --rfc-3339=ns >x; darcs rec -lam$i x; ((i % 3)) || darcs tag 0.$i.0; sleep 1; done &>/dev/null
    $ darcs cha
    Fri Jun 11 13:09:07 EST 2010  Trent W. Buck <trentbuck at gmail.com>
      * 8

    Fri Jun 11 13:09:06 EST 2010  Trent W. Buck <trentbuck at gmail.com>
      * 7

    Fri Jun 11 13:09:04 EST 2010  Trent W. Buck <trentbuck at gmail.com>
      tagged 0.6.0

    Fri Jun 11 13:09:04 EST 2010  Trent W. Buck <trentbuck at gmail.com>
      * 6

    Fri Jun 11 13:09:03 EST 2010  Trent W. Buck <trentbuck at gmail.com>
      * 5

    Fri Jun 11 13:09:02 EST 2010  Trent W. Buck <trentbuck at gmail.com>
      * 4

    Fri Jun 11 13:09:01 EST 2010  Trent W. Buck <trentbuck at gmail.com>
      tagged 0.3.0

    Fri Jun 11 13:09:01 EST 2010  Trent W. Buck <trentbuck at gmail.com>
      * 3

    Fri Jun 11 13:09:00 EST 2010  Trent W. Buck <trentbuck at gmail.com>
      * 2

    Fri Jun 11 13:08:59 EST 2010  Trent W. Buck <trentbuck at gmail.com>
      * 1

We have a end-user version string of:

    $ echo Version: $(darcs show tags | head -1)+$(darcs changes --count --from-tag .)
    Version: 0.6.0+3

The nth patch, counting from one in ascending commit chronology:

    $ darcs cha --xml --reverse | xmlstarlet sel -t -c //patch[2]
    <patch author="Trent W. Buck &lt;trentbuck at gmail.com&gt;" date="20100611030900" local_date="Fri Jun 11 13:09:00 EST 2010" inverted="False" hash="20100611030900-c31ef-c547fd0e979b3908eec60f7a8b46f283f2cc2a93.gz">
            <name>2</name>
            <comment>Ignore-this: c854c3f7ed4fa967d35183bbc82d985d</comment>
    </patch>

The nth patch, counting from the tag in question:

    $ darcs change --from-tag 0.6.0 --xml --reverse | xmlstarlet sel -t -c '//patch[3]'
    <patch author="Trent W. Buck &lt;trentbuck at gmail.com&gt;" date="20100611030907" local_date="Fri Jun 11 13:09:07 EST 2010" inverted="False" hash="20100611030907-c31ef-3d37f439d1067d5fb8e9973500ba925e9ce9e755.gz">
            <name>8</name>
            <comment>Ignore-this: a5944b55afbfb44b83ccff44bf7346a6</comment>
    </patch>

    $ darcs change --from-tag 0.6.0 --xml | xmlstarlet sel -t -c '//patch[last() - 2]'
    <patch author="Trent W. Buck &lt;trentbuck at gmail.com&gt;" date="20100611030907" local_date="Fri Jun 11 13:09:07 EST 2010" inverted="False" hash="20100611030907-c31ef-3d37f439d1067d5fb8e9973500ba925e9ce9e755.gz">
            <name>8</name>
            <comment>Ignore-this: a5944b55afbfb44b83ccff44bf7346a6</comment>
    </patch>

----------
nosy: +twb

__________________________________
Darcs bug tracker <bugs at darcs.net>
<http://bugs.darcs.net/issue1484>
__________________________________


More information about the darcs-devel mailing list