Beispiel #1
0
        internal P4PendingChangelist(string Description, P4Connection p4)
        {
            _p4 = p4;
            P4ExceptionLevels oldEx = _p4.ExceptionLevel;
            try
            {
                // we want to throw an exception if there are any errors.
                _p4.ExceptionLevel = P4ExceptionLevels.NoExceptionOnWarnings;
                baseForm = _p4.Fetch_Form("change");

                // clear the Jobs list
                baseForm.ArrayFields["Jobs"] = new string[0];

                // clear the Files list
                baseForm.ArrayFields["Files"] = new string[0];

                // save the description
                baseForm.Fields["Description"] = Description;

                P4UnParsedRecordSet r = _p4.Save_Form(baseForm);
            
                // convert to int to verify we're parsing correctly
                int changeNumber = int.Parse(r.Messages[0].Split(' ')[1]);
                baseForm.Fields["Change"] = changeNumber.ToString();
                
            }
            // no catch... we want the exception bubled up.
            finally
            {
                p4.ExceptionLevel = oldEx;
            }

        }
Beispiel #2
0
        /// <summary>
        /// Parse the raw text of a Perforce form into a P4Form object
        /// </summary>
        /// <param name="formCommand">The form command.</param>
        /// <param name="formContents">Raw contents of the form spec.</param>
        /// <returns>
        /// A P4Form object.  The fields of the form can be read or updated.  If you update a filed, you can save it with Save_Form.
        /// </returns>
        /// <include file='CodeDocuments.xml' path='//Forms/remarks' />
        public P4Form Parse_Form(string formCommand, string formContents)
        {
            // logic stolen from P4Ruby.  Cache the spec defs, and load a form from the cached specdefs.

            // If we don't have a cached Spec def, we need to create a dummy form to get it in the cache
            if (!cachedSpecDefs.ContainsKey(formCommand))
            {
                string bogusSpec = "__p4net_bogus_spec__";
                P4Form outputForm;

                //
                // For specs of the following types we need the bogus spec name
                //
                if (formCommand == "branch" || formCommand == "label" || formCommand == "depot" || formCommand == "group")
                {
                    outputForm = Fetch_Form(formCommand, bogusSpec);
                }
                else
                {
                    outputForm = Fetch_Form(formCommand);
                }
            }

            return(P4Form.LoadFromSpec(formCommand, cachedSpecDefs[formCommand], formContents, m_ClientApi.Encoding));
        }
Beispiel #3
0
        internal P4PendingChangelist(string Description, P4Connection p4)
        {
            _p4 = p4;
            P4ExceptionLevels oldEx = _p4.ExceptionLevel;

            try
            {
                // we want to throw an exception if there are any errors.
                _p4.ExceptionLevel = P4ExceptionLevels.NoExceptionOnWarnings;
                baseForm           = _p4.Fetch_Form("change");

                // clear the Jobs list
                baseForm.ArrayFields["Jobs"] = new string[0];

                // clear the Files list
                baseForm.ArrayFields["Files"] = new string[0];

                // save the description
                baseForm.Fields["Description"] = Description;

                P4UnParsedRecordSet r = _p4.Save_Form(baseForm);

                // convert to int to verify we're parsing correctly
                int changeNumber = int.Parse(r.Messages[0].Split(' ')[1]);
                baseForm.Fields["Change"] = changeNumber.ToString();
            }
            // no catch... we want the exception bubled up.
            finally
            {
                p4.ExceptionLevel = oldEx;
            }
        }
Beispiel #4
0
 /// <summary>
 /// Saves the form to Perforce.
 /// </summary>
 /// <param name="Form">The P4Form object retrieved from Fetch_Form.</param>
 /// <param name="Force">True to pass the '-f' flag when saving.</param>
 /// <include file='CodeDocuments.xml' path='//Forms/remarks' />
 /// <returns>P4UnParsedRecordSet.  Output can be parsed to verify the form was processed correctly.</returns>
 public P4UnParsedRecordSet Save_Form(P4Form Form, bool Force)
 {
     if (Form == null)
     {
         throw new ArgumentNullException("Form");
     }
     return(Save_Form(Form.FormCommand, Form.FormatSpec(), Force));
 }
