/// <summary>
 /// Creates a new instance of the command parser.
 /// </summary>
 /// <param name="command"></param>
 /// <param name="args"></param>
 /// <param name="cvsRoot"></param>
 /// <param name="workingDirectory"></param>
 public CommandParserFactory(string command, string[] args,
     CvsRoot cvsRoot, WorkingDirectory workingDirectory){
     this.command = command;
     this.args = GetArgsAfterCommandName(args);
     this.cvsRoot = cvsRoot;
     this.workingDirectory = workingDirectory;
 }
Esempio n. 2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="workingdirectory"></param>
 /// <param name="directory"></param>
 /// <param name="entry"></param>
 public RemoveCommand(WorkingDirectory workingdirectory,
                     string directory,
                     Entry entry)
 {
     this.workingdirectory    = workingdirectory;
     this.directory = directory;
     this.entry = entry;
 }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="workingDirectory"></param>
        public CheckoutModuleCommand(WorkingDirectory workingDirectory) {
            this.workingDirectory    = workingDirectory;

            this.Revision = this.workingDirectory.Revision;
            this.OverrideDirectory = this.workingDirectory.OverrideDirectory;
            if (this.workingDirectory.HasDate) {
                this.Date = this.workingDirectory.Date;
            }
            this.Module = this.workingDirectory.ModuleName;
        }
Esempio n. 4
0
        public IExternalSource Checkout(string cvsroot, string module, string password, 
            out string target)
        {
            //Set temp checkout dir
            target = System.IO.Path.Combine(Globals.TempDirectory, Guid.NewGuid().ToString());
            Directory.CreateDirectory(target);

            //Setup CVS vars
            CvsRoot root = new CvsRoot(cvsroot);
            WorkingDirectory working = new WorkingDirectory(root, target, module);

            CVSServerConnection connection = new CVSServerConnection();
            if (connection == null)
                throw new ToolExecutionException("Unable to connect to the CVS server");

            //Connect to CVS
            ICSharpCode.SharpCvsLib.Commands.ICommand command =
                new CheckoutModuleCommand(working);
            if (command == null)
                throw new ToolExecutionException("Failure to create a checkout command object");
            try {
                connection.Connect(working, password);
            } catch (AuthenticationException) {
                throw new ToolExecutionException("CVS rejected access (doublecheck all fields): Authentication failure");
            } catch (Exception er) {
                throw new ToolExecutionException("CVS rejected access (doublecheck all fields): " + er.Message);
            }

            //Execute checkout command
            try {
                command.Execute(connection);
                connection.Close();
            } catch (Exception er) {
                throw new ToolExecutionException("CVS error: " + er.Message);
            }

            //Create source from module root
            return CreateSource(Path.Combine(target, module));
        }
Esempio n. 5
0
 public LogCommand(WorkingDirectory workingDirectory, Folders folders) {
     this.workingDirectory = workingDirectory;
     this.folders = folders;
 }
Esempio n. 6
0
 /// <summary>
 /// Creates a new instance of the xml log command.
 /// </summary>
 /// <param name="workingDirectory">Directory on the local file system that represents a 
 /// working "sandbox" of the remote cvs repository.</param>
 /// <param name="module">Module to report on.</param>
 public XmlLogCommand(WorkingDirectory workingDirectory, string module) {
     this.cvsChangeLog = new CvsChangeLog(workingDirectory, module);
 }
        /// <summary>
        /// Produce the report
        /// </summary>
        public LogReport Run(string password)
        {
          // 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);
                cvsRoot = new CvsRoot(root.FileContents);
            }
           
            if (null == this.workingDirectory) {
                workingDirectory = new WorkingDirectory(cvsRoot,
                    localDirectory,
                    module);
            }
            
            // Get a connection
            CVSServerConnection connection = new CVSServerConnection();

        	connection.Connect(workingDirectory, password);
        	
        	return Run(connection);
        }
Esempio n. 8
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="workingDirectory"></param>
        /// <param name="module"></param>
		public RLogCommand(WorkingDirectory workingDirectory, string module) : base(workingDirectory, null, null) {
            this.workingDirectory = workingDirectory;
		}
Esempio n. 9
0
        /// <summary>
        /// Create a <code>CVS\Entries</code> management file with the given
        ///     entry line, or if the file exists then add the line to the
        ///     management file.
        /// </summary>
        /// <param name="workingDirectory">Local working directory.</param>
        /// <param name="localPath">The local path response sent down from
        ///     the server.</param>
        /// <param name="repositoryPath">The path to the file name on the
        ///     server.</param>
        /// <param name="entry">The string value that represents the cvs
        ///     entry.</param>
        /// <returns>The contents of the newly created entries file that match
        ///     the given file name created.</returns>
        public Entry AddEntry (WorkingDirectory workingDirectory,
                            String localPath,
                            String repositoryPath,
                            String entry) {
            PathTranslator pathTranslator =
                new PathTranslator (workingDirectory,
                                    repositoryPath);
            Factory factory = CvsFactory;

            Entry cvsEntry = (Entry)
                factory.CreateCvsObject(pathTranslator.CurrentDir, Entry.FILE_NAME, entry);

            return this.AddEntry(cvsEntry);
        }
