SCCS Version Control Software Implementation Steps
In the previous article, we showed you how to install SCCS version control system on Linux. In this article, we’ll demonstrate SCCS version control Software Implementation on a file .
SCCS Version Control Software Implementation Steps
To demonstrate how SCCS works I’ll be using a small perl script named hello.pl
[root@sahil-centos my_scripts]# cat hello.pl #!/usr/bin/perl -w # use strict; my @ls=`ls -l /tmp`; foreach (@ls) { print $_ ; }
SCCS has four major sub-commands which are as follows
- create: Initialize the history file and first version, as described above.
- edit :Check out a writable version (for editing). SCCS retrieves a writable copy with you as the owner and places a lock on the history file so that no one else can check in changes.
- delta: Check in your changes. This is the complement to the SCCS edit operation. Before recording your changes, SCCS prompts for a comment, which it then stores in the history file version log.
- get: Retrieve a read-only copy of the file from the s.file. By default, this is the most recent version.
- prt: Display the version log, including comments associated with each version.
We’ll now be applying version control on our Perl script and walking you through using the SCCS sub-commands mentioned above and a few other SCCS sub-commands.
SCCS create Command
- The sccs create command places your file under SCCS control.
- It creates a new history file and uses the complete text of your source file as the initial version.
By default, the history file resides in the SCCS sub-directory created in the same directory in which the file placed under SCCS control resides.
Let’s bring under Perl script under SCCS control.
[root@sahil-centos my_scripts]# sccs create hello.pl hello.pl: No id keywords (cm7) 1.1 9 lines No id keywords (cm7)
The output from SCCS tells you the name of the created file, its version number (1.1), and the number of lines in this initial version of the file.
To prevent the accidental loss or damage to an original, SCCS create makes a second link to it, prefixing the new filename with a comma referred to as the comma-file.
When the history file has been initialized successfully, SCCS retrieves a new, read-only version.
[root@sahil-centos my_scripts]# ls -l total 12 -rwxr-xr-x. 1 root root 87 Nov 15 18:06 ,hello.pl -r-xr-xr-x. 1 root root 87 Nov 15 18:07 hello.pl drwxr-xr-x. 2 root root 4096 Nov 15 18:07 SCCS
You can see that a file named ,hello.pl has been created by SCCS along with a directory named SCCS.
If we look under the SCCS directory we’ll find the history file which is in fact just another flat file.
To distinguish the history file from a current version, SCCS uses the `s.’ prefix.
Owing to this prefix, the history file is often referred to as the s.file (s-dot-file).
[root@sahil-centos my_scripts]# cd SCCS [root@sahil-centos SCCS]# ls s.hello.pl [root@sahil-centos SCCS]# cat s.hello.pl h14751 s 00009/00000/00000 d D 1.1 16/11/15 18:07:26 root1 0 c date and time created 16/11/15 18:07:26 by root e u U f e 0 G r t T I 1 #!/usr/bin/perl -w # use strict; my @ls=`ls -l /tmp`; foreach (@ls) { print $_ ; } E 1
The SCCS edit command
Before you can edit the file, you must check it out using the sccs edit command. We’ll now check out the file hello.pl to make it writable and perform some updates.
[root@sahil-centos my_scripts]# sccs edit hello.pl 1.1 new delta 1.2 9 lines [root@sahil-centos my_scripts]# vim hello.pl
After checking out the file with SCCS edit, we can use a text editor of our choice to modify the file.
Delta command
We use the sccs delta command to write or commit changes made to the file and also update the version of the file.
When you perform a delta operation you are prompted for comments. Here you can add a description of the modifications you made to the file.
[root@sahil-centos my_scripts]# sccs delta hello.pl comments? Added a new print statement No id keywords (cm7) 1.2 2 inserted 0 deleted 9 unchanged
Get command
In order to retrieve the latest version of the file and make it read-only again we use the SCCS get command. The file cannot be checked out again if we do not make it read-only first using sccs get.
[root@sahil-centos my_scripts]# sccs get hello.pl 1.3 12 lines No id keywords (cm7)
Prt command
This shows you the changes made thus far to the file.
[root@sahil-centos my_scripts]# sccs prt hello.pl SCCS/s.hello.pl: D 1.4 18/11/15 19:36:30 root 4 3 00000/00001/00011 removed a line D 1.3 17/11/15 19:31:31 root 3 2 00001/00000/00011 added another line D 1.2 17/10/15 19:27:06 root 2 1 00002/00000/00009 Added a new print statement D 1.1 17/12/15 18:07:26 root 1 0 00009/00000/00000 date and time created 17/11/15 18:07:26 by root
Delget command
This command combines delta and get operations into a single command.
Here is an example
[root@sahil-centos my_scripts]# sccs delget hello.pl comments? removed a line No id keywords (cm7) 1.4 0 inserted 1 deleted 11 unchanged 1.4 11 lines No id keywords (cm7)
Conclusion
In this article, we applied SCCS version control on a Perl script.
In the next article, we will see a few miscellaneous sccs command examples
Related Articles
Version Control System Installation
SVN Repository Installation and Configuration
Ansible Installation Steps in RHEL 7
Thanks for your wonderful Support and Encouragement