Beispiel #5
0
 /// <summary>
 /// Saves the form to Perforce.
 /// </summary>
 /// <param name="Form">The P4Form object retrieved from Fetch_Form.</param>
 /// <param name="args">Arguments passed to the form command.</param>
 /// <include file='CodeDocuments.xml' path='//Forms/remarks' />
 /// <returns>P4UnParsedRecordSet.  Output can be parsed to verify the form was processed correctly.</returns>
 public P4UnParsedRecordSet Save_Form(P4Form Form, params string[] args)
 {
     if (Form == null)
     {
         throw new ArgumentNullException("Form");
     }
     return(Save_Form(Form.FormCommand, Form.FormatSpec(), args));
 }
Beispiel #6
0
 internal override void Finished()
 {
     if (base.TaggedOutputs.Count != 1 || base.SpecDef == null)
     {
         throw new Exceptions.FormFetchException(_FormCommand, "Unexpected output attemting to fetch form!");
     }
     Dictionary<string, string> ht = base.TaggedOutputs[0].AllFieldDictionary;
     _Form = new P4Form(_FormCommand, base.SpecDef, ht, _encoding);
 }
Beispiel #7
0
        internal override void Finished()
        {
            if (base.TaggedOutputs.Count != 1 || base.SpecDef == null)
            {
                throw new Exceptions.FormFetchException(_FormCommand, "Unexpected output attemting to fetch form!");
            }
            Dictionary <string, string> ht = base.TaggedOutputs[0].AllFieldDictionary;

            _Form = new P4Form(_FormCommand, base.SpecDef, ht, _encoding);
        }
Beispiel #8
0
 /// <summary>
 /// Saves the form to Perforce.
 /// </summary>
 /// <param name="Form">The P4Form object retrieved from Fetch_Form.</param>
 /// <include file='CodeDocuments.xml' path='//Forms/remarks' />
 /// <returns>P4UnParsedRecordSet.  Output can be parsed to verify the form was processed correctly.</returns>
 public P4UnParsedRecordSet Save_Form(P4Form Form)
 {
     return(Save_Form(Form, false));
 }
Beispiel #9
0
        /// <summary>
        /// Copies the P4Form object into a new instance.
        /// </summary>
        /// <returns>A copy of the P4Form object.</returns>
        public P4Form Clone()
        {
            P4Form clone = new P4Form(_formCommand, _specdef, base.AllFieldDictionary, _encoding);

            return(clone);
        }
Beispiel #10
0
 /// <summary>
 /// Saves the form to Perforce.
 /// </summary>
 /// <param name="Form">The P4Form object retrieved from Fetch_Form.</param>
 /// <param name="args">Arguments passed to the form command.</param>
 /// <include file='CodeDocuments.xml' path='//Forms/remarks' />
 /// <returns>P4UnParsedRecordSet.  Output can be parsed to verify the form was processed correctly.</returns>
 public P4UnParsedRecordSet Save_Form(P4Form Form, params string[] args)
 {
     if (Form == null) throw new ArgumentNullException("Form");
     return Save_Form(Form.FormCommand, Form.FormatSpec(), args);
 }
Beispiel #11
0
 /// <summary>
 /// Saves the form to Perforce.
 /// </summary>
 /// <param name="Form">The P4Form object retrieved from Fetch_Form.</param>
 /// <param name="Force">True to pass the '-f' flag when saving.</param>
 /// <include file='CodeDocuments.xml' path='//Forms/remarks' />
 /// <returns>P4UnParsedRecordSet.  Output can be parsed to verify the form was processed correctly.</returns>
 public P4UnParsedRecordSet Save_Form(P4Form Form, bool Force)
 {
     if (Form == null) throw new ArgumentNullException("Form");
     return Save_Form(Form.FormCommand, Form.FormatSpec(), Force);
 }
Beispiel #12
0
 /// <summary>
 /// Saves the form to Perforce.
 /// </summary>
 /// <param name="Form">The P4Form object retrieved from Fetch_Form.</param>
 /// <include file='CodeDocuments.xml' path='//Forms/remarks' />
 /// <returns>P4UnParsedRecordSet.  Output can be parsed to verify the form was processed correctly.</returns>
 public P4UnParsedRecordSet Save_Form(P4Form Form)
 {
     return Save_Form(Form, false);
 }
Beispiel #13
0
 internal override void AddTag(Hashtable S)
 {
     _Form = new P4Form(_FormCommand, base.SpecDef, S, _encoding);
 }
Beispiel #14
0
 /// <summary>
 /// Copies the P4Form object into a new instance.
 /// </summary>
 /// <returns>A copy of the P4Form object.</returns>
 public P4Form Clone()
 {
     P4Form clone = new P4Form(_formCommand, _specdef, base.AllFieldDictionary, _encoding);
     return clone;
 }