예제 #1
0
        /// <summary>
        /// This is called for each Message response we receive from the cvs server.
        /// </summary>
        public void OnMessage(string message)
        {
     
//            System.Console.WriteLine(message);
 
             // for some reason the message handler is now preceeding 
            // each message with "cvs server: " so we need to strip this off first
            if (message.StartsWith("cvs server: "))
            {
                message = message.Substring(12);
            }

            // only process the lines starting with "M "        
            if (message.StartsWith("M ")) {
                // Strip of the leading "M "
                message = message.Substring(2);
                
                if (message.StartsWith(revisionEndPrefix)) {
                    // seperator between file and revision or between revisions
                    if (logState == LogState.WANT_FILE_HEADER_START) {
                        // ignore this (shouldn't happen)
                    }
                    else if (logState == LogState.WANT_FILE_HEADER || logState == LogState.WANT_FILE_DESCRIPTION) {
                        // this is the seperator between te file header and the first revision
                    }
                    else {
                        // seperator between revisions
                        curLogFile.AddRevision(curLogRevision);
                    }
                    curLogRevision = new LogRevision();
                    logState = LogState.WANT_REVISION;    
                }
                else if (message.StartsWith(fileEndPrefix)) {
                    // seperator between files
                    if (logState == LogState.WANT_FILE_HEADER_START) {
                        // ignore this (shouldn't happen)
                    }
                    else if (logState == LogState.WANT_FILE_HEADER || logState == LogState.WANT_FILE_DESCRIPTION) {
                        // file with no revisions
                        curLogReport.AddFile(curLogFile);
                    }
                    else {
                        // first add the revision
                        curLogFile.AddRevision(curLogRevision);
                        curLogRevision = new LogRevision();
                        // and now the file
                        curLogReport.AddFile(curLogFile);
                    }
                    curLogFile = new LogFile(this.cvsRoot);
                    logState = LogState.WANT_FILE_HEADER_START;    
                }
                else {
                    switch (logState) {
                        case LogState.WANT_FILE_HEADER_START:          // drop into WANT_FILE_HEADER
                        case LogState.WANT_FILE_HEADER_SYMBOLIC_NAMES: // drop into WANT_FILE_HEADER
                        case LogState.WANT_FILE_HEADER:
                            OnMessageHeader(message);
                            break;
                                    
                        case LogState.WANT_FILE_DESCRIPTION:
                            OnMessageDescription(message);
                            break;
                        
                        case LogState.WANT_REVISION:
                            OnMessageRevision(message);
                            break;
                    }
                }
            }
        }
예제 #2
0
		/// <summary>
		/// Adds a LogFile to the LogReport
		/// Only called when the LogReport is being constructed
		/// </summary>
		internal void AddFile(LogFile file)
		{
		    files.Add(file);
		}
예제 #3
0
        /// <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;
        }
예제 #4
0
 /// <summary>
 /// Adds a LogFile to the LogReport
 /// Only called when the LogReport is being constructed
 /// </summary>
 internal void AddFile(LogFile file)
 {
     files.Add(file);
 }