Esempio n. 10
0
        /// <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.AddCommand addCommand;
            this.ParseOptions(this.unparsedOptions);
            try {
                // Open the Repository file in the CVS directory
                Manager manager = new Manager(Environment.CurrentDirectory);
                Repository repository = manager.FetchRepository(Environment.CurrentDirectory); 
                // If this fails error out and state the user
                //    is not in a CVS repository directory tree.
                CurrentWorkingDirectory = new WorkingDirectory( this.cvsRoot,
                    Environment.CurrentDirectory, repository.FileContents);
                CurrentWorkingDirectory.OverrideDirectory = Environment.CurrentDirectory;
                // If fileNames has a wild card (*) like '*.txt'
                // Create new AddCommand object
                addCommand = new ICSharpCode.SharpCvsLib.Commands.AddCommand(
                                 this.CurrentWorkingDirectory);

                String[] files = Directory.GetFiles(Environment.CurrentDirectory, fileNames);
                ArrayList copiedFiles = new ArrayList ();
                foreach (String file in files) {
                    LOGGER.Debug("file=[" + file + "]");
                    // Remove the .txt when everything works, giving me bugs...
                    String fullPath = Path.Combine(Environment.CurrentDirectory, file);
                    copiedFiles.Add(fullPath);
                }
                addCommand.Folders = GetFoldersToAdd(copiedFiles);
            }
            catch (Exception e) {
                LOGGER.Error (e);
                throw e;
            }
            return addCommand;
        }
 /// <summary>
 /// Connect to the repository.
 /// </summary>
 /// <param name="repository"></param>
 /// <param name="password"></param>
 public void Connect(WorkingDirectory repository, string password) {
     this.repository = repository;
     if (StartProcessEvent != null) {
         this.StartProcessEvent(this, new ProcessEventArgs());
     }
     Authentication(password);
 }
Esempio n. 12
0
        private string GetPassword(CommandLineParser parser, WorkingDirectory workingDir) {
            string pwd = null;
            if (null != parser && null != parser.Password &&
				parser.Password.Length != 0) {
                pwd = parser.Password;
            } else {
                LoginCommand loginCommand = new LoginCommand(workingDir.CvsRoot);
                loginCommand.Execute();
                pwd = loginCommand.Password;
            }

            if (null == pwd) {
                pwd = String.Empty;
            }

            return pwd;
        }
 /// <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.RemoveCommand removeCommand;
     this.ParseOptions(this.unparsedOptions);
     try {
         String currentDirectory = Environment.CurrentDirectory;
         Entry removeEntry;
         // Open the Repository file in the CVS directory
         Manager manager = new Manager(currentDirectory);
         Repository repository = manager.FetchRepository(currentDirectory); 
         removeEntry = manager.FetchEntry(currentDirectory, fileNames );
         // If this fails error out and state the user
         //    is not in a CVS repository directory tree.
         CurrentWorkingDirectory = new WorkingDirectory( this.cvsRoot,
             currentDirectory, repository.FileContents);
         // Create new RemoveCommand object
         removeCommand = new ICSharpCode.SharpCvsLib.Commands.RemoveCommand(
                          this.CurrentWorkingDirectory, currentDirectory,
                          removeEntry);
     }
     catch (Exception e) {
         LOGGER.Error (e);
         throw e;
     }
     return removeCommand;
 }
