Example #1
0
        private void Route(ExecutionPlan plan, ExecutionToken token, CancellationToken cancel)
        {
            if (token.IsCancelled)
            {
                return;
            }

            if (token.SubscriptionOperation != null)
            {
                _subscriber.Execute(token, cancel);
            }

            if (token.CommandOperation != null)
            {
                if (plan.ContextOperation.RequiresStandaloneConnection && _heldConnection == null)
                {
                    _heldConnection = _exclusivePool.Provide();
                }

                if (_heldConnection != null)
                {
                    _heldConnection.Execute(token, cancel);
                }
                else
                {
                    _multiplexedCommander.Execute(token, cancel);
                }
            }

            _context.Apply(plan.ContextOperation);
        }
Example #2
0
        /// <summary>
        /// Execute the diff command.
        /// </summary>
        /// <param name="connection"></param>
        public void Execute(ICommandConnection connection)
        {
            connection.SubmitRequest(new DirectoryRequest(".",
                                                          workingdirectory.CvsRoot.CvsRepository +
                                                          directory));

            if (IsIgnoringCase)
            {
                connection.SubmitRequest(new ArgumentRequest("-i"));
            }
            if (IsIgnoringAllWhitespace)
            {
                connection.SubmitRequest(new ArgumentRequest("-w"));
            }
            if (IsIgnoringBlankLines)
            {
                connection.SubmitRequest(new ArgumentRequest("-B"));
            }
            if (IsIgnoringSpaceChange)
            {
                connection.SubmitRequest(new ArgumentRequest("-b"));
            }

            connection.SubmitRequest(new ArgumentRequest(entry.Name));
            connection.SubmitRequest(new DiffRequest());
        }
Example #3
0
        /// <summary>
        /// Execute the commit command
        /// </summary>
        /// <param name="connection">Cvs server connection</param>
        public void Execute(ICommandConnection connection)
        {
            connection.SubmitRequest(new ArgumentRequest("-m"));
            connection.SubmitRequest(new ArgumentRequest("LOG MESSAGE"));
            connection.SubmitRequest(new ArgumentRequest(ArgumentRequest.Options.DASH));
            foreach (DictionaryEntry folderEntry in workingdirectory.Folders)
            {
                Folder folder = (Folder)folderEntry.Value;
                this.SetDirectory(connection, folder);
                foreach (DictionaryEntry entryEntry  in folder.Entries)
                {
                    Entry entry = (Entry)entryEntry.Value;
                    if (!entry.IsDirectory)
                    {
                        this.SendFileRequest(connection, entry);
                    }
                }

                this.SetDirectory(connection, folder);

                foreach (DictionaryEntry entryEntry in folder.Entries)
                {
                    Entry entry = (Entry)entryEntry.Value;
                    if (!entry.IsDirectory)
                    {
                        connection.SubmitRequest(new ArgumentRequest(entry.Name));
                    }
                }
            }
            connection.SubmitRequest(new CommitRequest());
        }
Example #4
0
        private void SendEntryRequest(ICommandConnection connection,
                                      Entry entry)
        {
            bool     fileExists;
            DateTime old = entry.TimeStamp;

            entry.TimeStamp = entry.TimeStamp;
            try {
                fileExists = File.Exists(entry.Filename);
            }
            catch (Exception e) {
                LOGGER.Error(e);
                fileExists = false;
            }

            connection.SubmitRequest(new EntryRequest(entry));
            if (fileExists)
            {
                if (File.GetLastAccessTime(entry.Filename) !=
                    entry.TimeStamp.ToUniversalTime())
                {
                    connection.SubmitRequest(new ModifiedRequest(entry.Name));
                }
                else
                {
                    connection.SubmitRequest(new UnchangedRequest(entry.Name));
                }
            }

            entry.TimeStamp = old;
        }
        /// <summary>
        /// Do the dirty work.
        /// </summary>
        /// <param name="connection"></param>
        public void Execute(ICommandConnection connection)
        {
            //connection.SubmitRequest(new CaseRequest());
            connection.SubmitRequest(new ArgumentRequest("-b"));
            connection.SubmitRequest(new ArgumentRequest("1.1.1"));
            connection.SubmitRequest(new ArgumentRequest("-m"));
            connection.SubmitRequest(new ArgumentRequest(logmessage));

            LOGGER.Info("IMPORT START");

            foreach (DictionaryEntry folder in workingdirectory.Folders)
            {
                this.SetDirectory(connection, (Folder)folder.Value);
                foreach (Entry entry  in ((Folder)folder.Value).Entries.Values)
                {
                    this.SendFileRequest(connection, entry);
                }
            }

            connection.SubmitRequest(new ArgumentRequest(workingdirectory.WorkingDirectoryName));
            connection.SubmitRequest(new ArgumentRequest(vendor));
            connection.SubmitRequest(new ArgumentRequest(release));

            connection.SubmitRequest(new ImportRequest());
            if (LOGGER.IsDebugEnabled)
            {
                LOGGER.Debug("IMPORT END");
            }
        }
