AutoMap and Version Control

Abstract

AutoMap Scripting

One great feature of AutoMap is its ability to use scripting. Essentially, the AutoMap scripting interface is very similar to a batch (.bat) file in that it specifys a set of commands to be run. This makes it very simple to test aspects of a script by simply trying the desired command using the command prompt.

The Windows Command Prompt

Those with background in Unix/Linux have a strong understanding of the command line. This is the *nix philosophy emphasizes creating small applications that work only in a command prompt or shell and then building from there. Windows works differently in that the GUI aspects such as application windows, the file manager and start bar all are connected directly at the operating system level. This makes the command prompt in Windows, essentially just another application.

This application called "cmd.exe" and can be run by going to the start menu -> Run and entering "cmd". This will open a windows command prompt and you can begin trying commands you might use for scripting.

Basic Windows Scripting

A very basic command to try is the "dir" command. The dir command will list everything in a directory. A very simple use of AutoMap is to dynamically add all the files in a directory to a project to be run. To do this, you could try the following command::

  dir /b "C:\Documents and Settings\username\My Documents\My Pictures\" > MyFileList.txt

This will do three things:

  1. It will list the files and directories in the path given in quotes.
  2. Only the filenames will be printed to the screen and not the full path.
  3. The output will be directed to a file in the current directory called "MyFileList.txt" by using the ">".

In AutoMap you would use the FileList replacement syntax instead of the "MyFileList.txt" in order to write to the FileList file that will be used to add files to the project. As you can see, a very simple command quickly allows you to add files to the project dynamically.

You can use other commands as well to accomplish the same basic tasks. In addition to this, you could use a scripting language such as Python or Perl to run a script and print to the page. For example, here is a quick Python script to do the same thing as above.::

  # filename is listdir.py
  import os

  directory = r"C:\Documents and Settings\username\My Documents\My Pictures\"
  
  for filename in directory:
      print filename

You would then be able to run the script using cmd.exe doing::

  python listdir.py > "MyFileList.txt"

As you can see, this is a very simple means of adding dynamic functionality to AutoMap.

Using CVS and AutoMap

CVS is a version control system that allows you to keep track of when files and folders change. This allows you to make a change one day and then rollback changes to any previous version you have committed to the CVS repository. A CVS repository is simply the location where CVS is storing the files and version information.

CVS has some GUI tools such as <http://toirtoisecvs.org> TortoiseCVS and <http://wincvs.com> WinCVS, but for AutoMap we can use the simple command line client. This allows you to use the command prompt to "talk" to CVS. If you have specific questions regarding how to use CVS, it is best to ask your system administrator for more information.

Due to the limited nature of this example and potential CVS configurations, we will make some assumptions regarding how the system running AutoMap is setup regarding CVS. The first thing we will assume is the command line client is installed and configured as part of the path. Next we will assume the CVS repository is not password protected.

CVS Check Out

To work with files from CVS you need to "check out" the files. The CVS command to check out files is::

  cvs co

When you check out a repository it downloads the current version of the files you requested in a folder. The folder is named the same as the folder you checked out by default. So, if you wanted to check out the docs folder from some application repository, the command might look like this::

  cvs co :pserver:anonymous@cvs.webworks.com:/root/apps/proj_x/docs/ .

This would create a "docs" directory in the current directory with all the files from CVS.

Putting it Together

Even with our limited knowledge of Windows shell scripting and CVS, we have all we need to use CVS within AutoMap. In CVS example above, we checked out the doc directory from a CVS repository. Before that we discussed grabbing all the files from a directory using the "dir" command. Now we will put it together for very simple, yet reliable system for generating output based on the latest version from a CVS repo. Here is what it looks like::

  cvs co :pserver:anonymous@cvs.webworks.com:/root/apps/proj_x/docs/ .
  dir docs\*.fm,*.doc /S/B > ${FileListPath}
  del docs

The first line checks out the repository to the the "docs" directory. The next line lists all the files recursively and writes them to the File List that AutoMap will use to add file to the project. The last line will delete the docs directory so the next time AutoMap runs will automatically check out the latest version.

This kind of script is meant to be for a group in Documents area of a Job. You can right click a job that has been created via a stationery and click the "Documents" tab to see where you can add documents, edit groups and add scripts. The example above could be copied and pasted directly in the script window for a group.

Conclusions

Hopefully you can see how powerful the scripting capability is for AutoMap. If you have anyone in your organization that can write a quick script to work with some files and then print the results as a list, then you have the power to create powerful systems using AutoMap. While not all writers will be interested in using this feature, system administrators, development teams and project managers should consider how AutoMap could be used to help in creating better content for users.

HelpCenter/Tips/VersionControl/AutoMap_and_CVS (last edited 2008-02-13 06:18:22 by localhost)