NAME

VCS::SCCS - OO Interface to SCCS files

SYNOPSIS

use VCS::SCCS;

my $sccs = VCS::SCCS->new ("SCCS/s.file.pl");   # Read and parse

# Meta info
my $fn = $sccs->file ();            # s.file.pl
my $cs = $sccs->checksum ();        # 52534
my @us = $sccs->users ();           # qw( merijn user )
my $fl = $sccs->flags ();           # { q => "Test applic", v => undef }
my $cm = $sccs->comment ();         # ""
my $cr = $sccs->current ();         # 70
my @cr = $sccs->current ();         # ( 70, "5.39", 5, 39 )

# Delta related
my $xx = $sccs->delta (...);   -- NYI --
my $vs = $sccs->version ();         # "5.39"
my $vs = $sccs->version (69);       # "5.38"
my $rv = $sccs->revision ();        # 70
my $rv = $sccs->revision ("5.37");  # 68
my $rm = $sccs->revision_map ();    # [ [ 1, "4.1" ], ... [ 70, "5.39" ]]

# Content related
my $body_70 = $sccs->body ();       # file.pl @70 incl NL's
my @body_70 = $sccs->body ();       # file.pl @70 list of chomped lines
my @body_69 = $sccs->body (69);     # same for file.pl @96
my @body_69 = $sccs->body ("5.38"); # same
-- NYI --
my $diff = $sccs->diff (67);        # unified diff between rev 67 and 70
my $diff = $sccs->diff (63, "5.37");# unified diff between rev 63 and 68

DESCRIPTION

SCCS was the dominant version control system until the release of the Revision Control System. Today, SCCS is generally considered obsolete. However, its file format is still used internally by a few other revision control programs, including BitKeeper and TeamWare. Sablime[1] also allows the use of SCCS files. The SCCS file format uses a storage technique called interleaved deltas (or the weave). This storage technique is now considered by many revision control system developers as key to some advanced merging techniques, such as the "Precise Codeville" ("pcdv") merge.

This interface aims at the possibility to read those files, without the need of the sccs utility set, and open up to the possibility of scripts that use it to convert to more modern VCSs like git, Mercurial, CVS, or subversion.

FUNCTIONS

Meta function

new (<file>)

The constructor only accepts a single argument: the SCCS file. this will typically be something like SCCS/s.file.c.

If anything in that file makes new () believe that it is not a SCCS file, it will return undef. In this stage, there is no way yet to tell why new () failed.

file

Returns the name of the parsed file. Useful if you have more than a single $sccs object.

checksum

Returns the checksum that was stored in the file. This module does not check if it is valid, nor does it have functionality to calculate a new checksum.

users

Returns the list of users that was recorded in this file as authorized to make deltas/changes.

flags

Returns a hash of the flags set for this file (if set at all). VCS::SCCS does not do anything with these flags. They are here for the end-user only.

Note that not all flags are supported by all versions of admin, like x is supported on HP-UX, but not in CSSC.

t <type of program>

File has a user defined value for the %Y% keyword.

v [<program name>]

File was flagged to prompt for MR (using <program name> for validation).

i <keyword string>

File was flagged to require id keywords.

b

File was allowed to pass -b to get to create branch deltas.

m <module name>

File has a user defined value for the %M% keyword.

f <floor>

File was given a floor: the lowest release, a number from 1 to 9998, which may be get for editing.

c <ceiling>

File was given a ceiling: a number less than or equal to 9999, which can be retrieved by a get command.

d <default sid>

File was given a default delta number SID.

n

File created null deltas for skipped major versions.

j

File was flagged to allow concurrent edits on the same SID.

l <lock releases>

File was given a list of releases to which deltas can no longer be made.

q <user defined text>

File has a user defined value for the %Q% keyword.

x

File was flagged to set execution bit on get.

z <reserved for use in interfaces>

File was flagged to set execution bit on get.

comment

The comment that was added when the file was created.

current

In scalar context returns the current revision number. That is the number of the file that would be restored by get with no arguments.

In list context, it returns the current revision, version and parts of the version, something like (70, "5.39", 5, 39, undef, undef). The last 4 numbers are the equivalent of the keywords %R%, %L%, %B%, and %S% for that release.

set_translate (<type>)

By default VCS::SCCS will not translate the SCCS keywords (like %W%), see translate () for the full list. With set_translate (), you can select a translation type: SCCS and RCS are currently the only supported types, CVS and GIT are planned. Passing a false argument will reset translation to none.

Delta functions

delta =item delta (<revision>) =item delta (<version>)