Example #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RedisClient"/> class.
        /// </summary>
        /// <param name="endpoints">The Redis endpoints. The selected endpoint is selected in a rota basis.</param>
        /// <param name="options"><see cref="RedisClientOptions"/></param>
        public RedisClient(IPEndPoint[] endpoints, RedisClientOptions options = null)
            : this(options)
        {
            ParameterGuard.CannotBeNullOrEmpty(endpoints, "endpoints");

            _endpoints = endpoints.ToArray();

            _procedures = _options.Procedures != null?_options.Procedures.ToCollection() : ProcedureCollection.Empty;

            _proceduresInitializer = new ProcedureInitializer(_procedures, _options.Logger);

            _multiplexedCommander = new AggregatedCommandConnection <RedisCommanderConnection>(_options.MultiplexPool.CommandConnections, CommanderFactory, _options);
            _subscriptorsPool     = new ConnectionSelector <RedisSubscriberConnection>(_options.MultiplexPool.SubscriptionOptions, SubscriberFactory, _options);

            if (_options.ExclusivePool.Maximum > 0)
            {
                _exclusivePool = new ConnectionPool(_options.ExclusivePool.Minimum, _options.ExclusivePool.Maximum, CommanderFactory, _options.Logger);
            }
            else
            {
                _exclusivePool = DisabledConnectionPool.Instance;
            }

            IExecutionPlanner planner = new ExecutionPlanner(_procedures);
            _planner = _options.UseExecutionPlanCaching ? new CachingExecutionPlanner(planner) : planner;
        }
        public Task <TResponse> ExecuteAsync(ICommandConnection connection)
        {
            Connection = connection;

            var commandClone = (AbstractCommand <TPacket, TParser, TParserResponse, TResponse>)MemberwiseClone();

            return(Task.Run(() => commandClone.Execute(connection)));
        }
Example #8
0
        /// <summary>
        /// Produce the report
        /// </summary>
        public void Run(XmlTextWriter textWriter, ICommandConnection connection)
        {
            // send the log command to the cvs server and get the LogReport
            LogReport logReport = logCommand.Run(connection);

            // now format the LogReport into a change log
            FormatReport(textWriter, logReport);
        }
 /// <summary>
 /// Do the dirty work.
 /// </summary>
 /// <param name="connection"></param>
 public void Execute(ICommandConnection connection)
 {
     connection.SubmitRequest(new ArgumentRequest("-s"));
     connection.SubmitRequest(new ArgumentRequest("-r"));
     connection.SubmitRequest(new ArgumentRequest("0"));
     connection.SubmitRequest(new ArgumentRequest("./"));
     connection.SubmitRequest(new RDiffRequest());
 }
 /// <summary>
 /// Do the dirty work.
 /// </summary>
 /// <param name="connection"></param>
 public void Execute(ICommandConnection connection)
 {
     connection.SubmitRequest(new ArgumentRequest("-s"));
     connection.SubmitRequest(new ArgumentRequest("-r"));
     connection.SubmitRequest(new ArgumentRequest("0"));
     connection.SubmitRequest(new ArgumentRequest("./"));
     connection.SubmitRequest(new RDiffRequest());
 }
Example #11
0
 private void Clean()
 {
     if (_heldConnection != null && !_context.MustKeepConnection)
     {
         _heldConnection.Dispose();
         _heldConnection = null;
     }
 }
Example #12
0
 /// <summary>
 /// Do the dirty work.
 /// </summary>
 /// <param name="connection"></param>
 public void Execute(ICommandConnection connection)
 {
     connection.SubmitRequest(new DirectoryRequest(".", workingdirectory.CvsRoot.CvsRepository + directory));
     connection.SubmitRequest(new EntryRequest(entry));
     connection.SubmitRequest(new RemoveRequest());
     connection.SubmitRequest(new ArgumentRequest("-m"));
     connection.SubmitRequest(new ArgumentRequest("Remove"));
     connection.SubmitRequest(new CommitRequest());
 }
Example #13
0
 /// <summary>
 /// Do the dirty work.
 /// </summary>
 /// <param name="connection"></param>
 public void Execute(ICommandConnection connection)
 {
     connection.SubmitRequest(new DirectoryRequest(".", workingdirectory.CvsRoot.CvsRepository + directory));
     connection.SubmitRequest(new EntryRequest(entry));
     connection.SubmitRequest(new RemoveRequest());
     connection.SubmitRequest(new ArgumentRequest("-m"));
     connection.SubmitRequest(new ArgumentRequest("Remove"));
     connection.SubmitRequest(new CommitRequest());
 }
Example #14
0
        /// <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());
        }
Example #15
0
        private void SendFileRequest(ICommandConnection connection, Entry entry)
        {
            DateTime old = entry.TimeStamp;

            entry.TimeStamp = entry.TimeStamp;
            connection.SubmitRequest(new EntryRequest(entry));
            connection.SubmitRequest(new ModifiedRequest(entry.Name));
            connection.SendFile(entry.FullPath, entry.IsBinaryFile);

            entry.TimeStamp = old;
        }
Example #16
0
        /// <summary>
        /// Perform the update.
        /// </summary>
        /// <param name="connection"></param>
        public void Execute(ICommandConnection connection)
        {
            if (workingDirectory.FoldersToUpdate == null)
            {
                LOGGER.Info("Nothing to update on WorkingDirectory.FoldersToUpdate.");
                return;
            }
            Folder[] _foldersToUpdate =
                (Folder[])workingDirectory.FoldersToUpdate.Clone();
            foreach (Folder folder in _foldersToUpdate)
            {
                this.SetDirectory(connection, folder);

                Tag tag = folder.Tag;
                if (null != tag)
                {
                    connection.SubmitRequest(new StickyRequest(tag.FileContents));
                }
                if (workingDirectory.HasOverrideDirectory)
                {
                    connection.SubmitRequest(new ArgumentRequest(ArgumentRequest.Options.OVERRIDE_DIRECTORY));
                    connection.SubmitRequest(
                        new ArgumentRequest(workingDirectory.OverrideDirectory));
                }

                if (this.Revision != null && this.Revision != string.Empty)
                {
                    connection.SubmitRequest(new ArgumentRequest(ArgumentRequest.Options.REVISION));
                    connection.SubmitRequest(new ArgumentRequest(this.Revision));
                }
                if (workingDirectory.HasDate)
                {
                    connection.SubmitRequest(new ArgumentRequest(ArgumentRequest.Options.DATE));
                    connection.SubmitRequest(new ArgumentRequest(workingDirectory.GetDateAsString()));
                }

                foreach (DictionaryEntry dicEntry  in folder.Entries)
                {
                    Entry entry = (Entry)dicEntry.Value;
                    // directory entry modifications are not tracked in cvs,
                    //  once a directory is created it cannot be removed
                    if (!entry.IsDirectory)
                    {
                        DateTime old = entry.TimeStamp;
                        entry.TimeStamp = entry.TimeStamp;

                        this.SendFileRequest(connection, entry);
                    }
                }
                connection.SubmitRequest(new UpdateRequest());
            }
        }
