Example #1
0
        /// <summary>
        /// Get a list of streams from the repository
        /// </summary>
        /// <param name="options">options for the streams command<see cref="StreamsCmdOptions"/></param>
        /// <param name="files">files to filter results by</param>
        /// <returns>A list containing the matching streams</returns>
        /// <remarks>
        /// <br/><b>p4 help streams</b>
        /// <br/>
        /// <br/>     streams -- Display list of streams
        /// <br/>
        /// <br/>     p4 streams [-U -F filter -T fields -m max] [streamPath ...]
        /// <br/>
        /// <br/>   Reports the list of all streams currently known to the system.  If
        /// <br/>   a 'streamPath' argument is specified, the list of streams is limited
        /// <br/>   to those matching the supplied path. Unloaded task streams are not
        /// <br/>   listed by default.
        /// <br/>
        /// <br/>   For each stream, a single line of output lists the stream depot path,
        /// <br/>   the type, the parent stream depot path, and the stream name.
        /// <br/>
        /// <br/>   The -F filter flag limits the output to files satisfying the expression
        /// <br/>   given as 'filter'.  This filter expression is similar to the one used
        /// <br/>   by 'jobs -e jobview',  except that fields must match those above and
        /// <br/>   are case sensitive.
        /// <br/>
        /// <br/>           e.g. -F "Parent=//Ace/MAIN &amp; Type=development"
        /// <br/>
        /// <br/>   Note: the filtering takes place post-compute phase; there are no
        /// <br/>   indexes to optimize performance.
        /// <br/>
        /// <br/>   The -T fields flag (used with tagged output) limits the fields output
        /// <br/>   to those specified by a list given as 'fields'.  These field names can
        /// <br/>   be separated by a space or a comma.
        /// <br/>
        /// <br/>           e.g. -T "Stream, Owner"
        /// <br/>
        /// <br/>   The -m max flag limits output to the first 'max' number of streams.
        /// <br/>
        /// <br/>   The -U flag lists unloaded task streams (see 'p4 help unload').
        /// <br/>
        /// <br/>
        /// </remarks>
        /// <example>
        ///         To get the first 3 development type streams with the parent //flow/mainline:
        ///
        /// <code>
        ///         IList&#60;Stream&#62; = rep.GetStreams(new Options(StreamsCmdFlags.None,
        ///                    "Parent=//flow/mainline &amp; Type=development", null, "//...", 3));
        /// </code>
        /// </example>
        public IList <Stream> GetStreams(Options options, params FileSpec[] files)
        {
            P4Command cmd = null;

            if ((files != null) && (files.Length > 0))
            {
                cmd = new P4Command(this, "streams", true, FileSpec.ToStrings(files));
            }
            else
            {
                cmd = new P4Command(this, "streams", true);
            }

            P4CommandResult results = cmd.Run(options);

            if (results.Success)
            {
                if ((results.TaggedOutput == null) || (results.TaggedOutput.Count <= 0))
                {
                    return(null);
                }
                List <Stream> value = new List <Stream>();

                bool   dst_mismatch = false;
                string offset       = string.Empty;

                if (Server != null && Server.Metadata != null)
                {
                    offset       = Server.Metadata.DateTimeOffset;
                    dst_mismatch = FormBase.DSTMismatch(Server.Metadata);
                }

                foreach (TaggedObject obj in results.TaggedOutput)
                {
                    Stream stream = new Stream();
                    stream.FromStreamsCmdTaggedOutput(obj, offset, dst_mismatch);
                    value.Add(stream);
                }
                return(value);
            }
            else
            {
                P4Exception.Throw(results.ErrorList);
            }
            return(null);
        }
