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

NAME

VCS::LibCVS::Datum::RevisionNumber - A CVS revision number.

SYNOPSIS

DESCRIPTION

Represents a CVS revision number, either a branch or regular one.

It accepts both regular branch numbers (1.4.2) and magic ones (1.4.0.2). This means that numbers of the form "0.x" are ambiguous. They are treated as revision numbers on the branch "0".

The revision number "0" is used for added files, as well as for one of the trunk branches.

I use the term "depth" to refer to the number of fields in a revision. I use the terms "ancestor" and "descendant" to refer to a relationship between two revisions, whereby the intervening revisions increase monotonically. Eg. 1.6 is an ancestor of 1.19 and of 1.6.4.5, but 1.19 and 1.6.4.5 are neither ancestors nor descendants of each other.

SUPERCLASS

VCS::LibCVS::Datum

CLASS ROUTINES

new()

$rev_num = VCS::LibCVS::Datum::RevisionNumber->new("1.2.4.5") $rev_num = VCS::LibCVS::Datum::RevisionNumber->new("1.2.0.4") $rev_num = VCS::LibCVS::Datum::RevisionNumber->new("1.2.4")

return type: VCS::LibCVS::Datum::RevisionNumber
argument 1 type: scalar string

Must be a valid CVS revision number.

INSTANCE ROUTINES

as_string()

$rev_str = $rev_num->as_string()

return type: string scalar

Returns the revision number as a string.

equals()

if ($rev_num1->equals($rev_num2)) {

return type: boolean
argument 1 type: VCS::LibCVS::Datum::RevisionNumber

Returns true if the revision numbers contain the same information.

is_branch()

if ($rev_num->is_branch()) { . . .

return type: boolean scalar

Return true if this is a branch revision number, false otherwise.

is_trunk()

if ($rev_num->is_trunk()) { . . .

return type: boolean scalar

Return true if this is a revision number for the trunk, false otherwise. A trunk revision number is one with only one field, like: "1", "2", . . .

is_import_branch()

if ($rev_num->is_import_branch()) { . . .

return type: boolean scalar

Return true if this is a branch revision number for an import branch, false otherwise. An import branch is one with an odd revision number, which is assumed to be the result of an import.

branch_of()

$branch_num = $rev_num->branch_of()

return type: VCS::LibCVS::Datum::RevisionNumber

Get the RevisionNumber for the branch on which this revision lives. If it's a branch revision number it throws an exception.

base_of()

$branch_num = $rev_num->base_of()

return type: VCS::LibCVS::Datum::RevisionNumber

Returns the RevisionNumber from which this branch starts. If it's the trunk or a non-branch revision, an exception is thrown.

first_revision_of()

$rev_num = $branch_num->first_revision_of()

return type: VCS::LibCVS::Datum::RevisionNumber

Returns the RevisionNumber of the first revision committed to this branch. This is not the same as the base of the branch, it's the branch number with a .1 appended.

get_predecessor()

$p_rev_num = $rev_num->get_predecessor()

return type: VCS::LibCVS::Datum::RevisionNumber

Return the revision number that immediately preceeds this one, it's youngest ancestor. Return undef if there isn't one. Throw an exception if this is a branch revision.

get_successor()

$p_rev_num = $rev_num->get_successor()

return type: VCS::LibCVS::Datum::RevisionNumber

Return the revision number on the same branch that immediately follows this one, it's eldest descendant. Throw an exception if this is a branch revision.

compare()

$diff = $rev_num1->compare($rev_num2)

return type: integer, one of VCS::LibCVS::Datum::RevisionNumber::COMPARE_*
argument 1 type: string or RevisionNumber object

Compares this revision number with the argument.

The meanings of the return values are:

COMPARE_EQUAL

They are the same revision number.

COMPARE_ANCESTOR

The argument is an ancestor of this.

COMPARE_DESCENDANT

The argument is a descendant of this.

COMPARE_POSSIBLE_ANCESTOR

The argument is possibly an ancestor of this.

COMPARE_POSSIBLE_DESCENDANT

The argument is possibly a descendant of this.

COMPARE_INCOMPARABLE

The argument is neither an ancestor, nor a descendant of this, and they aren't equal.

Both branch and regular revision numbers can be compared this way. A branch revision number is an ancestor of all revisions on it (except its base revision) and its subbranches. So 1.6.2 is an ancestor of 1.6.2.4, a descendant of 1.6, and incomparable with 1.7.

Branches that sprout from the same revision are possibly ancestors or descendants. However, this can't be known because of CVS's lazy branching. In this case, the values returned are COMPARE_POSSIBLE_ANCESTOR and COMPARE_POSSIBLE_DESCENDANT. For example, 1.11.4 is possibly and ancestor of 1.11.6.

It would be nice if 1.6 were a descendant of 1.6.2, since it's on that branch, but then we'd lose transitivity, because then we'd have 1.6.2 < 1.6, 1.6 < 1.7, but 1.6.2 and 1.7 are incomparable.

SEE ALSO

  VCS::LibCVS::Datum