Example #17
0
 internal RedisChannel(IExecutionPlanner planner,
                       ProcedureCollection procedures,
                       ICommandConnection multiplexedCommander,
                       IConnectionProvider <ISubscriptionConnection> subscribers,
                       IConnectionProvider <ICommandConnection> exclusivePool)
 {
     _multiplexedCommander = multiplexedCommander;
     _exclusivePool        = exclusivePool;
     _subscribers          = subscribers;
     _planner    = planner;
     _procedures = procedures;
     _context    = new ExecutionContext();
 }
Example #18
0
        /// <summary>
        /// Execute checkout module command.
        /// </summary>
        /// <param name="connection">Server connection</param>
        public void Execute(ICommandConnection connection)
        {
            connection.SubmitRequest(new CaseRequest());

            if (this.deleteTag)
            {
                connection.SubmitRequest(new ArgumentRequest(Options.DELETE_TAG));
            }

            connection.SubmitRequest(new ArgumentRequest(TagName));
            connection.SubmitRequest(new ArgumentRequest(workingDirectory.ModuleName));

            connection.SubmitRequest(new RTagRequest());
        }
Example #19
0
        private void SetDirectory(ICommandConnection connection,
                                  Folder folder)
        {
            String absoluteDir = String.Format("{0}",
                                               connection.Repository.CvsRoot.CvsRepository);

            try {
                connection.SubmitRequest(new DirectoryRequest(".",
                                                              absoluteDir));
            }
            catch (Exception e) {
                String msg = "Exception while submitting directory request.  " +
                             "path=[" + folder.Repository.FileContents + "]";
                LOGGER.Error(e);
            }
        }
        /// <summary>
        /// Execute checkout module command.
        /// </summary>
        /// <param name="connection">Server connection</param>
        public void Execute(ICommandConnection connection)
        {
            workingDirectory.Clear();

            //connection.SubmitRequest(new CaseRequest());
            connection.SubmitRequest(new ArgumentRequest(this.Module));

            connection.SubmitRequest(new DirectoryRequest(".",
                                                          workingDirectory.CvsRoot.CvsRepository +
                                                          "/" + workingDirectory.ModuleName));

            connection.SubmitRequest(new ExpandModulesRequest());

            connection.SubmitRequest(
                new ArgumentRequest(ArgumentRequest.Options.MODULE_NAME));

            if (null != this.Revision)
            {
                connection.SubmitRequest(new ArgumentRequest(ArgumentRequest.Options.REVISION));
                connection.SubmitRequest(new ArgumentRequest(this.Revision));
            }
            if (this._hasDate)
            {
                connection.SubmitRequest(new ArgumentRequest(ArgumentRequest.Options.DATE));
                connection.SubmitRequest(new ArgumentRequest(this.DateAsString));
            }
            if (null != this.OverrideDirectory)
            {
                connection.SubmitRequest(
                    new ArgumentRequest(ArgumentRequest.Options.OVERRIDE_DIRECTORY));
                connection.SubmitRequest(
                    new ArgumentRequest(this.OverrideDirectory));
            }

            connection.SubmitRequest(new ArgumentRequest(this.Module));

            connection.SubmitRequest(new DirectoryRequest(".",
                                                          workingDirectory.CvsRoot.CvsRepository +
                                                          "/" + this.Module));

            connection.SubmitRequest(new CheckoutRequest());
            Manager manager = new Manager(connection.Repository.WorkingPath);
        }
Example #21
0
        /// <summary>
        /// Do the dirty work.
        /// </summary>
        /// <param name="connection"></param>
        public void Execute(ICommandConnection connection)
        {
            if (this.Quieter)
            {
                connection.SubmitRequest(new ArgumentRequest(Option.QUIETER));
            }
            if (this.EntryFormat)
            {
                connection.SubmitRequest(new ArgumentRequest(Option.ENTRY_FORMAT));
            }
            if (this.AllDetails)
            {
                connection.SubmitRequest(new ArgumentRequest(Option.ALL_DETAILS));
            }
            if (this.Recursive)
            {
                connection.SubmitRequest(new ArgumentRequest(Option.RECURSIVE));
            }
            if (this.LocalTime)
            {
                connection.SubmitRequest(new ArgumentRequest(Option.LOCAL_TIME));
            }
            if (null != this.Tag && this.Tag.Length != 0)
            {
                connection.SubmitRequest(new ArgumentRequest(Option.TAG));
            }
            if (this.Prune)
            {
                connection.SubmitRequest(new ArgumentRequest(Option.PRUNE));
            }

            // add any date arguments
            foreach (object o in dateArgs)
            {
                string dateArg = (string)o;
                connection.SubmitRequest(new ArgumentRequest(Option.DATE));
                connection.SubmitRequest(new ArgumentRequest(dateArg));
            }

            connection.SubmitRequest(new ListRequest());
        }
