NAME

ArchWay::Util::TreeVersions - manage meta-data of project partner versions


SYNOPSIS

    use ArchWay::Util::TreeVersions;
    use Arch::Tree;
    my $tv = ArchWay::Util::TreeVersions->new(Arch::Tree->new);
    my $parent_entry = $tv->all->{$parent_version};
    $parent_entry->{type}    = "hidden";
    $parent_entry->{kinship} = "parent";
    $parent_entry->{role}    = "rotated";
    $parent_entry->{label}   = "Ancient Branch";
    my $some_entry = $tv->get($some_version);
    $tv->set('my@host--archive/cat--brn--0', kinship => "child");
    $tv->save;


DESCRIPTION

This class manages ./{arch}/+archway-versions file in the project tree.

The format of this file is one line ``version type kinship label'' for each tree log version (and possibly new unmerged partner versions too). Where type is integer: 0=hidden, 1=active, 2=new.


METHODS

The following class methods are available:

new, load, sync, save, all, get, set, type_choices, kinship_choices.

new
Constructs the object that deals with meta-data of partner versions.

load
Loads the state file and initializes the data. The old data (if any) is lost if not save'd earlier. This method, load, calls sync automatically. This method is called in constructor.

save
Saves the data to the state file.

sync
Synchronize the data with the actual log-versions of the tree. This adds all new (or all if no file initialy exists) versions. Every added version gets type=1, kinship=``remote'' and empty label.

all
Returns hashref (keys are versions) of hashes with keys: type, kinship and label, as described above. The returned data structure may be modified in place, but it is better to use entry method.

get version
Returns hashref with keys: type, kinship and label. Returns undef on unexisting version.

set version field-hash
Updates the existing version entry or adds a new one. field-hash is a possibly incomplete hash (not hashref) with keys: type, kinship and label. By default the kinship is ``remote'', type is ``new'', role is ``regular'' and label is empty.

All fields except for label are limited to a list of predefined values and there are certain constraints. For example, type can't be changed from and to ``new'', any version gets the value ``new'' when initially added, and it is possibly replaced with ``active'' automatically when synchronized with the real tree versions. Similarly with kinship ``self''.

type_choices current_value
Returns hash (actually ordered array of pairs) of all possible type choices given the current_value. The hash value is boolean meaning changeability.

kinship_choices current_value
Returns hash (actually ordered array of pairs) of all possible kinship choices given the current_value. The hash value is boolean meaning changeability.

role_choices current_value
Returns hash (actually ordered array of pairs) of all possible role choices given the current_value. The hash value is boolean meaning changeability.


BUGS

No known bugs.


AUTHORS

Mikhael Goikhman (migo@homemail.com--Perl-GPL/archway--devel)


SEE ALSO

For more information, see Arch::Tree.