CvsCheckout

From Pickwiki
Jump to navigationJump to search

HomePage >> BasicSource >> TclStack

A helper program to check out source from CVS

SUBROUTINE CVS.CHECKOUT(RTN, FILE, ITEM, OPTIONS)
***************************************************************************
* Program: CVS.CHECKOUT
* Author : Ian [[McGowan]]
* Date   : 11/08/2002
* Edited : 18:13:28 Nov 08 2002 By MCGOWAN
* Comment: Check to see if working file matches cvs version, warn
***************************************************************************
* $Id: CVS.CHECKOUT,v 1.7 2003/04/10 17:51:07 dsiroot Exp $

* $Log: CVS.CHECKOUT,v $
* Revision 1.7  2003/04/10 17:51:07  dsiroot
* mcgowan:Shorted verbage, -U option on cvs update
*
* Revision 1.6  2003/04/10 03:36:21  dsiroot
* mcgowan:Add more verbage
*
* Revision 1.5  2003/04/10 03:23:03  dsiroot
* mcgowan:Show version numbers
*
* Revision 1.4  2003/04/10 02:45:34  dsiroot
* mcgowan:Add more verbage to blind update
*
* Revision 1.3  2003/04/10 02:37:48  dsiroot
* mcgowan:Handle weird statuses better
*
* Revision 1.2  2003/04/10 02:18:02  dsiroot
* mcgowan:Show diff start and end

PROMPT ''
RTN=''
CALL CVS.GETDIR(DIR,FILE)
CALL CVS.STATUS(STAT.RTN,FILE,ITEM,'')
STATUS=STAT.RTN<1>
WORK.VER=STAT.RTN<2>
CVS.VER=STAT.RTN<3>

BEGIN CASE
    CASE STATUS='NOTINCVS'
        PRINT "New program"
    CASE STATUS='UPTODATE'
        PRINT "Working version (":WORK.VER:") matches CVS (":CVS.VER:")"
    CASE STATUS='MODIFIED'
        GOSUB UPDATE
    CASE 1
        PRINT "Unknown cvs status:":STAT.RTN
END CASE
RETURN

UPDATE:
    CALL CVS.DIFF(DIFF.RTN,FILE,ITEM,'')
    IF DIFF.RTN = '' THEN
        PRINT "CVS status says an update is required.  This may be "
        PRINT "because diff ignores changes in whitespace or CVS"
        PRINT "comments, or because the versions are different"
        PRINT
        PRINT "Working version=":WORK.VER:", CVS=":CVS.VER
        PRINT
        PRINT "An update may clear this up, proceed? ":
        INPUT YORN
        IF YORN = "Y" THEN
            E=\!cd \:DIR:\;cvs update -C \:ITEM
            EXECUTE E
        END
    END ELSE
        PRINT "Working version does not match cvs version"
        I=DCOUNT(DIFF.RTN,@AM)
        FOR F=1 TO I; PRINT "Diff:":DIFF.RTN<F>; NEXT F
        PRINT
        PRINT "Would you like to "
        PRINT "   U) pdate this item from cvs (losing changes), or"
        PRINT "   C) heckin the changes, or"
        PRINT " RTN) Do nothing"
        INPUT ACTION
        BEGIN CASE
            CASE ACTION='U'
                PRINT 'Are you sure you want to overwrite the working copy? ':
                INPUT YORN
                IF YORN='Y' THEN
                    *E=\!rm \:DIR:\/\:ITEM
                    *EXECUTE E
                    E=\!cd \:DIR:\;cvs update -C \:ITEM
                    EXECUTE E
                END
            CASE ACTION='C'
                CI.OPTIONS=''
                CALL CVS.CHECKIN(CI.RTN,FILE,ITEM,CI.OPTIONS)
            CASE 1
                PRINT 'No action taken'
        END CASE
    END
RETURN