Example #22
0
        /// <summary>
        /// Execute the status command against the repository.
        /// </summary>
        /// <param name="connection"></param>
        public void Execute(ICommandConnection connection)
        {
            if (null != this._folders)
            {
                connection.SubmitRequest(new ArgumentRequest(ArgumentRequest.Options.DASH));

                foreach (Folder folder in this.Folders.Values)
                {
                    connection.SubmitRequest(new DirectoryRequest(".",
                                                                  this._workingdirectory.CvsRoot.CvsRepository + "/" +
                                                                  folder.Repository.FileContents));
                    foreach (Entry entry in folder.Entries.Values)
                    {
                        connection.SubmitRequest(new EntryRequest(entry));
                        connection.SubmitRequest(new UnchangedRequest(entry.Name));
                    }
                }
            }
            connection.ResponseMessageEvents.MessageResponseMessageEvent +=
                new MessageEventHandler(this.WriteEvent);
            connection.SubmitRequest(new StatusRequest());
        }
Example #23
0
        /// <summary>
        /// Execute checkout module command.
        /// </summary>
        /// <param name="connection">Server connection</param>
        public new void Execute(ICommandConnection connection)
        {
            string relativeDirectory = this.workingDirectory.ModuleName;

            // Note: don't use Path.Combine() as the separator must be "/"
            string repositoryDir = workingDirectory.CvsRoot.CvsRepository + "/" + relativeDirectory;

            connection.SubmitRequest(new DirectoryRequest(relativeDirectory, repositoryDir));

            if (DefaultBranch)
            {
                connection.SubmitRequest(new ArgumentRequest("-b"));
            }
            if (HeaderAndDescOnly)
            {
                connection.SubmitRequest(new ArgumentRequest("-t"));
            }
            if (HeaderOnly)
            {
                connection.SubmitRequest(new ArgumentRequest("-h"));
            }
            if (NoTags)
            {
                connection.SubmitRequest(new ArgumentRequest("-N"));
            }

            // add any date arguments
            foreach (object o in base.DateArgs)
            {
                string dateArg = (string)o;
                connection.SubmitRequest(new ArgumentRequest("-d"));
                connection.SubmitRequest(new ArgumentRequest(dateArg));
            }

            connection.SubmitRequest(new ArgumentRequest(workingDirectory.ModuleName));

            connection.SubmitRequest(new RLogRequest());
        }
Example #24
0
        /// <summary>
        /// Produce the xml log report.
        /// </summary>
        /// <param name="connection"></param>
        public void Execute(ICommandConnection connection)
        {
            this.connection = connection;
            if (null == this.XmlFilename || DateTime.MinValue == this.StartDate ||
                DateTime.MinValue == this.EndDate)
            {
                throw new ArgumentException(
                          String.Format("Xml filename ( {0} ), start date ( {1} ) and end date ( {2} ) must be provided.",
                                        this.XmlFilename, this.StartDate, this.EndDate));
            }

            if (!Path.IsPathRooted(this.XmlFilename))
            {
                this.XmlFilename = Path.Combine(System.Environment.CurrentDirectory, this.XmlFilename);
            }

            DirectoryInfo dirInfo =
                new DirectoryInfo(Path.GetDirectoryName(this.XmlFilename));

            if (!dirInfo.Exists)
            {
                dirInfo.Create();
            }
            this.cvsChangeLog.Run(this.XmlFilename, connection);

            if (null != this.XslFilename)
            {
                XslTransform t = new XslTransform();
                try {
                    t.Load(this.XslFilename);
                    t.Transform(this.XmlFilename, this.HtmlFilename);
                } catch (Exception e) {
                    LOGGER.Error(e);
                }
            }
        }
Example #25
0
        /// <summary>
        /// Produce the xml log report.
        /// </summary>
        /// <param name="connection"></param>
        public void Execute(ICommandConnection connection) {
            this.connection = connection;
            if (null == this.XmlFilename || DateTime.MinValue == this.StartDate ||
                DateTime.MinValue == this.EndDate) {
                throw new ArgumentException (
                    String.Format("Xml filename ( {0} ), start date ( {1} ) and end date ( {2} ) must be provided.",
                    this.XmlFilename, this.StartDate, this.EndDate));
            }

            if (!Path.IsPathRooted(this.XmlFilename)) {
                this.XmlFilename = Path.Combine(System.Environment.CurrentDirectory, this.XmlFilename);
            }

            DirectoryInfo dirInfo = 
                new DirectoryInfo(Path.GetDirectoryName(this.XmlFilename));
            if (!dirInfo.Exists) {
                dirInfo.Create();
            }
            this.cvsChangeLog.Run(this.XmlFilename, connection);

            if (null != this.XslFilename) {
                XslTransform t = new XslTransform();
                try {
                    t.Load(this.XslFilename);
                    t.Transform(this.XmlFilename, this.HtmlFilename);
                } catch (Exception e) {
                    LOGGER.Error(e);
                }
            }
        }
Example #26
0
 /// <summary>
 /// Process the login command with cvs library API calls.
 /// </summary>
 public void Execute(ICommandConnection connection)
 {
     this.Execute();
 }
Example #27
0
        private void SetDirectory (ICommandConnection connection,
            Folder folder) {
            String absoluteDir =
                connection.Repository.CvsRoot.CvsRepository + "/" +
                folder.Repository.FileContents;

            try {
                connection.SubmitRequest(new DirectoryRequest(".",
                    absoluteDir));
            }
            catch (Exception e) {
                String msg = "Exception while submitting directory request.  " +
                    "path=[" + folder.Repository.FileContents + "]";
                LOGGER.Error (e);
            }
        }