Example #2
0
        /// <summary>
        /// Get a list of jobs from the repository
        /// </summary>
        /// <param name="options">options for the jobs command<see cref="JobsCmdFlags"/></param>
        /// <param name="files">list of files to filter jobs by</param>
        /// <returns>A list containing the matching jobs</returns>
        /// <remarks>
        /// <br/><b>p4 help jobs</b>
        /// <br/>
        /// <br/>     jobs -- Display list of jobs
        /// <br/>
        /// <br/>     p4 jobs [-e jobview -i -l -m max -r] [file[revRange] ...]
        /// <br/>     p4 jobs -R
        /// <br/>
        /// <br/>   Lists jobs in the server. If a file specification is included, fixes
        /// <br/>   for submitted changelists affecting the specified files are listed.
        /// <br/>   The file specification can include wildcards and a revision range.
        /// <br/>    See 'p4 help revisions' for details about specifying revisions.
        /// <br/>
        /// <br/>   The -e flag lists jobs matching the expression specified in the
        /// <br/>   jobview parameter. For a description of jobview syntax, see 'p4 help
        /// <br/>   jobview'.
        /// <br/>
        /// <br/>   The -i flag includes any fixes made by changelists integrated into
        /// <br/>   the specified files.
        /// <br/>
        /// <br/>   The -l flag produces long output with the full text of the job
        /// <br/>   descriptions.
        /// <br/>
        /// <br/>   The -m max flag limits the output to the first 'max' jobs, ordered
        /// <br/>   by their job name.
        /// <br/>
        /// <br/>   The -r flag sorts the jobs in reverse order (by job name).
        /// <br/>
        /// <br/>   The -R flag rebuilds the jobs table and reindexes each job, which
        /// <br/>   is necessary after upgrading to 98.2.  'p4 jobs -R' requires that the
        /// <br/>   user be an operator or have 'super' access granted by 'p4 protect'.
        /// <br/>
        /// <br/>
        /// </remarks>
        /// <example>
        ///
        ///		To get a list of 100 jobs that include files under a given filepath:
        ///		<code>
        ///
        ///         FileSpec path = new FileSpec(new DepotPath(@"//depot/..."), null);
        ///         IList&#60;Job&#62; jobs = rep.GetJobs((new Options(JobsCmdFlags.LongDescriptions, null, 100)), path);
        ///
        ///		</code>
        ///
        ///		To get a list of 100 jobs with the status "open":
        ///		<code>
        ///
        ///         string jobView = "status=open";
        ///         IList&#60;Job&#62; jobs = rep.GetJobs((new Options(JobsCmdFlags.LongDescriptions, jobView, 100)), path);
        ///
        ///		</code>
        ///		To get a list of 10 jobs in reverse order:
        ///     <code>
        ///
        ///        IList&#60;Job&#62; jobs = rep.GetJobs((new Options(JobsCmdFlags.ReverseSort, null, 10));
        ///
        ///		</code>
        ///
        ///     To get a list of 10 jobs that include any fixes made by changelists integrated into
        ///     the specified files:
        ///     <code>
        ///
        ///         FileSpec path = new FileSpec(new DepotPath(@"//depot/..."), null);
        ///         IList&#60;Job&#62; jobs = rep.GetJobs((new Options(JobsCmdFlags.IncludeIntegratedFixes, null, 10)), path);
        ///
        ///     </code>
        ///
        /// </example>
        /// <seealso cref="JobsCmdFlags"/>
        public IList <Job> GetJobs(Options options, params FileSpec[] files)
        {
            P4Command cmd = null;

            if ((files != null) && (files.Length > 0))
            {
                cmd = new P4Command(this, "jobs", true, FileSpec.ToStrings(files));
            }
            else
            {
                cmd = new P4Command(this, "jobs", true);
            }

            P4CommandResult results = cmd.Run(options);

            if (results.Success)
            {
                if ((results.TaggedOutput == null) || (results.TaggedOutput.Count <= 0))
                {
                    return(null);
                }
                List <Job> value             = new List <Job>();
                Dictionary <string, Job> map = new Dictionary <string, Job>();
                foreach (TaggedObject obj in results.TaggedOutput)
                {
                    Job job = new Job();
                    job.FromJobCmdTaggedOutput(obj);
                    value.Add(job);
                }
                return(value);
            }
            else
            {
                P4Exception.Throw(results.ErrorList);
            }
            return(null);
        }