The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Darcs::Inventory - Read and parse a darcs version 1 or 2 inventory file

SYNOPSIS

    use Darcs::Inventory;
    $i = Darcs::Inventory->new("path/to/repo");
    $i = Darcs::Inventory->load("path/to/repo/_darcs/inventory");
    for ($i->patches) {
        print $_->info;
    }
    $i->format; # contents of _darcs/format, or "old", or "unknown"
    $i->file;   # The path to the inventory file.

    @raw = Darcs::Inventory::read("_darcs/inventory");
    print $raw[0];         # Prints the unparsed contents of the
                           # first patch in the inventory file.

DESCRIPTION

    B<Darcs::Inventory> reads an inventory file and returns some
    information on it, including the parsed list of patches in the
    form of B<L<Darcs::Inventory::Patch>> objects.

FUNCTIONS

Darcs::Inventory->new("path/to/repo")

This reads the standard inventory from a darcs repo. Don't pass in the _darcs directory, that is implied. This will return an inventory object that you can use to do further queries.

Darcs::Inventory->load("path/to/repo/_darcs/inventory")

This reads a specific inventory file. It doesn't have to be inside a _darcs directory, that's just an example. This will return an inventory object just like new that you can use to do further queries.

$inventory->patches

Returns a list of Darcs::Inventory::Patch objects--one for each patch in the inventory.

$inventory->format

If the $inventory was created with the new function, then this will return the contents of the _darcs/format file, or "old" if there was no _darcs/format file in the repo.

If the $inventory was created with the load function, then this will always return "unknown".

Since this can be multiple lines, the general use case is probably something like:

 if ($inventory->format =~ /hashed/) its_a_hashed_repo();
$inventory->file

This returns the path that was loaded. This is really only helpful with inventory objects created by the new function since darcs repos store the inventory in _darcs/inventory or _darcs/hashed_inventory based on the format.

Darcs::Inventory::read("path/to/repo")

This returns a list of strings. Each string is the raw lines of the inventory file split on patch boundaries, but not yet parsed.

This is probably not very useful to you unless you are doing something crazy.

LIMITATIONS

Currently the new function only loads in the main inventory file. This means it will generally only read patches until the last tag. Darcs moves patches past the last tag into separate inventory files as some sort of optimization. This means if you are trying to diff inventories with Darcs::Inventory::Diff that you can only diff until the last tag.

Currently the load function does not handle darcs repos in the new style _darcs/inventories/ directory. These file are compressed and I haven't yet needed to write the code to deal with them.

SEE ALSO

Darcs::Inventory::Patch

COPYRIGHT

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Copyright (C) 2007-2012 David Caldwell

AUTHOR

David Caldwell <david@porkrind.org>