Example #28
0
        /// <summary>
        /// Execute checkout module command.
        /// </summary>
        /// <param name="connection">Server connection</param>
        public new void Execute(ICommandConnection connection) {
            string relativeDirectory = this.workingDirectory.ModuleName;

            // Note: don't use Path.Combine() as the separator must be "/"
            string repositoryDir = workingDirectory.CvsRoot.CvsRepository + "/" + relativeDirectory;
            connection.SubmitRequest(new DirectoryRequest(relativeDirectory, repositoryDir));

            if (DefaultBranch) {
                connection.SubmitRequest(new ArgumentRequest("-b"));
            }
            if (HeaderAndDescOnly) {
                connection.SubmitRequest(new ArgumentRequest("-t"));
            }
            if (HeaderOnly) {
                connection.SubmitRequest(new ArgumentRequest("-h"));
            }
            if (NoTags) {
                connection.SubmitRequest(new ArgumentRequest("-N"));
            }
        
            // add any date arguments
            foreach (object o in base.DateArgs) {
                string dateArg = (string)o;
                connection.SubmitRequest(new ArgumentRequest("-d"));
                connection.SubmitRequest(new ArgumentRequest(dateArg));
            }

            connection.SubmitRequest(new ArgumentRequest(workingDirectory.ModuleName));

            connection.SubmitRequest(new RLogRequest());
        }
Example #29
0
 /// <summary>
 /// Do the dirty work.
 /// </summary>
 /// <param name="connection"></param>
 public void Execute(ICommandConnection connection)
 {
     connection.SubmitRequest(new InitRequest(cvsroot.CvsRepository));
 }
Example #30
0
        private void SendEntryRequest (ICommandConnection connection,
                                Entry entry) {
            bool fileExists;
            DateTime old = entry.TimeStamp;
            entry.TimeStamp = entry.TimeStamp;
            try {
                fileExists = File.Exists (entry.Filename);
            }
            catch (Exception e) {
                LOGGER.Error (e);
                fileExists = false;
            }

            connection.SubmitRequest (new EntryRequest (entry));
            if (fileExists) {
                if (File.GetLastAccessTime(entry.Filename) !=
                    entry.TimeStamp.ToUniversalTime ()) {
                    connection.SubmitRequest(new ModifiedRequest(entry.Name));
                } else {
                    connection.SubmitRequest(new UnchangedRequest(entry.Name));
                }
            }

            entry.TimeStamp = old;
        }
Example #31
0
 /// <summary>
 /// Do the dirty work.
 /// </summary>
 /// <param name="connection"></param>
 public void Execute(ICommandConnection connection)
 {
     connection.SubmitRequest(new InitRequest(cvsroot.CvsRepository));
 }
        /// <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;
        }
Example #33
0
        /// <summary>
        /// Perform the update.
        /// </summary>
        /// <param name="connection"></param>
        public void Execute(ICommandConnection connection) {
            if (workingDirectory.FoldersToUpdate == null) {
                LOGGER.Info("Nothing to update on WorkingDirectory.FoldersToUpdate.");
                return;
            }
            Folder[] _foldersToUpdate =
                (Folder[])workingDirectory.FoldersToUpdate.Clone ();
            foreach (Folder folder in _foldersToUpdate) {
                this.SetDirectory (connection, folder);

                Tag tag = folder.Tag;
                if (null != tag) {
                    connection.SubmitRequest (new StickyRequest (tag.FileContents));
                }
                if (workingDirectory.HasOverrideDirectory) {
                    connection.SubmitRequest (new ArgumentRequest (ArgumentRequest.Options.OVERRIDE_DIRECTORY));
                    connection.SubmitRequest (
                        new ArgumentRequest (workingDirectory.OverrideDirectory));
                }

                if (this.Revision != null && this.Revision != string.Empty) {
                    connection.SubmitRequest (new ArgumentRequest (ArgumentRequest.Options.REVISION));
                    connection.SubmitRequest(new ArgumentRequest(this.Revision));
                }
                if (workingDirectory.HasDate) {
                    connection.SubmitRequest (new ArgumentRequest (ArgumentRequest.Options.DATE));
                    connection.SubmitRequest(new ArgumentRequest(workingDirectory.GetDateAsString()));
                }
                
                foreach (DictionaryEntry dicEntry  in folder.Entries) {
                    Entry entry = (Entry)dicEntry.Value;
                    // directory entry modifications are not tracked in cvs,
                    //  once a directory is created it cannot be removed
                    if (!entry.IsDirectory) {
                        DateTime old = entry.TimeStamp;
                        entry.TimeStamp = entry.TimeStamp;
    				
                        this.SendFileRequest (connection, entry);
                    }
                }
                connection.SubmitRequest(new UpdateRequest());
            }

        }
Example #34
0
        /// <summary>
        /// Produce the report.
        /// </summary>
        /// <param name="xmlFilename"></param>
        /// <param name="connection"></param>
        public void Run(string xmlFilename, ICommandConnection connection)
        {
            XmlTextWriter textWriter = new XmlTextWriter(xmlFilename, new UTF8Encoding());

            Run(textWriter, connection);
        }