Esempio n. 14
0
        /// <summary>
        /// Perform an rtag against the repository.  The rtag command has a number
        ///     of request options that may be specified.  These are translated into
        ///     boolean values where possible to calling classes.  A summary of 
        ///     available command options is listed below and is listed in the private
        ///     options classes.
        ///    
        ///         -D date
        ///             Tag the most recent revision no later than date. 
        ///         -f
        ///             Only useful with the `-D date' or `-r tag' flags. 
        ///             If no matching revision is found, use the most recent 
        ///             revision (instead of ignoring the file). 
        ///         -F
        ///             Overwrite an existing tag of the same name on a different 
        ///             revision. 
        ///         -l
        ///             Local; run only in current working directory. 
        ///         -n
        ///             Do not run any tag program that was specified with the `-t' 
        ///             flag inside the `modules' file. (see section The modules 
        ///             file). 
        ///         -R
        ///             Tag directories recursively. This is on by default. 
        ///         -r tag
        ///             Only tag those files that contain tag. This can be used to 
        ///             rename a tag: tag only the files identified by the old tag, 
        ///             then delete the old tag, leaving the new tag on exactly the 
        ///             same files as the old tag. 
        ///
        ///         In addition to the above common options, these options are 
        ///         available:
        ///
        ///         -a
        ///             Use the `-a' option to have rtag look in the `Attic' 
        ///             (see section The attic) for removed files that contain the 
        ///             specified tag. The tag is removed from these files, which 
        ///             makes it convenient to re-use a symbolic tag as development 
        ///             continues (and files get removed from the up-coming 
        ///             distribution). 
        ///         -b
        ///             Make the tag a branch tag. See section Branching and merging. 
        ///         -d
        ///             Delete the tag instead of creating it. In general, tags 
        ///             (often the symbolic names of software distributions) should 
        ///             not be removed, but the `-d' option is available as a means 
        ///             to remove completely obsolete symbolic names if necessary 
        ///             (as might be the case for an Alpha release, or if you 
        ///             mistagged a module).  
        ///             
        /// </summary>
        /// <param name="workingDirectory">The working directory which contains
        ///     the repository information.</param>
		public RTagCommand(WorkingDirectory workingDirectory) {
            this.workingDirectory = workingDirectory;
		}
Esempio n. 15
0
 /// <summary>
 /// Create a new instance of the cvs changelog command.
 /// </summary>
 /// <param name="workingDirectory"></param>
 /// <param name="module"></param>
 public CvsChangeLog(WorkingDirectory workingDirectory, string module) {
     logCommand = new LogReportCommand(workingDirectory, module);
 }
Esempio n. 16
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;
        }
 /// <summary>
 /// Create a new connection and initialize with the working directory
 /// object.
 /// </summary>
 /// <param name="workingDirectory"></param>
 public CVSServerConnection (WorkingDirectory workingDirectory)  {
     this.repository = workingDirectory;
     this.Init();
 }
 /// <summary>
 /// Constructor for the import module command.
 /// </summary>
 /// <param name="workingdirectory"></param>
 /// <param name="logmessage"></param>
 public ImportModuleCommand(WorkingDirectory workingdirectory, string logmessage)
 {
     this.logmessage = logmessage;
     this.workingdirectory = workingdirectory;
 }
        private void Init () {
            inputStream  = new CvsStream (new MemoryStream());
            outputStream = new CvsStream (new MemoryStream());

            this.config = SharpCvsLibConfig.GetInstance();
            try {
                if (config.Log.DebugLog.Enabled) {
                    requestLog = new RequestLog ();
                    responseLog = new ResponseLog ();

                    this.InputStream.RequestMessage.MessageEvent +=
                        new EncodedMessage.MessageHandler (requestLog.Log);
                    this.OutputStream.ResponseMessage.MessageEvent +=
                        new EncodedMessage.MessageHandler (responseLog.Log);
                }
            } catch (Exception e) {
                LOGGER.Error (e);
            }

            if (null == config) {
                config = new SharpCvsLibConfig ();
            }
            LOGGER.Debug("Config=["  + config.ToString() + "]");

            if (this.repository == null) {
                this.repository = DeriveWorkingDirectory();
            }
        }
Esempio n. 20
0
        /// <summary>
        ///     Create the root file in the local cvs directory.  This file holds
        ///         the details about the cvs root used in this sandbox.
        /// </summary>
        /// <param name="workingDirectory">Holds information about the current
        ///     path and cvs root.</param>
        /// <param name="localPath">The local path response sent down from
        ///     the server.</param>
        /// <param name="repositoryPath">The path to the file name on the
        ///     server.</param>
        /// <returns>The object contents of the newly created root file.</returns>
        public Root AddRoot (WorkingDirectory workingDirectory,
                            String localPath,
                            String repositoryPath) {
            PathTranslator pathTranslator =
                new PathTranslator (workingDirectory,
                                    repositoryPath);
            Factory factory = CvsFactory;

            Root root =
                (Root)factory.CreateCvsObject (pathTranslator.CurrentDir, Root.FILE_NAME,
                                            pathTranslator.CvsRoot.ToString ());
            return this.AddRoot (root);
        }
Esempio n. 21
0
        /// <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;
        }
Esempio n. 22
0
 /// <summary>
 /// Login to a cvs repository with workDirectory object
 /// </summary>
 /// <param name="cvsRoot">The repository root.</param>
 /// <param name="workingDirectory">User information</param>
 public LoginCommand(CvsRoot cvsRoot, WorkingDirectory workingDirectory){
     this.cvsRoot = cvsRoot;
     this.workingDirectory = workingDirectory;
     // Is there a password file?
     //     yes, get password for this username
     //     no, prompt user for password to use
 }
