/// <summary> /// Process a new entry response. /// /// TODO: Copied implementation from CheckedInResponse, determine if this /// is correct or not. /// </summary> public override void Process() { string localPath = this.ReadLine(); string repositoryPath = this.ReadLine(); string entryLine = this.ReadLine(); PathTranslator orgPath = new PathTranslator (Services.Repository, repositoryPath); string fileName = orgPath.LocalPathAndFilename; Factory factory = new Factory(); Entry entry = (Entry) factory.CreateCvsObject(orgPath.CurrentDir, Entry.FILE_NAME, entryLine); Manager manager = new Manager (Services.Repository.WorkingPath); manager.Add (entry); }
/// <summary> /// Execute checkout module command. /// /// taken from: http://www.elegosoft.com/cvs/cvsclient.html /// add \n /// Response expected: yes. Add a file or directory. This uses any /// previous Argument, Directory, Entry, or Modified requests, if they /// have been sent. The last Directory sent specifies the working /// directory at the time of the operation. To add a directory, send the /// directory to be added using Directory and Argument requests. /// /// </summary> /// <example> /// /// C: Root /u/cvsroot /// . . . /// C: Argument nsdir /// C: Directory nsdir /// C: /u/cvsroot/1dir/nsdir /// C: Directory . /// C: /u/cvsroot/1dir /// C: add /// S: M Directory /u/cvsroot/1dir/nsdir added to the repository /// S: ok /// /// You will notice that the server does not signal to the client in any /// particular way that the directory has been successfully added. The client /// is supposed to just assume that the directory has been added and update /// its records accordingly. Note also that adding a directory is immediate; /// it does not wait until a ci request as files do. To add a file, send the /// file to be added using a Modified request. For example: /// /// C: Argument nfile /// C: Directory . /// C: /u/cvsroot/1dir /// C: Modified nfile /// C: u=rw,g=r,o=r /// C: 6 /// C: hello /// C: add /// S: E cvs server: scheduling file `nfile' for addition /// S: Mode u=rw,g=r,o=r /// S: Checked-in ./ /// S: /u/cvsroot/1dir/nfile /// S: /nfile/0/// /// S: E cvs server: use 'cvs commit' to add this file permanently /// S: ok /// /// Note that the file has not been added to the repository; the only effect /// of a successful add request, for a file, is to supply the client with a /// new entries line containing `0' to indicate an added file. In fact, the /// client probably could perform this operation without contacting the /// server, although using add does cause the server to perform a few more /// checks. The client sends a subsequent ci to actually add the file to the /// repository. Another quirk of the add request is that with CVS 1.9 and /// older, a pathname specified in an Argument request cannot contain `/'. /// There is no good reason for this restriction, and in fact more recent /// CVS servers don't have it. But the way to interoperate with the older /// servers is to ensure that all Directory requests for add (except those /// used to add directories, as described above), use `.' for local-directory. /// Specifying another string for local-directory may not get an error, but /// it will get you strange Checked-in responses from the buggy servers. /// </example> /// <param name="connection">Server connection</param> public void Execute(ICommandConnection connection) { connection.SubmitRequest(new ArgumentRequest(ArgumentRequest.Options.DASH)); int loops = 0; foreach (DictionaryEntry folderEntry in this.Folders) { LOGGER.Debug("loops=[" + loops++ + "]"); Folder folder = (Folder)folderEntry.Value; this.SetDirectory (connection, folder); // send each is-modified request foreach (DictionaryEntry entryEntry in folder.Entries) { Entry entry = (Entry)entryEntry.Value; //connection.SubmitRequest(new IsModifiedRequest(entry.Name)); //String fileName = Path.Combine(entry.Path, entry.Name); this.SendFileRequest (connection, entry); // Add the file to the cvs entries file Manager manager = new Manager(connection.Repository.WorkingPath); manager.Add(entry); if (LOGGER.IsDebugEnabled) { LOGGER.Debug("AddCommand. Entry=[" + entry + "]"); } } // send each argument request foreach (DictionaryEntry entryEntry in folder.Entries) { Entry entry = (Entry)entryEntry.Value; connection.SubmitRequest(new ArgumentRequest(entry.Name)); //String fileName = Path.Combine(entry.Path, entry.Name); //this.SendFileRequest (connection, entry); // Add the file to the cvs entries file Manager manager = new Manager(connection.Repository.WorkingPath); manager.Add(entry); if (LOGGER.IsDebugEnabled) { LOGGER.Debug("AddCommand. Entry=[" + entry + "]"); Entries entries = manager.FetchEntries(entry.FullPath); foreach (DictionaryEntry dicEntry in entries) { LOGGER.Debug("entry=[" + dicEntry.Value + "]"); } } } } connection.SubmitRequest(new AddRequest()); }
/// <summary> /// Process a created file response. /// </summary> public override void Process() { Manager manager = new Manager (Services.Repository.WorkingPath); String localPath = this.ReadLine(); String reposPath = this.ReadLine(); String entry = this.ReadLine(); String flags = this.ReadLine(); String sizeStr = this.ReadLine(); PathTranslator orgPath = new PathTranslator (Services.Repository, reposPath); String localPathAndFilename = orgPath.LocalPathAndFilename; String directory = orgPath.LocalPath; bool compress = sizeStr[0] == 'z'; if (compress) { sizeStr = sizeStr.Substring(1); } int size = Int32.Parse(sizeStr); if (!Directory.Exists(orgPath.LocalPath)) { Directory.CreateDirectory(orgPath.LocalPath); } if (Services.NextFile != null && Services.NextFile.Length > 0) { localPathAndFilename = Services.NextFile; Services.NextFile = null; } Factory factory = new Factory(); Entry e = (Entry) factory.CreateCvsObject(orgPath.CurrentDir, Entry.FILE_NAME, entry); if (e.IsBinaryFile) { Services.UncompressedFileHandler.ReceiveBinaryFile(Stream, localPathAndFilename, size); } else { Services.UncompressedFileHandler.ReceiveTextFile(Stream, localPathAndFilename, size); } e.Date = Services.NextFileDate; Services.NextFileDate = null; manager.Add(e); LOGGER.Debug("In created response, just added entry. File date=[" + e.Date + "]"); manager.SetFileTimeStamp (e.FullPath, e.TimeStamp, e.IsUtcTimeStamp); UpdateMessage message = new UpdateMessage (); message.Module = Services.Repository.WorkingDirectoryName; message.Repository = orgPath.RelativePath; message.Filename = e.Name; Services.SendMessage (message.Message); }