Example #35
0
        /// <summary>
        /// Execute checkout module command.
        /// </summary>
        /// <param name="connection">Server connection</param>
        public void Execute(ICommandConnection connection) {
            connection.SubmitRequest(new CaseRequest());

            if (this.deleteTag) {
                connection.SubmitRequest(new ArgumentRequest(Options.DELETE_TAG));
            }

            connection.SubmitRequest(new ArgumentRequest(TagName));
            connection.SubmitRequest(new ArgumentRequest(workingDirectory.ModuleName));

            connection.SubmitRequest(new RTagRequest());
        }
        /// <summary>
        /// Execute checkout module command.
        /// </summary>
        /// <param name="connection">Server connection</param>
        public void Execute(ICommandConnection connection) {
            workingDirectory.Clear();

            //connection.SubmitRequest(new CaseRequest());
            connection.SubmitRequest(new ArgumentRequest(this.Module));

            connection.SubmitRequest(new DirectoryRequest(".",
                                    workingDirectory.CvsRoot.CvsRepository +
                                    "/" + workingDirectory.ModuleName));

            connection.SubmitRequest(new ExpandModulesRequest());

            connection.SubmitRequest(
                new ArgumentRequest(ArgumentRequest.Options.MODULE_NAME));

            if (null != this.Revision) {
                connection.SubmitRequest (new ArgumentRequest (ArgumentRequest.Options.REVISION));
                connection.SubmitRequest(new ArgumentRequest(this.Revision));
            }
            if (this._hasDate) {
                connection.SubmitRequest (new ArgumentRequest (ArgumentRequest.Options.DATE));
                connection.SubmitRequest(new ArgumentRequest(this.DateAsString));
            }
            if (null != this.OverrideDirectory) {
                connection.SubmitRequest (
                    new ArgumentRequest (ArgumentRequest.Options.OVERRIDE_DIRECTORY));
                connection.SubmitRequest (
                    new ArgumentRequest (this.OverrideDirectory));
            }

            connection.SubmitRequest(new ArgumentRequest(this.Module));

            connection.SubmitRequest(new DirectoryRequest(".",
                                    workingDirectory.CvsRoot.CvsRepository +
                                    "/" + this.Module));

            connection.SubmitRequest(new CheckoutRequest());
            Manager manager = new Manager (connection.Repository.WorkingPath);
        }
Example #37
0
        /// <summary>
        /// Do the dirty work.
        /// </summary>
        /// <param name="connection"></param>
        public void Execute(ICommandConnection connection)
        {
            foreach (Folder folder in this.Folders.Values)
            {
                this.SetDirectory(connection, folder);

                if (defaultBranch)
                {
                    connection.SubmitRequest(new ArgumentRequest("-b"));
                }
                if (headerAndDescOnly)
                {
                    connection.SubmitRequest(new ArgumentRequest("-t"));
                }
                if (headerOnly)
                {
                    connection.SubmitRequest(new ArgumentRequest("-h"));
                }
                if (noTags)
                {
                    connection.SubmitRequest(new ArgumentRequest("-N"));
                }

                // add any date arguments
                foreach (object o in dateArgs)
                {
                    string dateArg = (string)o;
                    connection.SubmitRequest(new ArgumentRequest("-d"));
                    connection.SubmitRequest(new ArgumentRequest(dateArg));
                }

                foreach (DictionaryEntry de in folder.Entries)
                {
                    Entry entry = (Entry)de.Value;
                    // Only submit the entry information if the entry is not
                    // a directory.
                    if (!entry.IsDirectory)
                    {
                        DateTime old = entry.TimeStamp;
                        entry.TimeStamp = entry.TimeStamp;

                        String fileName = Path.Combine(entry.Path, entry.Name);
                        this.SendEntryRequest(connection, entry);
                    }
                }
            }

            string relativeDirectory;

            if (this.directory != null && this.directory.Length > 0)
            {
                if (null == this.directory)
                {
                    this.directory = ".";
                }
                relativeDirectory = this.directory;
            }
            else
            {
                relativeDirectory = workingDirectory.WorkingDirectoryName;
            }
            // Note: don't use Path.Combine() as the separator must be "/"
            string repositoryDir = workingDirectory.CvsRoot.CvsRepository + "/" + relativeDirectory;

            connection.SubmitRequest(new DirectoryRequest(relativeDirectory, repositoryDir));

            if (defaultBranch)
            {
                connection.SubmitRequest(new ArgumentRequest("-b"));
            }
            if (headerAndDescOnly)
            {
                connection.SubmitRequest(new ArgumentRequest("-t"));
            }
            if (headerOnly)
            {
                connection.SubmitRequest(new ArgumentRequest("-h"));
            }
            if (noTags)
            {
                connection.SubmitRequest(new ArgumentRequest("-N"));
            }

            if (!recursive)
            {
                connection.SubmitRequest(new ArgumentRequest("-l"));
            }

            // add any date arguments
            foreach (object o in dateArgs)
            {
                string dateArg = (string)o;
                connection.SubmitRequest(new ArgumentRequest("-d"));
                connection.SubmitRequest(new ArgumentRequest(dateArg));
            }

            if (this.entry != null)
            {
                connection.SubmitRequest(new EntryRequest(this.entry));
            }

            connection.SubmitRequest(new LogRequest());
        }
