Saturday, March 01, 2008

Dev : Replace CVS Files, All Files

Windows file REPLACE command is something very useful that every person should know, esspecially for developers. Let me try elaborate using a scenario.

Using Tortoise CVS in windows to backup as well as managing source code versioning is a life saving attemped. It can help you to know who commited what and most of all, it is free.

But then, what if one day, your source code administrator sends all developers an email :
"Hi,

From today onwards, all CVS source code in SUN server will be moved to MOON server due to disk space issue. Please change your workstation's settings accordingly.

Thanks.

From,
Admin."

For the time being, I wouldn't know if there is any other ways to make life easier on this matter. All my source code are pointing towards SUN and now you say MOON? Yeah right, easy for you to say... But first of all, how?

By knowing the behaviour of Tortoise CVS, like every developer knows, there will be a hidden folder called "CVS" in each folder that is using CVS for versioning control in your workstation. But what you should really know is that is what's in it. For the time being, lets get straight to the point.

In each hidden CVS folder, there will be a file called Root. The content of Root might appear differently depending on what CVS authentication you use. As example, ":sspi:mydomain\cksgary@sun:/cvs". Notice that the word "sun" behind "@"? This is the keyword. Just replace the sun with moon. But yet, that is not enough. Because there are more than 2 thousand subfolders that contain this Root file. It is not possible for me to change one by one even if I sacrifice my whole day doing this.

And here comes the real life saver. Using windows REPLACE command really helped out. Just follow the steps below :

1. Ok, lets say your working folder is "D:\work". Make a copy of this Root file in "D:\". Please make sure that it is renamed exactly the same as in the working one. Change the content accordingly.
2. Go to "START --> RUN --> type CMD". This will open a command prompt console for you.
3. Type "REPLACE D:\Root D:\work /s". This will then start replacing all files with the name of Root in all folders and subfolders in "D:\work" with the "d:\Root" file.

3 steps, and you're done. This could be used in any other scenarios if there is a need to replace all files with the same name.

No comments: