NAME

VcsTools::File - Perl class to manage a VCS file.

SYNOPSIS

my %dbhash;
tie %dbhash,  'MLDBM',    $file , O_CREAT|O_RDWR, 0640 or die $! ;

require VcsTools::DataSpec::HpTnd ;
my $ds = new VcsTools::DataSpec::HpTnd ;
my $fileO = new VcsTools::File (dbHash => \%dbhash,
                                keyRoot => 'root',
                                vcsClass => 'VcsTools::HmsAgent',
                                hmsHost => 'hptnofs',
                                hmsDir =>'adir',
                                hmsBase => 'abase',
                                hmsHost => 'hptnofs',
                                name => 'dummy.txt',
                                workDir => $ENV{'PWD'},
                                dataScanner => $ds ,
                                fileAgentClass => 'VcsTools::FileAgent',
                                processClass => 'dummyP'
                               );

DESCRIPTION

This class represents a VCS file. It holds all the interfaces to the "real" world and the history object (See VcsTools::History)).

History object contains 2 buttons to check and/or modify the some features of the file (writable or locked)

Furthermore File object adds some bindings and menu to History's GraphWidget to offer more functionnalities from the GUI.

CAVEATS

The file must contain the $ Revision $ VCS keyword.

WIDGET USAGE

The File widget contains a sub-window featuring:

  • A revision label to indicate the revision of the current file.

  • A 'writable' check button, which indicated the status of the file and is able to change its mode.

  • A 'locked'check button, which indicated the lock status of the file and is able to change its lock.

By default, all these widget are disabled until the user performs a File->check through the menu.

The File menu contains several commands :

  • open history: Will open the history menu.

  • check: to get the revision, mode, and lock status of the current file.

  • archive: to archive the file (Enabled only if the file is writable).

  • edit: to edit the file (Enabled only if the file is writable).

The File object will add some functionnalities to the History object while opening it :

  • A 'merge' global menu: To perform a merge on 2 selected revision.

  • A 'show diff' global menu: To show a diff between 2 selected revision.

  • Button 2 is bound to arrows to show the diff between the 2 revisions next to the arrow.

  • A 'show diff' command is also added to the arrow popup menu. =item *

    Button 2 is bound to nodes to show the content of this revision.

Constructor

new('name'=> '...', ...)

Will create a new File object.

Parameters are those of Puppet::Any(3) plus :

  • dataScanner : VcsTools::DataSpec::HpTnd (or equivalent) object reference.

  • vcsClass : class name of the VCS interface.

  • processClass : class name of the VCS interface.

  • workDir : Absolute directory where the file is.

One of the following 2 parameters must be passed to the constructor:

  • fileAgentClass: class name of the file interface.

  • fileAgentClass: object reference of the file interface.

Generic methods

display()

Will launch a widget for this object.

createProcess( ... )

Will create a new process interface class. All arguments are forwarded to the process constructor. This function will also specify a 'workDir' argument to the constructor.

check(callback => ...)

check r/w permission, revision and lock state of the file

The file must contain the $ Revision $ keyword.

archiveFile(info_hash_ref, [revision])

Will archive the file using the optional info hash ref as a template for the history editor. By default the revision to archive is a revision below the revision of the physical file.

History handling methods

createHistory()

Will create a VcsTools::History object for this file.

openHistory()

Will create a VcsTools::History object for this file and open its display.

guessNewRev(revision)

Will return a "next" revision number from the input parameter taking into account all revisions that already exist.

For instance :

  • guessNewRev(1.2) returns 1.3 if 1.3 doesn't exist

  • guessNewRev(1.2) returns 1.2.1.1 if 1.3 already exists

  • guessNewRev(1.2) returns 1.2.2.1 if 1.3 and branch 1.2.1 already exist

Handling the real file

createFileAgent()

Create the file Agent class.

edit()

Will launch a window editor.

getRevision(callback => sub ... )

Will read the revision of the current file.

Callback will be called with (1, revision) in case of success or (0, error_string) in case of problems.

checkWritable(callback => sub ... )

Will check whether the file is writable or not.

Callback will be called with (1,1) if the file is writable, (1,0) if the file is read only and (0, error_string) in case of problems.

chmodFile([writable => 1|0],callback => sub ... )

Will change the file mode to writable or not.

Callback will be called with (1) if chmod was done and with (0, error_string) in case of problems.

wrFileRev(name => 'foo', revision => 'x.y' , callback => sub ... )

Write the content of revision x.y into file foo.

Callback will be called with (1) if the file was written and with (0, error_string) in case of problems.

Handling the VCS part

createVcsAgent()

Create the VCS interface class.

checkLock(callback => sub ... )

See "Methods" in VcsTools::HmsAgent

changeLock([lock => 1|0], callback => sub ... )

See "Methods" in VcsTools::HmsAgent

checkOut(lock => 1|0, callback => sub ... )

See "Methods" in VcsTools::HmsAgent

getContent(revision => 'x.y', 'callback' => sub_ref)

See "Methods" in VcsTools::HmsAgent

head2 archiveHistory(...)

See "Methods" in VcsTools::HmsAgent

getLog(callback => sub ref)

See "Methods" in VcsTools::HmsAgent

showDiff('rev1' => 'x.y', [rev2 => 'y.z'], callback => sub ref)

See "Methods" in VcsTools::HmsAgent

checkIn(...)

See "Methods" in VcsTools::HmsAgent

merge(revision1, revision2)

Will open a GUI to merge the 2 revisions. Will use xemacs ediff merge to perform the actual merge.

AUTHOR

Dominique Dumont, Dominique_Dumont@grenoble.hp.com

Copyright (c) 1998 Dominique Dumont. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

perl(1), Tk(3), Puppet::Any(3), VcsTools::DataSpec::HpTnd(3), VcsTools::Version(3), VcsTools::File(3)