Example #38
0
        /// <summary>
        /// Do the dirty work.
        /// </summary>
        /// <param name="connection"></param>
        public void Execute(ICommandConnection connection) {
            foreach (Folder folder in this.Folders.Values) {
                this.SetDirectory (connection, folder);
                
                if (defaultBranch) {
                    connection.SubmitRequest(new ArgumentRequest("-b"));
                }
                if (headerAndDescOnly) {
                    connection.SubmitRequest(new ArgumentRequest("-t"));
                }
                if (headerOnly) {
                    connection.SubmitRequest(new ArgumentRequest("-h"));
                }
                if (noTags) {
                    connection.SubmitRequest(new ArgumentRequest("-N"));
                }

                // add any date arguments
                foreach (object o in dateArgs) {
                    string dateArg = (string)o;
                    connection.SubmitRequest(new ArgumentRequest("-d"));
                    connection.SubmitRequest(new ArgumentRequest(dateArg));
                }

                foreach (DictionaryEntry de in folder.Entries) {
                    Entry entry = (Entry)de.Value;
                    // Only submit the entry information if the entry is not
                    // a directory.
                    if (!entry.IsDirectory) {
                        DateTime old = entry.TimeStamp;
                        entry.TimeStamp = entry.TimeStamp;

                        String fileName = Path.Combine(entry.Path, entry.Name);
                        this.SendEntryRequest (connection, entry);
                    }
                }
            }

            string relativeDirectory;
            if (this.directory != null && this.directory.Length > 0) {
                if (null == this.directory) {
                    this.directory = ".";
                }
                relativeDirectory = this.directory;
            } else {
                relativeDirectory = workingDirectory.WorkingDirectoryName;
            }
            // Note: don't use Path.Combine() as the separator must be "/"
            string repositoryDir = workingDirectory.CvsRoot.CvsRepository + "/" + relativeDirectory;
            connection.SubmitRequest(new DirectoryRequest(relativeDirectory, repositoryDir));

            if (defaultBranch) {
                connection.SubmitRequest(new ArgumentRequest("-b"));
            }
            if (headerAndDescOnly) {
                connection.SubmitRequest(new ArgumentRequest("-t"));
            }
            if (headerOnly) {
                connection.SubmitRequest(new ArgumentRequest("-h"));
            }
            if (noTags) {
                connection.SubmitRequest(new ArgumentRequest("-N"));
            }

            if (!recursive) {
                connection.SubmitRequest(new ArgumentRequest("-l"));
            }

            // add any date arguments
            foreach (object o in dateArgs) {
                string dateArg = (string)o;
                connection.SubmitRequest(new ArgumentRequest("-d"));
                connection.SubmitRequest(new ArgumentRequest(dateArg));
            }

            if (this.entry != null) {
                connection.SubmitRequest (new EntryRequest (this.entry));
            }

            connection.SubmitRequest (new LogRequest());

        }
Example #39
0
        /// <summary>
        /// Do the dirty work.
        /// </summary>
        /// <param name="connection"></param>
        public void Execute(ICommandConnection connection)
        {
            if (this.Quieter) {
                connection.SubmitRequest(new ArgumentRequest(Option.QUIETER));
            }
            if (this.EntryFormat) {
                connection.SubmitRequest(new ArgumentRequest(Option.ENTRY_FORMAT));
            }
            if (this.AllDetails) {
                connection.SubmitRequest(new ArgumentRequest(Option.ALL_DETAILS));
            }
            if (this.Recursive) {
                connection.SubmitRequest(new ArgumentRequest(Option.RECURSIVE));
            }
            if (this.LocalTime) {
                connection.SubmitRequest(new ArgumentRequest(Option.LOCAL_TIME));
            }
            if (null != this.Tag && this.Tag.Length != 0) {
                connection.SubmitRequest(new ArgumentRequest(Option.TAG));
            }
            if (this.Prune) {
                connection.SubmitRequest(new ArgumentRequest(Option.PRUNE));
            }

            // add any date arguments
            foreach (object o in dateArgs) {
                string dateArg = (string)o;
                connection.SubmitRequest(new ArgumentRequest(Option.DATE));
                connection.SubmitRequest(new ArgumentRequest(dateArg));
            }

            connection.SubmitRequest (new ListRequest());
        }     
Example #40
0
 /// <summary>
 /// Process the login command with cvs library API calls.
 /// </summary>
 public void Execute (ICommandConnection connection) {
     this.Execute();
 }
Example #41
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);
        }
Example #42
0
        /// <summary>
        /// Execute the diff command.
        /// </summary>
        /// <param name="connection"></param>
        public void Execute(ICommandConnection connection)
        {
            connection.SubmitRequest(new DirectoryRequest(".",
                                    workingdirectory.CvsRoot.CvsRepository +
                                    directory));

            if (IsIgnoringCase) {
                connection.SubmitRequest(new ArgumentRequest("-i"));
            }
            if (IsIgnoringAllWhitespace) {
                connection.SubmitRequest(new ArgumentRequest("-w"));
            }
            if (IsIgnoringBlankLines) {
                connection.SubmitRequest(new ArgumentRequest("-B"));
            }
            if (IsIgnoringSpaceChange) {
                connection.SubmitRequest(new ArgumentRequest("-b"));
            }

            connection.SubmitRequest(new ArgumentRequest(entry.Name));
            connection.SubmitRequest(new DiffRequest());
        }
