/// <summary>
        /// Create the command object that will be used to act on the repository.
        /// </summary>
        /// <returns>The command object that will be used to act on the
        ///     repository.</returns>
        /// <exception cref="Exception">TODO: Make a more specific exception</exception>
        /// <exception cref="NotImplementedException">If the command argument
        ///     is not implemented currently.  TODO: Implement the argument.</exception>
        public override ICommand CreateCommand()
        {
            ICSharpCode.SharpCvsLib.Commands.LogCommand logCommand;
            DirectoryInfo dir = new DirectoryInfo(Directory.GetCurrentDirectory());

            this.ParseOptions(this.unparsedOptions);
            try {
                Repository repository = Repository.Load(dir);
                if (null == repository || null == repository.FileContents)
                {
                    throw new CvsFileNotFoundException(
                              string.Format("Valid CVS\\Repository file not found in {0}",
                                            dir));
                }
                this.repository = repository.FileContents;
                Root root = Root.Load(dir);
                if (null == root || null == root.FileContents)
                {
                    throw new CvsFileNotFoundException(
                              string.Format("Valid CVS\\Root file not found in {0}",
                                            dir));
                }
                this.cvsRoot = new CvsRoot(root.FileContents);
            } catch (CvsFileNotFoundException e) {
                LOGGER.Error(e);
                ConsoleMain.ExitProgram("Not a CVS repository.", e);
            }

            CurrentWorkingDirectory = new WorkingDirectory(this.cvsRoot,
                                                           dir.FullName, this.repository);


            logCommand =
                new ICSharpCode.SharpCvsLib.Commands.LogCommand(
                    CurrentWorkingDirectory, folders);

            return(logCommand);
        }
        /// <summary>
        /// Create the command object that will be used to act on the repository.
        /// </summary>
        /// <returns>The command object that will be used to act on the
        ///     repository.</returns>
        /// <exception cref="Exception">TODO: Make a more specific exception</exception>
        /// <exception cref="NotImplementedException">If the command argument
        ///     is not implemented currently.  TODO: Implement the argument.</exception>
        public override ICommand CreateCommand () {
            ICSharpCode.SharpCvsLib.Commands.LogCommand logCommand;
            DirectoryInfo dir = new DirectoryInfo(Directory.GetCurrentDirectory());

            this.ParseOptions(this.unparsedOptions);
            try {
                Repository repository = Repository.Load(dir);
                if (null == repository || null == repository.FileContents) {
                    throw new CvsFileNotFoundException(
                        string.Format("Valid CVS\\Repository file not found in {0}",
                        dir));
                }
                this.repository = repository.FileContents;
                Root root = Root.Load(dir);
                if (null == root || null == root.FileContents) {
                    throw new CvsFileNotFoundException(
                        string.Format("Valid CVS\\Root file not found in {0}",
                        dir));
                }   
                this.cvsRoot = new CvsRoot(root.FileContents);
            } catch (CvsFileNotFoundException e) {
                LOGGER.Error(e);
                ConsoleMain.ExitProgram("Not a CVS repository.", e);
            }

            CurrentWorkingDirectory = new WorkingDirectory(this.cvsRoot,
                dir.FullName, this.repository);


            logCommand = 
                new ICSharpCode.SharpCvsLib.Commands.LogCommand(
                CurrentWorkingDirectory, folders);

            return logCommand;
        }
        /// <summary>
        /// Produce the report
        /// Alternate interface for when we are given a server cooection
        /// This is needed for the SharpCvsLib command line client
        /// </summary>
        public LogReport Run(ICommandConnection connection)
        {
           // read Root and Repository from local directory
            if (null == this.cvsRoot) {
                Manager manager = new Manager(localDirectory);
                Root root = (Root)manager.FetchSingle (localDirectory,
                    Factory.FileType.Root);
        
                this.cvsRoot = new CvsRoot(root.FileContents);
            }

            if (null == workingDirectory) {
                Manager manager = new Manager(localDirectory);
                Repository repository = (Repository)manager.FetchSingle (localDirectory,
                    Factory.FileType.Repository);

                this.workingDirectory = new WorkingDirectory(cvsRoot,
                    localDirectory,
                    repository.FileContents);
            }
        
            ILogCommand command;
            // Recursively add all cvs folders/files under the localDirectory
System.Console.WriteLine("GNE workingDirectory.WorkingPath = {0}", workingDirectory.WorkingPath);
System.Console.WriteLine("GNE localDirectory: {0}", localDirectory);
 //           if (Directory.Exists(workingDirectory.WorkingPath)) {
            if (Directory.Exists(localDirectory) && File.Exists(Path.Combine(localDirectory, "Repository"))) {
                workingDirectory.FoldersToUpdate = FetchFiles(localDirectory);
                command = 
                    new LogCommand(workingDirectory, this.workingDirectory.ModuleName, null);
            } else {
                command = 
// GNE - this wont compile                   new LogCommand(workingDirectory, this.workingDirectory.ModuleName);
                    new RLogCommand(workingDirectory, this.workingDirectory.ModuleName);
            }
    
            // add any date restrictions        
            if (hasStartDate && hasEndDate) {
            	command.AddInclusiveDateRange(startDate, endDate);
            } else if (hasStartDate) {
            	command.AddInclusiveDateStart(startDate);
            } else if (hasEndDate) {
            	command.AddInclusiveDateEnd(endDate);
            }
     
            // Initialse state machine
            curLogReport = new LogReport(); // this is what we are going to return to the caller
            curLogFile = new LogFile(this.cvsRoot);
            curLogRevision = new LogRevision();
            logState = LogState.WANT_FILE_HEADER_START;
             
            if (connection.GetType() == typeof(CVSServerConnection)) {
                CVSServerConnection cvsServerConnection = (CVSServerConnection)connection;
                cvsServerConnection.MessageEvent.MessageEvent += new EncodedMessage.MessageHandler(OnMessage);
            }
            command.Execute(connection);

            // return curLogReport but clear our reference to it
            LogReport report = curLogReport;
            curLogReport = null;
            return report;
        }