Esempio n. 23
0
        /// <summary>
        ///     Create the repository file in the cvs sub directory of the
        ///         current working directory.
        /// </summary>
        /// <param name="workingDirectory">Holds information about the current
        ///     path and cvs root.</param>
        /// <param name="localPath">The local path response sent down from
        ///     the server.</param>
        /// <param name="repositoryPath">The path to the file name on the
        ///     server.</param>
        /// <returns>The object contents of the newly created repository file.</returns>
        public Repository AddRepository (WorkingDirectory workingDirectory,
                                        String localPath,
                                        String repositoryPath) {
            PathTranslator pathTranslator =
                new PathTranslator (workingDirectory,
                                    repositoryPath);
            Factory factory = CvsFactory;

            String repositoryContents = String.Format("{0}/{1}",
                workingDirectory.ModuleName, pathTranslator.RelativePath);

            DirectoryInfo dir = pathTranslator.CurrentDir;

            Repository repository =
                (Repository)factory.CreateCvsObject (dir, Repository.FILE_NAME,
                                                    repositoryContents);
            return this.AddRepository (repository);
        }
Esempio n. 24
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="workingDirectory"></param>
 public UpdateCommand2(WorkingDirectory workingDirectory) {
     this.workingDirectory = workingDirectory;
 }
Esempio n. 25
0
        /// <summary>
        ///     Create the root file in the local cvs directory.  This file holds
        ///         the details about the cvs root used in this sandbox.
        /// </summary>
        /// <param name="workingDirectory">Holds information about the current
        ///     path and cvs root.</param>
        /// <param name="localPath">The local path response sent down from
        ///     the server.</param>
        /// <param name="repositoryPath">The path to the file name on the
        ///     server.</param>
        /// <param name="stickyTag">The sticky tag to add to the tag file.</param>
        /// <returns>The object contents of the newly created root file.</returns>
        public Tag AddTag (WorkingDirectory workingDirectory, String localPath,
            String repositoryPath, String stickyTag) {
            PathTranslator pathTranslator =
                new PathTranslator (workingDirectory,
                repositoryPath);
            Factory factory = CvsFactory;

            FileInfo tagFile = 
                new FileInfo(Path.Combine(PathTranslator.AppendCvs(localPath).FullName,
                Tag.FILE_NAME));

            Tag tag =
                (Tag)factory.CreateCvsObject (tagFile, stickyTag);

            return this.AddTag (tag);;
        }
Esempio n. 26
0
 /// <summary>
 /// Create a new instance of the working directory.
 /// </summary>
 /// <param name="workingDirectory"></param>
 public StatusCommand(WorkingDirectory workingDirectory){
     this._workingdirectory = workingDirectory;
 }
Esempio n. 27
0
 /// <summary>
 /// Initialize the working directory to be used in the add.
 /// </summary>
 public AddCommand(WorkingDirectory workingDirectory) {
     this.workingDirectory    = workingDirectory;
 }
Esempio n. 28
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="workingdirectory"></param>
 /// <param name="directory"></param>
 /// <param name="entry"></param>
 public StatusCommand(WorkingDirectory workingdirectory, 
     string directory, Entry entry){
     this._workingdirectory    = workingdirectory;
     this.directory = directory;
     this.entry = entry;
     if (null == this.Folders) {
         this._folders = new Folders();
         Folder folder = new Folder();
         folder.Entries.Add(entry);
         this._folders.Add(folder);
     }
 }
Esempio n. 29
0
 /// <summary>
 /// Commit command two constructor
 /// </summary>
 /// <param name="workingdirectory"></param>
 public CommitCommand2(WorkingDirectory workingdirectory)
 {
     this.workingdirectory = workingdirectory;
 }
        /// <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 () {
            DirectoryInfo dir = 
                new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), "CVS"));
            StatusCommand statusCommand;
            this.localDirectory = Directory.GetCurrentDirectory();

            try {
                this.repository = Repository.Load(dir).FileContents; 
                this.CvsRoot = new CvsRoot(Root.Load(dir).FileContents);
            } catch (NullReferenceException) {
                this.InvalidRepository();
            } catch (CvsFileNotFoundException) {
                this.InvalidRepository();
            } catch (ICSharpCode.SharpCvsLib.Exceptions.CvsRootParseException) {
                this.InvalidRepository();
            }

            CurrentWorkingDirectory = new WorkingDirectory(this.CvsRoot,
                localDirectory, this.repository);

            // Create new command object
            statusCommand = new StatusCommand(CurrentWorkingDirectory);
            statusCommand.Folders = this.GetCurrentDirectory(new DirectoryInfo(localDirectory));
            this.ParseOptions(statusCommand, this.Args);

            return statusCommand;
        }