Example #43
0
 /// <summary>
 /// Produce the report.
 /// </summary>
 /// <param name="xmlFilename"></param>
 /// <param name="connection"></param>
 public void Run(string xmlFilename, ICommandConnection connection) {
     XmlTextWriter textWriter = new XmlTextWriter(xmlFilename, new UTF8Encoding());
     Run(textWriter, connection);
 }
        public TResponse Execute(ICommandConnection connection)
        {
            if (_lockExecute == null)
            {
                _lockExecute = new object();
            }

            lock (_lockExecute)
            {
                Connection = connection;

                if (connection == null)
                {
                    throw new ArgumentNullException(nameof(connection), "Command connection cannot be null.");
                }

                var packet              = GetPacket();
                var parser              = new TParser();
                var response            = new TResponse();
                var parserCompleteEvent = new AutoResetEvent(false);

                parser.CommandPacket = packet;

                var parserResponse = default(TParserResponse);
                parser.ParserComplete += (s, e) =>
                {
                    Debug.WriteLine("Parser complete");
                    parserResponse = e.Response;
                    parserCompleteEvent.Set();
                };

                Exception parserException = null;
                parser.ParserError += (s, e) =>
                {
                    Debug.WriteLine("Parser error");
                    parserException = e.Exception;
                    parserCompleteEvent.Set();
                };

                EventHandler <DataReceivedEventArgs> dataReceivedEventHandler = (s, e) => parser.Parse(e.Data);

                if (ResponseTimeout > 0)
                {
                    Debug.WriteLine("Attach parser");
                    connection.DataReceived += dataReceivedEventHandler;
                }

                try
                {
                    Debug.WriteLine("Send: " + Encoding.UTF8.GetString(packet.Data).Replace("\r\n", ""));

                    connection.Send(packet.Data);

                    // If response timeout is 0, do not wait parser to complete
                    if (ResponseTimeout > 0)
                    {
                        // Wait parser to complete
                        var isParserComplete = parserCompleteEvent.WaitOne(ResponseTimeout);

                        Debug.WriteLine("Deattach parser");
                        connection.DataReceived -= dataReceivedEventHandler;

                        if (parserException != null)
                        {
                            ExceptionDispatchInfo.Capture(parserException).Throw();
                        }

                        if (!isParserComplete)
                        {
                            throw new TimeoutException("Command response timeout.");
                        }

                        if (parserResponse != null)
                        {
                            response.ProcessData(parserResponse);
                        }
                    }
                }
                catch
                {
                    if (ResponseTimeout > 0)
                    {
                        Debug.WriteLine("Deattach parser");
                        connection.DataReceived -= dataReceivedEventHandler;
                    }

                    throw;
                }

                return(response);
            }
        }
        /// <summary>
        /// Do the dirty work.
        /// </summary>
        /// <param name="connection"></param>
        public void Execute(ICommandConnection connection)
        {
            //connection.SubmitRequest(new CaseRequest());
            connection.SubmitRequest(new ArgumentRequest("-b"));
            connection.SubmitRequest(new ArgumentRequest("1.1.1"));
            connection.SubmitRequest(new ArgumentRequest("-m"));
            connection.SubmitRequest(new ArgumentRequest(logmessage));

            LOGGER.Info("IMPORT START");

            foreach (DictionaryEntry folder in workingdirectory.Folders) {
                this.SetDirectory(connection, (Folder)folder.Value);
                foreach (Entry entry  in ((Folder)folder.Value).Entries.Values) {
                    this.SendFileRequest(connection, entry);
                }
            }

            connection.SubmitRequest(new ArgumentRequest(workingdirectory.WorkingDirectoryName));
            connection.SubmitRequest(new ArgumentRequest(vendor));
            connection.SubmitRequest(new ArgumentRequest(release));

            connection.SubmitRequest(new ImportRequest());
            if (LOGGER.IsDebugEnabled) {
                LOGGER.Debug ("IMPORT END");
            }
        }
Example #46
0
        /// <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());
        }
Example #47
0
        /// <summary>
        /// Execute the status command against the repository.
        /// </summary>
        /// <param name="connection"></param>
        public void Execute(ICommandConnection connection){
            if (null != this._folders) {
                connection.SubmitRequest(new ArgumentRequest(ArgumentRequest.Options.DASH));

                foreach (Folder folder in this.Folders.Values) {
                    connection.SubmitRequest(new DirectoryRequest(".",
                        this._workingdirectory.CvsRoot.CvsRepository + "/" +
                        folder.Repository.FileContents));
                    foreach (Entry entry in folder.Entries.Values) {
                        connection.SubmitRequest(new EntryRequest(entry));
                        connection.SubmitRequest(new UnchangedRequest(entry.Name));
                    }
                }
            }
            connection.ResponseMessageEvents.MessageResponseMessageEvent +=
                new MessageEventHandler(this.WriteEvent);
            connection.SubmitRequest(new StatusRequest());
        }
Example #48
0
        /// <summary>
        /// Execute the commit command
        /// </summary>
        /// <param name="connection">Cvs server connection</param>
        public void Execute(ICommandConnection connection) {
            connection.SubmitRequest(new ArgumentRequest("-m"));
            connection.SubmitRequest(new ArgumentRequest("LOG MESSAGE"));
            connection.SubmitRequest(new ArgumentRequest(ArgumentRequest.Options.DASH));
            foreach (DictionaryEntry folderEntry in workingdirectory.Folders) {
                Folder folder = (Folder)folderEntry.Value;
                this.SetDirectory(connection, folder);
                foreach (DictionaryEntry entryEntry  in folder.Entries) {
                    Entry entry = (Entry)entryEntry.Value;
                    if (!entry.IsDirectory) {
                        this.SendFileRequest(connection, entry);
                    }
                }

                this.SetDirectory(connection, folder);

                foreach (DictionaryEntry entryEntry in folder.Entries) {
                    Entry entry = (Entry)entryEntry.Value;
                    if (!entry.IsDirectory) {
                        connection.SubmitRequest(new ArgumentRequest(entry.Name));
                    }
                }
            }
            connection.SubmitRequest(new CommitRequest());
        }
Example #49
0
 internal PooledConnection(ICommandConnection inner, Action returnConnection)
 {
     _inner            = inner;
     _returnConnection = returnConnection;
 }
Example #50
0
        private void SendFileRequest (ICommandConnection connection,
            Entry entry) {
            DateTime old = entry.TimeStamp;
            entry.TimeStamp = entry.TimeStamp;
            connection.SubmitRequest (new EntryRequest (entry));
            connection.SubmitRequest(new ModifiedRequest(entry.Name));
            connection.SendFile(entry.FullPath, entry.IsBinaryFile);

            entry.TimeStamp = old;
        }
Example #51
0
 /// <summary>
 /// Produce the report
 /// </summary>
 public void Run(XmlTextWriter textWriter, ICommandConnection connection)
 {
     // send the log command to the cvs server and get the LogReport
     LogReport logReport = logCommand.Run(connection);
     
     // now format the LogReport into a change log
     FormatReport(textWriter, logReport);
 }