If called without argument, it returns the delta of the last revision as a hashref.

If called with a revision argument, it returns you the delta of that revision. If there is no such revision, returns undef.

If called with a version argument, it returns you the delta of that version. If there is no such version, returns undef.

The elements of the hash returned are:

lines_ins

The number of lines inserted in this delta

lines_del

The number of lines deleted in this delta

lines_unc

The number of lines unchanged in this delta

type

The type of this delta. Usually this will be a D, but it could also be a R, which has not (yet) been tested.

version

The version (SID) of this delta

release

The release number of this delta

level

The level number of this delta

branch

The branch number of this delta. Can be undef

sequence

The sequence number of this delta. Can be undef

date

The date this delta was submitted in YY/MM/DD format

time

The time this delta was submitted in HH:MM:SS format

stamp

The date and time elements converted to a unix time stamp

committer

The logname of the user that committed this delta

mr

The MR numbers of this delta, separated by ", "

comment

The comment as entered with this delta

version =item version (<revision>)

If called without argument, it returns the last version, just as the second return value of current () in list context.

If called with a revision argument, it returns you the version that matches that revision. It returns undef if no matching version is found.

revision =item revision (<version>)

If called without argument, it returns the last revision, just as current () returns in scalar context.

If called with a version argument, it returns you the revision that matches that version. It returns undef if no matching revision is found.

revision_map

Returns an anonymous list of revision - version pairs (in anonymous lists).

Content function

body =item body (<revision>) =item body (<version>)

In scalar context returns the full body for the given revision. If no revision is passed, the current (most recent) revision is used. If a version is passed, the matching revision will be used. If the is no matching version or revision, body () returns undef.

In list context, body () returns the list of chomped lines for the given revision.

body () will use the translation set by set_translate ().

diff

NYI

translate (<revision>, <text>)

Translate the SCCS keywords in the text passed using the plan set with set_translate ().

The SCCS keywords are

%M%

Module name: either the value of the m flag in the file (see flags), or if absent, the name of the SCCS file with the leading s. removed.

%I%

SCCS identification (SID) (%R%.%L%.%B%.%S%) of the retrieved text.

%R%

Release.

%L%

Level.

%B%

Branch.

%S%

Sequence.

%D%

Current date (YY/MM/DD).

%H%

Current date (MM/DD/YY).

%T%

Current time (HH:MM:SS).

%E%

Date newest applied delta was created (YY/MM/DD).

%G%

Date newest applied delta was created (MM/DD/YY).

%U%

Time newest applied delta was created (HH:MM:SS).

%Y%

Module type: value of the t flag in the SCCS file (see flags).

%F%

SCCS file name.

%P%

Fully qualified SCCS file name.

%Q%

The value of the q flag in the file (see flags).

%C%

Current line number. This keyword is intended for identifying messages output by the program such as --this should not have happened-- type errors. It is not intended to be used on every line to provide sequence numbers.

%Z%

The 4-character string @(#) @(#) recognizable by what (see what(1)).

%W%

A shorthand notation for constructing what(1) strings for HP?UX system program files. %W%=%Z%%M%horizontal-tab%I%

%A%

Another shorthand notation for constructing what(1) strings for non-HP-UX system program files. %A% = %Z%%Y% %M% %I%%Z%

SPECIFICATION

SCCS file format is reasonable well documented. I have included a manual page for sccsfile for HP-UX in doc/

EXAMPLES

See the files in examples/ for my attempts to start convertors to other VCSs

LIMITATIONS

As this module is created as a base for conversion to more useful and robust VCSs, it is a read-only interface to the SCCS files.

TODO

* improve documentation
* implement delta () and diff ()
* more tests
* sccs2rcs
* sccs2cvs
* sccs2git
* sccs2hg
* sccs2svn
* errors and warnings
* provide hooks to VCS::

DIAGNOSTICS

First errors, than diagnostics ...

SEE ALSO

SCCS - http://en.wikipedia.org/wiki/Source_Code_Control_System

CSSC - https://sourceforge.net/projects/cssc A GNU project that aims to be a drop-in replacement for SCCS. It is written in c++ and therefor disqualifies to be used at any older OS that does support SCCS but has no C++ compiler. And even if you have one, there is a good chance it won't build or does not bass the basic tests. I didn't get it to work.

VCS - http://search.cpan.org/dist/VCS

AUTHOR

H.Merijn Brand <h.m.brand@xs4all.nl>

COPYRIGHT AND LICENSE

Copyright (C) 2007-2007 H.Merijn Brand

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