Using Working Folders in Version Control

[article]
Source Control HOWTO - Chapter 5

last for long.  I will be making changes to some of the files in my working folder, so it will be "newer" than the repository.  Other developers may be checking in their changes to the repository, thus making my working folder "out of date."  My working folder is going to be new and old at the same time.  Things are going to get confusing.  The SCM tool is responsible for keeping track of everything.  In fact, it must keep track of the state of each file individually.

For housekeeping purposes, the SCM tool usually keeps a bit of extra information on the client side.  When a file is retrieved, the SCM client stores its contents in the corresponding working file, but it also records certain information for later.  Examples:

  • Your SCM tool may record the timestamp on the working file, so that it can later detect if you have modified it. 
  • It may record the version number of the repository file that was retrieved, so that it may later know the starting point from which you began to make your changes. 
  • It may even tuck away a complete copy of the file that was retrieved, so that it can show you a diff without accessing the server.

I call this information "hidden state information."  Its exact location depends on which SCM tool you are using.  Subversion hides it in invisible subdirectories in your working directory.  Vault can work similarly, but by default it stores hidden state information in the current user's "Application Data" directory.

Working File States

Because of the changes happening on both the client and the server, a working file can be in one of several possible states.  SCM tools typically have some way of displaying the state of each file to the user.  Vault shows file states in the main window.  CVS shows them in response to the 'cvs status' command.

The table below shows the possible states for a working file.  The column on the left shows my particular name for each of these states, which through no coincidence is the name that Vault uses.  The column on the far right shows the name shown by the 'cvs status' command.  However, the terminology doesn't really matter.  One way or another, your SCM tool is probably keeping track of all these things and can tell you the state of any file in your working folder hierarchy.

Refresh

State Name

Has the working file been modified?

Does the repository have a newer version than the last one retrieved?

Remarks

'cvs status'

None

No

No

The working file matches the latest version in the repository.

Up-to-date

Old

No

Yes

 

Needs Patch

Edited

Yes

No

 

Locally Modified

Needs Merge

Yes

Yes

 

Needs Merge

Missing

N/A

N/A

The working file does not exist.

Needs Checkout

Renegade

Yes

No

You have modified a file without first checking it out.

N/A

Unknown

No

No

There is a working file, but the SCM tool has no hidden state information about it.

Unknown

In order to keep all this file status information current, the SCM client must have ways of staying up to date with everything that is happening.  Whenever something changes in the working folders or in the repository, the SCM client wants to know.

Changes in the working folders on the client side are relatively easy.  The SCM client can quickly scan files in the working folders to determine what has changed.  On some operating systems, the client can register to be notified of changes to any file.

Notification of changes on the server can be a bit trickier.  The

About the author

TechWell Contributor's picture TechWell Contributor

The opinions and positions expressed within these guest posts are those of the author alone and do not represent those of the TechWell Community Sites. Guest authors represent that they have the right to distribute this content and that such content is not violating the legal rights of others. If you would like to contribute content to a TechWell Community Site, email editors@techwell.com.

AgileConnection is one of the growing communities of the TechWell network.

Featuring fresh, insightful stories, TechWell.com is the place to go for what is happening in software development and delivery.  Join the conversation now!

Upcoming Events

Sep 24
Oct 12
Nov 09
Nov 09