|
|
|
CVSRestore A Java program to restore files in CVS |
|
|
|
This program was conceived and coded by Bert Szoghy, email: webmaster@quadmore.com
Last code update: August 15 2007
Last page update: August 15 2007
This Java SWING program will generate a bash script in order to restore a batch of files from a CVS Attic. This tool can be used with any CVS repository and can run on any machine that will be able to communicate with the CVS server you are targeting. CVSRestore will run on any OS as is using the Java Runtime version 1.5
CVSwas created following a serious bug encountered in a commercial product with a CVS interface which was found to accidentally delete 30 or 40 files at a time. Restoring one file takes several long and precise commands that are seldom used, and doing these several commands over and over will drive anyone crazy. Hence the creation of this program which was originally used in conjunction with another program which determined which files were missing.
This program should be very useful for developers who need to restore a file but are unfamiliar with CVS on Linux, as well as for CVS administrators to reduce scripting chores.
Download here
LICENSE
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General
Public License as published by the Free Software Foundation; version 3 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along with this program.
If not, please see http://www.gnu.org/licenses/.
HOW CVS WORKS FOR RESTORING FILES
For details on these operations, please refer to the "Cederqvist":
http://ftp.gnu.org/non-gnu/cvs/source/feature/1.12.13/cederqvist-1.12.13.pdf
Briefly, to restore a deleted file from an Attic directory in CVS, you first use the "CVS history" command which
will retrieve (among other things) the version number corresponding to the deletion (or "death") of the file.
To restore a file, you will need to specify the version number that precedes the version number corresponding to
the death of the file.
For example, if the history command provided you with the result:
R 2005-10-31 20:42 +0000 d00ddr 1.5 MyFile MyModule/MySubdirectory ==
This would indicate that we will want to restore version 1.4 in our script. Note that this is not trivial
as the file numbering in CVS is not decimal, the following are all valid CVS version numbers:
1.2, 1.1.2.2, 1.1.2.2.4.4 and so on...
It is therefore necessary to:
1) Concatenate a CVS history command for the file we wish to restore;
2) Communicate directly by SSH2 to the CVS server from the Java program;
3) Acquire the results received for the CVS history and assign it to a variable;
4) Parse the result to get the version number corresponding to the death of the file;
5) Cast the last number in the version number from a string to a number;
6) Subtract one from that number;
7) Reconcatenate the resulting number into a string to assemble a CVS checkout command for the resulting script;
8) Add asynchroneous threading to the application to make it respond well;
9) Print out the script.
Responses from the Linux server are also printed out at the end, for careful comparison.
ASSUMPTIONS
1) All files in the listbelong to the same CVS module (which you will need to specify in the connection window)
2) The format of the response to the "CVS history" command has 32 characters before the version number, for example:
R 2005-10-31 20:42 +0000 MyUsername 1.5.2.88 Ver00CD8111755406022.etx UML/Analyse ==
R 2005-10-31 20:42 +0000 MyUsername 1.5 Ver00CD8111755406022.etx UML/Analyse ==
As CVS servers are normally on a Linux box, you could replace the Java code that counts 32 characters with a
seperate command that used awk, for example replacing the command:
cvs -d /usr/local/cvs/sysdo history -cal evolution/Ver3B1E31119384328BE.etx
with:
cvs -d /usr/local/cvs/sysdo history -cal evolution/Ver3B1E31119384328BE.etx | awk '{ print $6 }'
... which will provide you with the desired version number directly. But this assumes you have awk
installed.
RECOMPILING THIS PROGRAM
The entire source code is included and it will compile using the Java SDK versions 1.5 or 1.4.2 as is.
There is a known Linux bug in threading with that Java version for threading in SWING resulting in an Xlib error
indcating "unexpected async reply" caused by the Sun SwingWorker threading on this app.
I recommend installing a 1.5 JRE side by side with the 1.4 if you have to keep version 1.4 on your Linux box.
This program was compiled with the Sun Java JDK 1.5.
The external Open Source library Ganymed is required and included in this project, so there is no classpath to
adjust.
More on Ganymed at:
http://www.ganymed.ethz.ch/ssh2/
RUNNING THE PROGRAM
If you unzip this directory to the C: drive on the Windows platform, and you have Java 1.5 installed, the two following commands in a DOS prompt will run the program:
cd C:\CVSRestore
java CVSRestore
This should bring up the Swing program:
Just follow the simple instructions to restore your files.
FEEDBACK
You can email me here.
OUR OTHER SOFTWARE
BabyTalk: Open Source text-to-speech in Java
BabyTalk Web: Open Source text-to-speech in Java SWING, with JAXB and Java Web Services, along with the Simpletext SQL database
FreeTTS demo using MBROLA for Windows
Sound recorder using Java Swing
Sound recorder with file upload to a web server using Java Swing
Quadmore Java to Microsoft SAPI bridge for Windows: Sun Java to Microsoft Speech API 5.1
Johanne's Time Organizer: Open Source time tracking in Powerbuilder
|
|
|
|