Subject: Re: Source Control and Refactoring
> Rename the class in the repository, instead. I wouldn't suggest
> everybody rights to do this, however.
I don't thik that renaming in CVS repository is a good thing. You can
project if there are references to source file names in project (the
simplest example is #include "old-filename.h". To be confident that this
change won't break anything you can replace all occurences of
"old-filename.h" to "new-filename.h", but still you'll have problems
older versions of source code (won't compile/be executed properly by
I suggest to use CVS "correct" way: mv, cvs rm, cvs add. In order to
heavy refactoring I'm using simple script:
grep -c "$sFrom" -r . |
awk -v "sFrom=$sFrom" -v "sTo=$sTo" -v sTmpFile=$$
sFile = $1
sCount = $2
if(sCount == 0)
print "mv " sFile " " sTmpFile
iPos = index(sFile, sFrom);
if(iPos != 0)
print "cvs remove " sFile
gsub(sFrom, sTo, sFile);
print "sed \"s/" sFrom "/" sTo "/g\" <" sTmpFile " >"
if(iPos != 0)
print "cvs add " sFile
print "rm " sTmpFile
This script replaces all occurences of $1 to $2 including file names.
Typical usage is:
$ replace OldClassName NewBetterClassName | sh
Of course ALL references to OldClassName will be replaced - even in
documentation (if there is one in my XP projects :). This is safe way -
case of errors you can abandon changes in working repository (notice
there's no commit in replace script).
To be sure that such refactoring hasn't broken anything simply execute
suite after every replace usage (F9 under my vim IDE - most frequently
F-key on my keyboard :).
Dariusz Cieslak, tel. 505-670-010, cieslakd (at) wp.pl;
C, C++, Java, Python, PHP programmer; UML, OOA&D, Extreme
Direct access to this group with http://web2news.com