Setting up SCCS Version Control System Part 3

In the previous article, we showed you how to bring a file into SCCS control, modify it and commit the changes. In this article, we will go through a few more sccs commands to help us understand and use the tool to its optimal potential. Setting Up SCCS Version Control System Part – 3

Setting Up SCCS Version Control system (SCCS diffs)

sccs diffs shows pending uncommitted changes.

[root@sahil-centos my_scripts]# sccs diffs hello.pl
------- hello.pl -------

At that moment there were no pending uncommitted changes. So, let’s make an update to the file.

[root@sahil-centos my_scripts]# sccs edit hello.pl
1.3
new delta 1.4
12 lines

Now we’ll run sccs diffs again.

[root@sahil-centos my_scripts]# sccs diffs hello.pl
------- hello.pl -------
12d11
< print "testing \n";
[root@sahil-centos my_scripts]#

The above output confirms that we have made a change to the file but have not committed the change using sccs delta followed by sccs get.

sccs info

The sccs info command tells you which files are being edited at present.
This is useful to know to run before checking out a file to make sure that it’s not being edited by someone already.

[root@sahil-centos my_scripts]# sccs info
Nothing being edited

sccs sccsdiff

This command is used to compare changes between two versions/SIDs.

In the below example, we compare the changes between versions 1.1 and 1.2 of the file hello.pl.

[root@sahil-centos my_scripts]# sccs sccsdiff -r1.1 -r1.2 hello.pl

------- hello.pl -------
9a10,11
>
> print "Adding some text\n";

Retrieve an earlier version using sccs get

A critical function of any version control system is the ability to retrieve a previous version of the file.

In case of sccs we use the sccs get command to do so as shown in the following example

[root@sahil-centos my_scripts]# sccs get -k -r 1.3 -G hello_old.pl hello.pl
1.3
12 lines
[root@sahil-centos my_scripts]# cat hello.pl
#!/usr/bin/perl -w
#
use strict;

my @ls=`ls -l /tmp`;

foreach (@ls) {
print $_ ;
}

print "Adding some text\n";
[root@sahil-centos my_scripts]# cat hello_old.pl

l#!/usr/bin/perl -w
#
use strict;

my @ls=`ls -l /tmp`;

foreach (@ls) {
print $_ ;
}

print "Adding some text\n";
print "testing \n";

The above sccs get command retrieved version 1.3 of the file hello.pl and saved it as hello_old.pl.

The difference between the latest version and the retrieved older version could be noticed when we displayed the content of both files using the cat command. Setting Up SCCS Version Control System

sccs rmdel

The sccs rmdel command is used to delete a particular version of the file.

Let’s view the currently available versions of the file hello.pl using sccs prt.

[root@sahil-centos my_scripts]# sccs prt hello.pl
 SCCS/s.hello.pl:
 D 1.5   17/11/15 19:56:43 root  5 4     00000/00000/00011none
 D 1.4   17/11/15 19:36:30 root  4 3     00000/00001/00011removed a line
 D 1.3   17/11/15 19:31:31 root  3 2     00001/00000/00011added another line
 D 1.2   17/11/15 19:27:06 root  2 1     00002/00000/00009Added a new print statement
 D 1.1   17/11/15 18:07:26 root  1 0     00009/00000/00000date and time created 17/11/15 18:07:26 by root

it appears that we presently have five versions of the file available. Now we’ll remove versions 1.5 and 1.4 using sccs rmdel.

[root@sahil-centos my_scripts]# sccs rmdel -r 1.5 hello.pl
[root@sahil-centos my_scripts]#
[root@sahil-centos my_scripts]# sccs rmdel -r 1.4 hello.pl

Now let’s execute the sccs prt command again to view the current status of the file versions.

[root@sahil-centos my_scripts]# sccs prt hello.pl

SCCS/s.hello.pl:

D 1.3 17/11/15 19:31:31 root 3 2 00001/00000/00011
added another line

D 1.2 17/11/15 19:27:06 root 2 1 00002/00000/00009
Added a new print statement

D 1.1 17/11/15 18:07:26 root 1 0 00009/00000/00000
date and time created 17/11/15 18:07:26 by root

Notice that the entries for versions 1.4 and 1.5 are gone making version 1.3 as the latest version of the file available.

We can verify it by executing the sccs get command and checking the content of the file.

[root@sahil-centos my_scripts]# sccs get hello.pl
1.3
12 lines
No id keywords (cm7)
[root@sahil-centos my_scripts]# cat hello.pl
#!/usr/bin/perl -w
#
use strict;

my @ls=`ls -l /tmp`;

foreach (@ls) {
print $_ ;
}

print "Adding some text\n";
print "testing \n";

As confirmed by the above sccs get command output, version 1.3 is the most recent version of the file available.

A quick final tip

Consider the below error message.

[root@sahil-centos my_scripts]# sccs edit hello.pl
ERROR [SCCS/s.hello.pl]: writable `hello.pl' exists (ge4)

ge4:
"writable `...' exists"
For safety's sake, SCCS won't overwrite an existing g-file if it's writable.
If you don't need the g-file, remove it and rerun the get command.

I don’t recall checking out the file but from the above error, it’s clear that the file is currently in a writable state and therefore cannot be checked out.

When I  tried to run sccs get to make the file read-only again then that also didn’t work.

The workaround I found was to run the sccs delta command to check in an empty commit followed by sccs get to make the file read-only again.

It was only after following these steps was I able to check out the file for writing again.

[root@sahil-centos my_scripts]# sccs delta hello.pl
comments? none
No id keywords (cm7)
1.5
0 inserted
0 deleted
11 unchanged
[root@sahil-centos my_scripts]# sccs get hello.pl
1.5
11 lines
No id keywords (cm7)

Conclusion

This concludes the third and final article written thus far to familiarize you with the working of SCCS version control system. We hope that you found the setup and usage instructions presented in this series of articles interesting enough to give SCCS a try yourself.

Related Articles

Previous Article Implementation Steps

Software Installation Guide

Wiki

Thanks for your wonderful Support and Encouragement

Sahil Suri

I am a system administrator who loves to learn and share my knowledge with the community. I've been working in the IT industry since 2011.

Leave a Reply

Your email address will not be published. Required fields are marked *